MakeAgents 0.2.1¶
- class make_agents.End¶
Can be used to end the action graph.
- class make_agents.Start¶
Used to mark the start of the action graph.
- make_agents.action(func: callable) callable ¶
A decorator to create action functions — functions to be used by the agent. An action function must have at most one parameter, which must be annotated with a Pydantic model.
Note that the following should be considered part of the “prompt” for the agent:
The name of the function
The Pydantic model, if the function has a parameter
The function’s docstring (don’t annotate the parameter in the docstring, use the Pydantic model for this)
- Parameters:
func (callable) – The function to be decorated.
- Returns:
The same function, with metadata attached.
- Return type:
callable
- Raises:
ValueError – If the function has more than one parameter, or if the parameter is not annotated with a Pydantic model.
- make_agents.run_agent(action_graph: dict | callable, messages_init: list[dict] | None = None, completion: callable | None = <function get_completion_func.<locals>.completion>, pre_llm_callback: callable | None = <function identity>) Iterator[list[dict[str, str]]] ¶
Run an agent. This is a generator that yields the list of messages after each step. Be mindful that the yielded messages are mutable, allowing them to be modified in place, (make copies if you want to avoid this).
- Parameters:
action_graph (Union[dict[callable, list[callable]], callable]) – The graph of actions that the agent can take. Can either be a dictionary or a callable. Use a callable to create a dynamic action graph. (See examples in the README)
messages_init (Optional[list[dict]], optional) – Optionally initialise the list of messages, e.g. to specify a custom system prompt. If not provided, the default system prompt will be used.
completion (Optional[callable], optional) – The function that will be used to get completions from the LLM.
pre_llm_callback (Optional[callable], optional) – This function is called before any LLM calls. It will be passed the list of messages, and can modify it in place. Can be used for, e.g. reducing the list of messages to only the most recent ones, or reducing the list by summarising, etc.
- Yields:
Iterator[list[dict[str, str]]] – At each step, the list of messages is yielded, i.e. the same list that was yielded in the previous step, with one more message appended.