SkillContext#
- class council.contexts.SkillContext(store: AgentContextStore, execution_context: ExecutionContext, name: str, budget: Budget, messages: Iterable[ChatMessage], iteration: Option[IterationContext])[source]#
Bases:
ChainContextClass representing the execution context of a
SkillBase.- append(message: ChatMessage) None#
adds the message to the context
- property cancellation_token: CancellationToken#
returns the cancellation token
- property chain_histories: Iterable[MessageCollection]#
returns the collections of all messages generated by the current chain, grouped by execution iteration
- property chat_history: ChatHistory#
the chat history
- property current: MessageCollection#
Returns the
MessageCollectionfor the current execution of aChain- Returns:
a collection of messages
- Return type:
- static empty() ChainContext#
helper function that creates a new empty instance.
For test purpose only.
- execution_log_to_dict() Dict[str, Any]#
returns the execution log as a dictionary
- execution_log_to_json() str#
returns the execution as a JSON string
- extend(messages: Iterable[ChatMessage]) None#
adds many message to the context
- fork_for(monitored: Monitored, budget: Budget | None = None) ChainContext#
forks the context for the given object, adjust the execution context appropriately
- static from_agent_context(context: AgentContext, monitored: Monitored, name: str, budget: Budget | None = None)#
creates a new instance from an
AgentContext, adjust the execution context appropriately.
- static from_chat_history(history: ChatHistory, budget: Budget | None = None) ChainContext#
helper function that creates a new instance from a
ChatHistory.For test purpose only.
- static from_user_message(message: str, budget: Budget | None = None) ChainContext#
creates a new instance from a user message. The
ChatHistorycontains only the user message
- property iteration: Option[IterationContext]#
The iteration context, if any.
- Returns:
Some iteration context, if any, else
Option.none()- Return type:
- property iteration_count: int#
the number of iteration for this execution
- 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 log_entry: ExecutionLogEntry#
the log entry
- merge(contexts: List[ChainContext]) None#
merge the given context to the context
- property messages: Iterable[ChatMessage]#
returns all the visible messages for the chain, ordered by execution iteration (oldest first). This contains:
the
ChatHistoryall messages from previous iterations
visible messages from current iteration
- new_log_entry(monitored: Monitored) ExecutionLogEntry#
creates a new log entry from this context
- property reversed: Iterable[ChatMessage]#
similar to
messages(), but in reverse order (most recent first).
- should_stop() bool#
returns True is the execution of the chain should be stopped. False otherwise. :returns: True is either the budget is expired or the cancellation token is set :rtype: bool
- 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: