AgentContext#
- class council.contexts.AgentContext(store: AgentContextStore, execution_context: ExecutionContext, budget: Budget)[source]#
Bases:
ContextBase
the execution context given to an
Agent
- property chains: Iterable[MessageCollection]#
provides read-only access to the messages for each chain executed in the current iteration.
- property chat_history: ChatHistory#
the chat history
- static empty(budget: Budget | None = None) AgentContext [source]#
creates a new instance with no data
- Parameters:
budget (Budget) – Optional, budget allocated for the agent execution
- property evaluation: Sequence[ScoredChatMessage]#
provides read-only access to the evaluation of the current iteration
- 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
- static from_chat_history(chat_history: ChatHistory, budget: Budget | None = None) AgentContext [source]#
creates a new instance from a
ChatHistory
- Parameters:
chat_history (ChatHistory) – The chat history to initialize the new agent context
budget (Budget) – Optional, budget allocated for the agent execution
- static from_user_message(message: str, budget: Budget | None = None) AgentContext [source]#
creates a new instance from a user message. The
ChatHistory
contains only the given message- Parameters:
message – the user message to start with
budget (Budget) – Optional, budget allocated for the agent execution
- property iteration_count: int#
the number of iteration for this execution
- property log_entry: ExecutionLogEntry#
the log entry
- new_agent_context_for(monitored: Monitored) AgentContext [source]#
creates a new instance for the given object, adjusting the execution context appropriately
- Parameters:
monitored – the object to create a new context for
- new_agent_context_for_execution_unit(name: str) AgentContext [source]#
creates a new instance, adjusting the execution context for the given name
- Parameters:
name – name used in the
ExecutionContext
- new_agent_context_for_new_iteration() AgentContext [source]#
creates a new instance, adjusting the execution context appropriately
- new_log_entry(monitored: Monitored) ExecutionLogEntry #
creates a new log entry from this context
- set_evaluation(messages: Iterable[ScoredChatMessage]) None [source]#
sets the evaluation result for the current execution iteration
- Parameters:
messages (Iterable[ScoredChatMessage]) – the result of the evaluation