context
Agent chat context
Primarily provides the EleanorAIRequestContext
class which encapsulates all logic
needed to generate an agent’s response to a chat.
Attributes
Classes
ChatTraceMetadata
ChatType
EleanorAIRequestContext
Bases: BaseDataModel
Contains context information needed to invoke an Eleanor-managed response to an input
Attributes:
-
namespace
(Namespace
) –Namespace where the user(s), agent(s), session, and LLM belong to
-
chat
(CanonicalChat
) –Chat conversation object
-
chat_users
(Dict[str, str]
) –Detected user(s) dictionary that maps name to pkid
-
chat_agents
(Dict[str, str]
) –Detected agent(s) dictionary that maps name to pkid
-
chat_type
(ChatType
) –The chat type
-
responding_agent
(Agent
) –Agent that will be responding to the request
-
session
(ActivitySession
) –Session where the response is generated in
-
participant_session
(ActivitySessionParticipant
) –Participant session (the table that links the responding agent to the selected session)
-
responding_agent_settings
(AgentResourceSettings
) –Responding Agent Settings
-
update_collection_ref
(Optional[MemoryCollection]
) –Memory collection reference to update during chat completions
-
eleanor_framework_header
(Optional[EleanorFrameworkHeader]
) –Parsed Eleanor Framework Header object detected from input
-
retrieved_memories
(Any
) –Retrieved memory metadata, populated when the agent adds memories to the chat conversation
-
llm_spec
(LLMSettings
) –Configuration spec for the detected LLM
-
llm
(BaseLanguageModel
) –Instance of a Langchain BaseLanguageModel pre-configured to handle the request and invoked to generate the agent’s response
Attributes
chat
class-attribute
instance-attribute
chat: CanonicalChat = Field(
...,
title="Canonical Chat",
description="Chat conversation object",
)
chat_agents
class-attribute
instance-attribute
chat_agents: Dict[str, str] = Field(
...,
title="Chat Agents",
description="Detected agent(s) dictionary that maps name to pkid",
)
chat_trace_metadata
property
Returns LangFuse trace metadata dictionary derived from the context values
Returns:
-
Dict
(Dict
) –The metadata object containing information about the chat trace.
chat_type
class-attribute
instance-attribute
chat_type: ChatType = Field(
..., title="Chat Type", description="The chat type"
)
chat_users
class-attribute
instance-attribute
chat_users: Dict[str, str] = Field(
...,
title="Chat USers",
description="Detected user(s) dictionary that maps name to pkid",
)
eleanor_framework_header
class-attribute
instance-attribute
eleanor_framework_header: Optional[
EleanorFrameworkHeader
] = Field(
default=None,
title="Eleanor Framework Header",
description="Parsed Eleanor Framework Header object detected from input. Will be None if the header was not provided by the client",
)
llm
class-attribute
instance-attribute
llm: BaseLanguageModel = Field(
...,
title="LLM",
description="Instance of a Langchain BaseLanguageModel pre-configured to handle the request and invoked to generate the agent's response",
)
llm_spec
class-attribute
instance-attribute
llm_spec: LLMSettings = Field(
...,
title="LLM Specification",
description="Configuration spec for the detected LLM. Used to detect prompt formatting information needed for the completions process",
)
model_config
class-attribute
instance-attribute
model_config = ConfigDict(
populate_by_name=True,
use_enum_values=False,
extra="forbid",
strict=False,
arbitrary_types_allowed=True,
)
namespace
class-attribute
instance-attribute
namespace: Namespace = Field(
...,
title="Namespace",
description="Namespace where the user(s), agent(s), session, and LLM belong to",
)
participant_session
class-attribute
instance-attribute
participant_session: ActivitySessionParticipant = Field(
...,
title="Participant Session",
description="Participant session (the table that links the responding agent to the selected session)",
)
responding_agent
class-attribute
instance-attribute
responding_agent: Agent = Field(
...,
title="Responding Agent",
description="Agent that will be responding to the request",
)
responding_agent_settings
class-attribute
instance-attribute
responding_agent_settings: AgentResourceSettings = Field(
...,
title="Responding Agent Settings",
description=__doc__,
)
retrieved_memories
class-attribute
instance-attribute
retrieved_memories: Any = Field(
default_factory=list,
title="Retrieved Memories",
description="Retrieved memory metadata, populated when the agent adds memories to the chat conversation. The main use case for this field is to output debugging information to LangFuse",
)
session
class-attribute
instance-attribute
session: ActivitySession = Field(
...,
title="Session",
description="Session where the response is generated in",
)
update_collection_ref
class-attribute
instance-attribute
update_collection_ref: Optional[MemoryCollection] = Field(
default=None,
title="Update Collection Reference",
description="Memory collection reference to update during chat completions.",
)
Functions
detach_clone
detach_clone(
sa_session: SASession, neo4j_session: NJSession
) -> EleanorAIRequestContext
Creates a deep copy of the current EleanorAIRequestContext instance and detaches its ORM objects from the provided SQLAlchemy session.
Parameters:
-
sa_session
(SASession
) –The SQLAlchemy session from which to detach the ORM objects.
Returns:
-
EleanorAIRequestContext
(EleanorAIRequestContext
) –A deep copy of the current instance with detached ORM objects.
from_oai_chat_completion_request
classmethod
from_oai_chat_completion_request(
request: ChatCompletionRequest,
sa_session: SASession,
neo4j_session: NJSession,
) -> EleanorAIRequestContext
merge
Merges the ORM objects in the current EleanorAIRequestContext instance with the provided SQLAlchemy session.
Parameters:
-
sa_session
(SASession
) –The SQLAlchemy session to use for merging the ORM objects.