evofabric.core.agent#
AgentNode#
- class evofabric.core.agent.AgentNode(AsyncStreamNode)[source]#
Agent node integrating memory management, tool invocation, LLM invocation, and input/output formatting. Inherits from
AsyncStreamNodeWorkflow:
Sequentially call the memory module’s
retrieval_update()to update the model context.Format the input according to the
input_msg_formattemplate.Call LLM Client to get the response.
Execute the invoked tools on demand.
Format the reply according to the
output_msg_formattemplate.Call the memory module’s
add_messages()method sequentially to update memory.
- Parameters:
client (ChatClientBase) – LLM backend client.
system_prompt (str, optional) – System prompt.
inference_kwargs (Dict, optional) – Inference parameters when calling LLM.
tool_manager (Union[ToolManagerBase, List[ToolManagerBase]], optional) – Tool Manager or Manager List.
memory (Union[MemBase, List[MemBase]], optional) – Memory component or component list.
output_schema (Optional[Type[BaseModel]], optional) – The Pydantic model expected to be returned by the LLM.
output_msg_format (Optional[str], optional) – jinja2 template string used for rendering LLM output; must also provide
output_schemainput_msg_format (Optional[str], optional) – jinja2 template string used to format input state into a single user message.
- __call__(self, state: State, stream_writer: StreamWriter) StateDelta[source]#
Execute agent reasoning.
- Parameters:
state (State) – Input state must contain the
messagesfield.stream_writer (StreamWriter) – Streaming output writer.
- Returns:
Incremental state, containing the updated message.
- Return type:
StateDelta
UserNode#
- class evofabric.core.agent.UserNode(AsyncNode)[source]#
A node that obtains user input from the terminal and provides asynchronous input to the graph.
Inherits from
AsyncNode.UserNode automatically handles the following exceptions:
EOFError: User input stream ended (e.g., end-of-file marker)
KeyboardInterrupt: User interrupts input (Ctrl+C)
Other Exceptions: Catch all unexpected errors
An empty state increment will be returned in all abnormal situations:
{"messages": []}- Parameters:
prompt_message (str) – User input prompt. Default: ``Please enter your input: ``
input_key (str) – The key name for storing user input in the state. Default is
user_input