ai_query_api
AIQueryApi
Represents the AI Query API.
Args:
opts
(BackendApiOptions): The backend API optionsMethods:
create_task
: Creates a task for an agent to executecreate_steps
: Creates steps for a taskupdate_step
: Updates a stepsearch_tasks
: Searches for tasksget_task_with_steps
: Gets a task with its stepsget_steps_from_task
: Gets the steps from a taskget_steps
: Gets the stepsget_tasks_from_agents
: Gets the tasks from the agentssearch_step
: Searches for stepsget_step
: Gets the details of a step__init__
__init__(opts: BackendApiOptions)
create_steps
create_steps(did: str, task_id: str, steps: List[Step])
It creates the step/s required to complete an AI Task. This method is used by the AI Agent to create the steps required to complete the AI Task.
Args:
did
(str): The DID of the service.task_id
(str): The task ID.steps
(List[Step]): The steps to create.create_task
create_task(did: str, task: Task, _callback: Optional[Any] = None)
Subscribers can create an AI Task for an Agent. The task must contain the input query that will be used by the AI Agent. This method is used by subscribers of a Payment Plan required to access a specific AI Agent or Service. Users who are not subscribers won’t be able to create AI Tasks for that Agent. Because only subscribers can create AI Tasks, the method requires the access token to interact with the AI Agent/Service. This is given using the queryOpts
object (accessToken attribute).
Args:
did
(str): The DID of the service.task
(Task): The task to create._callback
(Any): The callback to execute when a new task log event is received (optional)Example: task = { “query”: “https://www.youtube.com/watch?v=0tZFQs7qBfQ”, “name”: “transcribe”, “additional_params”: [], “artifacts”: [] } task = subscriber.ai_protocol.create_task(agent.did, task) print(‘Task created:’, task.json())
get_step
get_step(step_id: str)
Get the details of a step.
Args:
did
(str): The DID of the service.task_id
(str): The task ID.step_id
(str): The step ID.get_steps
get_steps(
status: AgentExecutionStatus = <AgentExecutionStatus.Pending: 'Pending'>,
dids: List[str] = []
)
It retrieves all the steps that the agent needs to execute to complete the different tasks assigned. This method is used by the AI Agent to retrieve information about the steps part of tasks created by users to the agents owned by the user.
Args:
status
(AgentExecutionStatus): The status of the steps.dids
(List[str]): The list of DIDs.get_steps_from_task
get_steps_from_task(did: str, task_id: str, status: Optional[str] = None)
It retrieves all the steps that the agent needs to execute to complete a specific task associated to the user. This method is used by the AI Agent to retrieve information about the tasks created by users to the agents owned by the user.
Args:
did
(str): The DID of the service.task_id
(str): The task ID.status
(Optional[str]): The status of the steps.get_task_with_steps
get_task_with_steps(did: str, task_id: str)
It returns the full task and the steps resulted of the execution of the task.
This method is used by subscribers of a Payment Plan required to access a specific AI Agent or Service. Users who are not subscribers won’t be able to create AI Tasks for that Agent.
Args:
did
(str): The DID of the service.task_id
(str): The task ID.get_tasks_from_agents
get_tasks_from_agents()
It retrieves all the tasks that the agent needs to execute to complete the different tasks assigned. This method is used by the AI Agent to retrieve information about the tasks created by users to the agents owned by the user
log_task
log_task(task_log: TaskLog)
It send a log message with the status of a task and a message with relevant information for the subscriber. This method is used by AI agents to log messages.
Args:
task_log
(TaskLog): An instance containing log details.search_step
search_step(search_params: Any)
It search steps based on the search parameters. The steps belongs to the tasks part of the AI Agents owned by the user. This method is used by the AI Agent to retrieve information about the steps part of tasks created by users to the agents owned by the user.
Args:
search_params
(Any): The search parameters.search_tasks
search_tasks(search_params: Any)
It searches tasks based on the search parameters associated to the user.
Args:
search_params
(Any): The search parameters.subscribe
subscribe(
callback: Any,
join_account_room: bool = True,
join_agent_rooms: Optional[str, List[str]] = None,
subscribe_event_types: Optional[List[str]] = None,
get_pending_events_on_subscribe: bool = True
)
It subscribes to the Nevermined network to retrieve new AI Tasks requested by other users. This method is used by AI agents to subscribe and receive new AI Tasks sent by other subscribers.
Args:
callback
(Any): The callback function to be called when a new event is received.join_account_room
(bool): If True, it will join the account room.join_agent_rooms
(Optional[Union[str, List[str]]]): The agent rooms to join.subscribe_event_types
(Optional[List[str]]): The event types to subscribe to.get_pending_events_on_subscribe
(bool): If True, it will get the pending events on subscribe.subscribe_tasks_updated
subscribe_tasks_updated(callback: Any, tasks: List[str])
update_step
update_step(did: str, task_id: str, step_id: str, step: Step)
It updates the step with the new information. This method is used by the AI Agent to update the status and output of an step. This method can not be called by a subscriber.
Args:
did
(str): The DID of the service.task_id
(str): The task ID.step_id
(str): The step ID.step
(Step): The step object to update. https://docs.nevermined.io/docs/protocol/query-protocol#steps-attributesThis file was automatically generated via lazydocs.