aixplain.factories.agent_factory.utils
build_tool_payload
def build_tool_payload(tool: Union[Tool, Model])
Build a tool payload from a tool or model object.
Arguments:
tool
Union[Tool, Model] - The tool or model object to build the payload from.
Returns:
Dict
- The tool payload.
build_tool
def build_tool(tool: Dict)
Build a tool from a dictionary.
Arguments:
tool
Dict - Tool dictionary.
Returns:
Tool
- Tool object.
build_llm
def build_llm(payload: Dict, api_key: Text = config.TEAM_API_KEY) -> LLM
Build a Large Language Model (LLM) instance from a dictionary configuration.
This function attempts to create an LLM instance either from a cached LLM object in the payload or by creating a new instance using the provided configuration.
Arguments:
payload
Dict - Dictionary containing LLM configuration and possibly a cached LLM object.api_key
Text, optional - API key for authentication. Defaults to config.TEAM_API_KEY.
Returns:
LLM
- Instantiated LLM object with configured parameters.
build_agent
def build_agent(payload: Dict,
tools: List[Tool] = None,
api_key: Text = config.TEAM_API_KEY) -> Agent
Build an agent instance from a dictionary configuration.
This function creates an agent with its associated tools, LLM, and tasks based on the provided configuration.
Arguments:
payload
Dict - Dictionary containing agent configuration including tools, LLM settings, and tasks.tools
List[Tool], optional - List of pre-configured tools to use. If None, tools will be built from the payload. Defaults to None.api_key
Text, optional - API key for authentication. Defaults to config.TEAM_API_KEY.
Returns:
Agent
- Instantiated agent object with configured tools, LLM, and tasks.
Raises:
ValueError
- If a tool type is not supported.AssertionError
- If tool configuration is invalid.