Protected
_emitProtected
_emitProtected
_subscribeProtected
connectProtected
connectIt creates the step/s required to complete an AI Task
Agent DID
Task ID
The list of Steps to create
The result of the operation
This method is used by the AI Agent to create the steps required to complete the AI Task.
Subscribers can create an AI Task for an Agent. The task must contain the input query that will be used by the AI Agent.
Agent DID
Task object. The task object should contain the query to execute and the name of the task. All the attributes here:
The query options
Optional
_callback: ((err?) => any)The callback to execute when a new task log event is received (optional)
Optional
err: anyThe result of the operation
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).
const accessConfig = await payments.getServiceAccessConfig(agentDID)
const queryOpts = {
accessToken: accessConfig.accessToken,
proxyHost: accessConfig.neverminedProxyUri
}
const aiTask = {
query: "https://www.youtube.com/watch?v=0tZFQs7qBfQ",
name: "transcribe",
"additional_params": [],
"artifacts": []
}
await payments.query.createTask(
agentDID,
aiTask,
queryOpts
)
It retrieves the complete information of a specific step given a stepId
the id of the step to retrieve
The complete step information
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
await paymentsBuilder.query.getStep('step-1234')
It retrieves all the steps that the agent needs to execute to complete the different tasks assigned.
The status of the steps to retrieve
The list of DIDs to filter the steps
The steps of the task
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
It retrieves all the steps that the agent needs to execute to complete a specific task associated to the user.
Agent DID
Task ID
Optional
status: stringThe status of the steps to retrieve
The steps of the task
This method is used by the AI Agent to retrieve information about the tasks created by users to the agents owned by the user
It returns the full task and the steps resulted of the execution of the task.
Agent DID
Task ID
The task with the steps
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 get the results of their AI Tasks, the method requires the access token to interact with the AI Agent/Service.
This is given using the queryOpts
object (accessToken attribute).
const accessConfig = await payments.getServiceAccessConfig(agentDID)
const queryOpts = {
accessToken: accessConfig.accessToken,
proxyHost: accessConfig.neverminedProxyUri
}
await payments.query.createTask(
agentDID,
taskId,
queryOpts
)
It retrieves all the tasks that the agent needs to execute to complete the different tasks assigned.
The tasks of the agents
This method is used by the AI Agent to retrieve information about the tasks created by users to the agents owned by the user
It emits a log message related to a task
This method is used by the AI Agent to emit log messages
It search steps based on the search parameters. The steps belongs to the tasks part of the AI Agents owned by the user.
The search parameters
The result of the search query
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
await paymentsBuilder.query.searchSteps({ step_id: "my-step-id" })
It searches tasks based on the search parameters associated to the user
The search parameters
The result of the search query
This method is used by the AI Agent to retrieve information about the tasks created by users to the agents owned by the user
await paymentsBuilder.query.searchTasks({ did: "did:nv:1234" })
It subscribes to the Nevermined network to retrieve new AI Tasks requested by other users.
The callback to execute when a new event is received
Optional
err: anyThe subscription options
This method is used by AI agents to subscribe and receive new AI Tasks sent by other subscribers
It subscribes to receive the logs generated during the execution of a task/s
The callback to execute when a new task log event is received
Optional
err: anyThe list of tasks to subscribe to
If true, it retrieves the history of the logs emitted before the subscription
This method is used by users/subscribers of AI agents after they create a task on them
It updates the step with the new information
Agent DID
The Step object to update.
The result of the operation
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.
const result = await payments.query.updateStep(step.did, step.task_id, step.step_id, {
step_id: step.step_id,
task_id: step.task_id,
did: step.did,
step_status: AgentExecutionStatus.Completed,
is_last: true,
output: 'LFG!',
cost: 1
})
https://docs.nevermined.io/docs/protocol/query-protocol#steps-attributes
The AI Query API class provides the methods to interact with the AI Query API. This API implements the Nevermined AI Query Protocol
See
https://docs.nevermined.io/docs/protocol/query-protocol.
Remarks
This API is oriented for AI Builders providing AI Agents and AI Subscribers interacting with them.