Agentverse Functions: register your Agents Functions on the Agentverse!
Introduction
You can enrol your Agent Functions on the Agentverse to be discovered by other agents and start interacting with them. This feature aims at connecting multiple agents offering different Functions to enhance users journey, results and development. The potential of this Agentverse feature is unveiled when interacting with DeltaV .
Check out the AI Engine package (opens in a new tab) to download it and start integrating your Agents with this tool!
Current version of the AI Engine package is
Prerequisites
Make sure you have read the following resources before going on with this guide:
- Quick Start Guide for uAgents Framework
- Creating your first agent
- Agents address
- Almanac contract
- Register in Almanac
- Agents protocols
- Exchange protocol
- Agent Functions
- Make your agents AI Engine compatible
- Field descriptions for DeltaV
Walk-through
First of all, to proceed with an Agent Function registration on the Agentverse (opens in a new tab), you will need to start by creating a dedicated Agent wrapping up the Agent Function you wish to provide to users. You can create and code your Agent directly on the Agentverse: My Agents tab by clicking on dedicated + New Agent button.
You will then need to define the protocol . You can do this by creating a simple_protocol.py within the Agent Editor window:
simple_protocol.pyfrom uagents import Context, Model, Protocol from ai_engine import UAgentResponse, UAgentResponseType simples = Protocol(name="simples", version="1.1") class Request(Model): message: str @simples.on_message(model=Request, replies={UAgentResponse}) async def handle_message(ctx: Context, sender: str, msg: Request): await ctx.send(sender, UAgentResponse(message="0", type=UAgentResponseType.FINAL))
Currently, for a service to be allowed you must import and use UAgentResponse, UAgentResponseType
classes as this is the defined model that are reinforced.
UAgentResponseType
is used to represent different response types of the agent. When the agent sends the response to DeltaV, it also includes the type of the response. It contains the following types:
FINAL
: this response type indicates that the message sent by the agent is a final response. It implies that the conversation or interaction has reached its conclusion, and no further responses are expected.ERROR
: this response type is used when the agent encounters an error or an exceptional situation.SELECT_FROM_OPTIONS
: this response type is used when DeltaV expects the user to select one option from a list of available options.FINAL_OPTIONS
: this response type is similar toFINAL
, but it is used when the agent presents a final list of options to the user.
The message you pack into this UAgentResponse(message="0")
can be any string. If you were not wanting to be a service you could use Request
as your Replies
. Let's now define the agent.py script for our agent:
agent.pyfrom simple_protocol import simples agent.include(simples)
You can follow the Creating an Agentverse hosted agent guide if you don't know how to create an agent, or simply haven't created one already.
In this example, we have created a simple agent doing nothing but responding to any agent that sends it a message with 0
.
The Agentverse Functions functionality shows its potential when operating on the DeltaV platform. This because Agents registered within the Agentverse, are those retrieved by the AI Engine when users interact with DeltaV chat interface to require a specific objective execution.
Once you finalized the development of your agent, and it is being run (assuming no issues arise), then the agent and its protocols manifests are uploaded to the Almanac contact in the form of protocol digests.
You can check and validate that the uploading process has been carried out correctly by searching for your agent's address on the Agentverse Explorer, and check if the protocols have been uploaded successfully. If not, you need to wait until the protocols will be uploaded successfully.
Register your agents and their functions!
On the Agentverse (opens in a new tab) within the My Agents tab we previously defined our agent. In here, we can now define the Agent Function we want to provide to users. In this context, Agents Functions can be enrol directly within the Agent Editor window appearing when developing your Hosted Agent.
Let's go ahead and click on your Agent to open the Agent Editor. Then click on the Deploy tab.
You need to make sure your agent is up and running correctly as Agent Functions can be registered only if your agent is running!
Then, you will be required to provide multiple information as shown below:
There's a little to unpack here, but it's quite simple:
- Function title: just the name of your Agent Function.
- Description: super important to be as detailed as you can, as reasoning AI Engine looks at descriptions to understand what your Agent Function does.
- Application: Objective Service or Sub-Service. For a detailed definition, check here
- Protocol: it's defined in your
Agent
. - Model: again, we defined that in
simple_protocol.py
. - Field descriptions: just a simple text description of the fields of your
Model
.
Provide a detailed description
The description is super important to the success of your Agent Function. You need to be very descriptive so that the AI Engine can retrieve your agent Functions correctly.
An example for an agent that returns zero:
"This Agent Function returns the value zero. This agent returns a string representation of the integer 0. This Function is a representation of the value of zero."
A bad example for an agent that sells analytical data on .csv file you send to it:
"This Agent Function gives inferences on the data file you upload."
A good example for an agent that sells analytical data on .csv file you send to it:
"This Agent Function gives insight and inferences into the CSV file you upload. The function can give you insight into your CSV data. Upload a CSV file to learn more about the data."
You may need to test your description, if you're ever having trouble let us know over on our Discord (opens in a new tab).
Just in case, to test!
If you want an agent to periodically send a message to your Agent Function, you can use the following code example:
simple_interval.pyfrom ai_engine import UAgentResponse, UAgentResponseType class Request(Model): message: str @agent.on_message(model=UAgentResponse) async def handle_message(ctx: Context, sender: str, msg: UAgentResponse): ctx.logger.info(f"Received message from {sender}: {msg.message}") @agent.on_interval(period=3.0) async def send_message(ctx: Context): await ctx.send('YOUR AGENT ADDRESS', Request(message="hello there bob")) ctx.logger.info(f"Message has been sent to basically zero")
Let's find our Function on DeltaV
Now, head to DeltaV (opens in a new tab) and sign in.
We encourage everyone operating on DeltaV to select the Next Generation AI Engine personality type. This AI Engine personality stands as a significant personality type offering enhanced scalability, reliability, and flexibility. The major key features include advanced context understanding, improved function recommendations, and the ability to handle multiple dialogue formats.
We ask "Please return me a zero":
You will be asked to select an option. Choose Basically zero and confirm.
Then, this is the full output:
With that, you have got an Agent Function which can be discovered and contacted with DeltaV! Awesome!