AI Agent Client

ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.delete_agent(agent_id: str, inventory_id: str)

Delete the AI agent based on the agent_id and inventory_id

Parameters:
  • agent_id (str) – The ID of the agent to be deleted.

  • inventory_id (str) – The ID of the inventory to which the agent contains.

Returns:

“AI agent Deleted Successfully”

Example:

from ibm_watsonx_gov.agent_catalog.clients import delete_agent
agent_id = '273d2b0c-dc04-407d-b3e8-2fdde790b1ed'
inventory_id = "81b1b891-0ded-46ca-bc3f-155e98a1xxx"
response = delete_agent(agent_id=agent_id, inventory_id=inventory_id)
response
ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.delete_agent_with_name(agent_name: str, inventory_id: str = None)

Method to delete the agent with agent_name

Parameters:
  • agent_name (str) – Name of the agent

  • inventory_id (str, Optional)

Example:

from ibm_watsonx_gov.agent_catalog.clients import delete_agent_with_name
response = delete_agent_with_name("banking_agent1")
response
ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.get_agent(agent_id: str, inventory_id: str)

Retrieves the details of a specific agent based on the given agent ID and inventory ID.

Parameters:
  • agent_id (str) – The ID of the agent to be retrieved.

  • inventory_id (str) – The ID of the inventory to fetch the agent from.

Returns:

The processed result from the agent get API.

Return type:

dict

Example:

from ibm_watsonx_gov.agent_catalog.clients import get_agent
agent_id = '273d2b0c-dc04-407d-b3e8-2fdde790b1ed'
inventory_id = "81b1b891-0ded-46ca-bc3f-155e98a1xxx"
get_response = get_agent(agent_id=agent_id, inventory_id=inventory_id)
get_response
ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.get_agent_by_name(agent_name: str, inventory_id: str = None)

Method to retrieve agent information based on the agent name within the current inventory ID.

Parameters:
  • agent_name (str) – Name of the agent

  • inventory_id (str, optional) – Inventory id

Returns:

Returns the agent details based on the agent name.

Return type:

dict

Example:

from ibm_watsonx_gov.agent_catalog.clients import get_agent_by_name
response = get_agent_by_name("banking_agent1")
response
ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.list_agents(service_provider_type: list[str] | str = None, category: list[str] | str = None, inventory_id: list[str] | str = None, framework: list[str] | str = None, agent_name: list[str] | str = None, search_text: list[str] | str = None)

Retrieves a list of registered AI agents based on the provided filter criteria.

All parameters are optional. If no filters are provided, all agents will be listed.

Parameters:
  • service_provider_type (Union[list[str], str], optional) – Filter agents by one or more service provider types.

  • category (Union[list[str], str], optional) – Filter agents by one or more categories.

  • inventory_id (Union[list[str], str], optional) – Filter agents by one or more inventory IDs.

  • framework (Union[list[str], str], optional) – Filter agents by one or more frameworks (e.g., “langchain”).

  • agent_name (Union[list[str], str], optional) – Filter agents by one or more agent names.

Returns:

A list of agents matching the filter criteria.

Return type:

list

Examples:

from ibm_watsonx_gov.agent_catalog.clients import list_agents
response = list_agents(agent_name=["banking_agent1"])
response
ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.register_agent(payload: dict | AgentRegistrationPayload)

Registers a new agent by converting the provided payload to an AgentRegistrationPayload instance. And then call the agent registration endpoint.

Parameters:
  • payload (Union[dict, AgentRegistrationPayload]) – The payload to register the agent.

  • AgentRegistrationPayload. (It can either be a dictionary or an instance of)

Returns:

The processed result from the agent registration API.

Return type:

dict

Examples:

Using AgentRegistrationPayload model:
from ibm_watsonx_gov.agent_catalog.clients import (
    AgentRegistrationPayload,
    register_agent,
)

post_payload = {
    "display_name": "banking agent",
    "agent_name": "banking_agent1",
    "description": "backing agent application",
    "endpoint": {
        "url": "http://localhost:8000/tools/add",
        "headers": {
            "Authorization": "Bearer dummy-token-12345",
            "Content-Type": "application/json",
        },
        "method": "POST"
    },
    "service_provider_type": "wml",
    "schema": {"properties": {"Query": {}}},
}
register_payload = AgentRegistrationPayload(**post_payload)
register_response = register_agent(payload=register_payload)
register_response
ibm_watsonx_gov.agent_catalog.clients.ai_agent_client.update_agent(agent_id: str, inventory_id: str, payloads: list[dict] | AgentUpdatePayload)

Patches the agent information based on the provided agent ID, inventory ID, and payloads.

Parameters:
  • agent_id (str) – The ID of the agent to be patched.

  • inventory_id (str) – The ID of the inventory to which the agent contains.

  • payloads (list[Union[dict, AgentUpdatePayload]]) – A list of dictionaries or AgentUpdatePayload instances containing the update information for the agent.

Returns:

The processed result from the agent patch API.

Return type:

dict

Notes

  • Each item in the payloads list should be either a dictionary or an instance of AgentUpdatePayload.

  • If a dictionary is provided, it is converted into an AgentUpdatePayload instance.

Examples:

Using AgentUpdatePayload model:
from ibm_watsonx_gov.agent_catalog.clients import AgentUpdatePayload, update_agent
agent_id = '273d2b0c-dc04-407d-b3e8-2fdde790b1ed'
inventory_id = "81b1b891-0ded-46ca-bc3f-155e98a15xxx"
patch_payload = [
    {"op": "replace", "path": "/reusable", "value": True},
    {"op": "replace", "path": "/metrics", "value": {"metric_id": "64"}},
]
update_agent_payload = AgentUpdatePayload(**{"payload": patch_payload})
update_response = update_agent(
    agent_id=agent_id,
    inventory_id=inventory_id,
    payloads=update_agent_payload,
)
update_response