ChainContext#
- class council.contexts.ChainContext(chat_history: ChatHistory, chain_history: List[ChainHistory])[source]#
Bases:
MessageCollectionClass representing the execution context of a
Chain.- __init__(chat_history: ChatHistory, chain_history: List[ChainHistory])[source]#
Initializes the ChainContext with the provided chat and chain history.
- Parameters:
chat_history (ChatHistory) – The chat history.
chain_history (List[ChainHistory]) – All the
ChainHistoryfrom the many execution of a chain.
- property current: ChainHistory#
Returns the
ChainHistoryto be used for the current execution of aChain- Returns:
the chain history
- Return type:
- property last_agent_message: ChatMessage | None#
Returns the last message of kind
ChatMessageKind.Agent, if any, otherwise None- Return type:
Optional[ChatMessage]
- property last_message: ChatMessage | None#
Returns the last message, if any, otherwise None.
- Return type:
Optional[ChatMessage]
- last_message_from_skill(skill_name: str) ChatMessage | None#
Returns the last message generated by a given skill, if any, otherwise None
- Parameters:
skill_name (str) – Name of the skill
- Return type:
Optional[ChatMessage]
- property last_user_message: ChatMessage | None#
Returns the last message of kind
ChatMessageKind.User, if any, otherwise None- Return type:
Optional[ChatMessage]
- property messages: Iterable[ChatMessage]#
Iterates over the collection of messages, in the order they appear in the context
- Returns:
Iterable[ChatMessage]
- new_iteration()[source]#
Prepare this instance for a new execution of a chain by adding a new
ChainHistory
- property reversed: Iterable[ChatMessage]#
Iterates over the collection of messages, in reversed order
- Returns:
Iterable[ChatMessage]
- property try_last_agent_message: Option[ChatMessage]#
Returns the last message of kind
ChatMessageKind.Agentwrapped into anOption- Returns:
Option[ChatMessage]
- property try_last_message: Option[ChatMessage]#
Returns the last message, wrapped into an
Option- Return type:
- try_last_message_from_skill(skill_name: str) Option[ChatMessage]#
Returns the last message generated by a given skill, wrapped into an
Option- Parameters:
skill_name (str) – Name of the skill
- Return type:
- property try_last_user_message: Option[ChatMessage]#
Returns the last message of kind
ChatMessageKind.User, wrapped into an :class:`Option- Return type: