Skip to content

Commit

Permalink
fix(docs): registering a service guide (#231)
Browse files Browse the repository at this point in the history
Co-authored-by: josh <[email protected]>
  • Loading branch information
devjsc and josh authored Oct 24, 2023
1 parent c11241b commit 4ce244d
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 13 deletions.
101 changes: 88 additions & 13 deletions pages/guides/agentverse/registering-agent-services.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,105 @@ import { Callout } from 'nextra/components'

# Agentverse services

In the [Agentverse Services ↗️](https://agentverse.ai/services) section, you will be able to enrol your agent in the system so as to be discovered by other agents and start interacting with them. The services sections aims at connecting multiple agents offering different services so to enhance users journey, results and development.
In the [Agentverse Services ↗️](https://agentverse.ai/services) section, you will be able to enrol your agent in the system so as to be discovered by other agents and start interacting with them.
The services sections aims at connecting multiple agents offering different services so to enhance users journey, results and development.

To start, let's build a simple agent to register as a service:

We define the protocol:

```py copy filename="simple_protocol.py"
from uagents import Context, Model, Protocol
from ai_engine import UAgentResponse, UAgentResponseType

simples = Protocol(name="simples", version="v1.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` as this is the defined model that are renforced. 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`

```py copy filename="agent.py"
from simple_protocol import simples

agent.include(simples)
```
You can follow the guide in [Creating a hosted agent ↗][/guides/agentverse/creating-a-hosted-agent] if you don't know how to, or haven't created an agent already.

This is a simple example of an agent, it does nothing but respond to any agent that sends it a message with `0`.

<Callout type="info" emoji="ℹ️">
Services are a way to package your agent's capabilities into marketable entities!
</Callout>

## Register your agents and services!

Whenever you wish to enrol an agent and the service provided into the Agentverse Services, you will need to click on the **+ New Service** button and provide different information for your service to be successfully registered, including:
First, you'll see a page like this:

![](../../../src/images/guides/agentverse/click_new_service.png)

- Service title.
- Agent address.
- Service description.
- Service group.
Let's go ahead and click this + New Service, we filled the form out as follows:

![](../../../src/images/guides/agentverse/create_service_filled.png)

There's a little to unpack here; but it's quite simple;

- Service title - just the name of your service
- Description - It's important to have a description of your agents, so that others know what they do!
- Service group - the group the agent belongs to
- Agent - Select which of your agents is a service
- Task type (task or subtask).
- 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.

By providing the information above, we can get your agent address and name and set up a dedicated mailbox for it to receive messages.
You may need to go ahead and create a service group:

<Callout type="info" emoji="ℹ️">
You can use the **Agentverse Service Groups** section or tab if you wish to add your service into a group which then offers several services to other users or agents. You will need to specify if the your new service group is **Private**, **Public**, or **Open**.
</Callout>
![](../../../src/images/guides/agentverse/service_group.png)

Services Groups are a way to package your service into a group which then offers several services to users or agents.

If you want an agent to periodically send a message to your service; you can use:

```python copy filename="simple_interval.py"

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 basicaly zero")
````

## Let's find our service on DeltaV

Head to [DeltaV ↗️](https://deltav.agentverse.ai/) and sign in.



You'll be asked to select a Service Group; we selected `Helpers` as that's the one we created for this guide.

![](../../../src/images/guides/agentverse/deltav_service_select.png)

Then, we ask "Please return me a zero"

![](../../../src/images/guides/agentverse/deltav_simple_start.png)

## Register agents offering targeted services!
Then, this is the full output:

The description provides an overview of what the agent does effectively alongside the service category for that particular agent (e.g., hotels, flights, taxi, entertainment, and so on). This way, we give the agent an additional degree of control over the metadata handled and thus to be discovered by other agents interested in creating an interaction with it.
![](../../../src/images/guides/agentverse/deltav_full_zero.png)

For instance, imagine you have created an agent supporting a taxi protocol and that you wish to enrol it in the Agentverse Services section so for it to be discovered easily by any other agent available and looking for taxi services. When you enrol such an agent, you will need to provide a description for the service offered, such as, best taxis in the central London area. This way, we specify that our agent is specialised in taxi services focusing around the central London area. On the other hand, there may be other agents offering taxi services which were enrolled in the Services section but provide a different description of services offered, for instance, best taxis in the London area. This way, such agents will be found by any other agent interested in taxi services operating outside the central London area.
With that, you've got a service which can be discovered and contacted with DeltaV. Awesome.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/guides/agentverse/create_service.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/guides/agentverse/service_group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4ce244d

Please sign in to comment.