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 âī¸.
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:
from 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:
from 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.
This way the integration between the Agentverse Services functionality and DeltaV spreads adoption of Agent Functions to a greater plethora of users. Checkout the Assemble any Function with DeltaV âī¸ guide for additional information on possible queries available via DeltaV.
Once you finalised 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: Primary or Secondary Function. 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:
from 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 service on DeltaV
Now, head to DeltaV âī¸ (opens in a new tab) and sign in.
We ask "Please return me a zero":
You will be asked to select a function. 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!
For additional examples on how to register an Agent Function on the Agentverse and subsequently DeltaV, have a look at the other guides we have prepared for you: register a coin toss agent as a Function đĒ âī¸ and register a dice roll agent as a Function đ˛ âī¸.
You can also check our dedicated guide âī¸ helping you to create a locally run Agent with an Agent Function, which is then registered on the Agentverse and then retrievable on DeltaV!