Skip to content

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

Bases: BaseDataModel

Contains metadata for a chat completion trace

Attributes

chat_type instance-attribute
chat_type: str
llm instance-attribute
llm: Dict
memories instance-attribute
memories: Any
namespace_name instance-attribute
namespace_name: str
namespace_pkid instance-attribute
namespace_pkid: str
resp_agent_name instance-attribute
resp_agent_name: str
resp_agent_pkid instance-attribute
resp_agent_pkid: str
session_name instance-attribute
session_name: str
session_pkid instance-attribute
session_pkid: str
session_settings instance-attribute
session_settings: Dict
update_collection_name instance-attribute
update_collection_name: str
update_collection_pkid instance-attribute
update_collection_pkid: str

ChatType

Bases: Enum

Chat type enumeration

Attributes

GROUP class-attribute instance-attribute
GROUP = 'group'
SINGLE class-attribute instance-attribute
SINGLE = 'single'

EleanorAIRequestContext

Bases: BaseDataModel

Contains context information needed to invoke an Eleanor-managed response to an input

Attributes:

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
chat_trace_metadata: Dict

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

chat_users_as_string
chat_users_as_string()
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
merge(sa_session: SASession) -> None

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.

refresh
refresh(sa_session: SASession) -> None

Refreshes the ORM objects in the current EleanorAIRequestContext instance.

Parameters:

  • sa_session (SASession) –

    The SQLAlchemy session to use for refreshing the ORM objects.

Functions