Agent Loader

ibm_watsonx_gov.agent_catalog.core.agent_loader.get_agent_input_data_from_schema(schema: dict)

Generates the input data based on the schema

Parameters:

schema (dict) – agent schema.

Returns:

Input data to pass to the agent.

Return type:

str

ibm_watsonx_gov.agent_catalog.core.agent_loader.invoke(agent: AgentInterface, input_data: dict) dict

Executes the agent that implements AgentInterface.

Parameters:
  • agent (AgentInterface) – The agent instance to invoke.

  • input_data (dict) – Input to pass to the agent.

Returns:

Output from the agent.

Return type:

dict

ibm_watsonx_gov.agent_catalog.core.agent_loader.load_agent(agent_name: str, **kwargs) AgentInterface

Loads the agent based on agent name and framework information

Parameters:

agent_name – Agent name

Returns:

The agent instance

Return type:

AgentInterface

Examples

from ibm_watsonx_gov.agent_catalog.core.agent_loader import load_agent import json

agent = load_agent(agent_name=”<AGENT_NAME>”) response = agent.invoke({“<PLACE_HOLDER_NAME>”: “<PLACE_HOLDER_VALUE>”}) response[“result”]

  1. Example of agent loading that expects headers
    from ibm_watsonx_gov.agent_catalog.core.agent_loader import load_agent
    
    headers = {
                "Authorization":"Bearer __TOKEN__"  # Need to supply dynamic headers
            }
    
    agent = load_agent(agent_name="<AGENT_NAME>", headers=headers)
    response = agent.invoke({"<PLACE_HOLDER_NAME>": "<PLACE_HOLDER_VALUE>"})
    response["result"]