Skip to content

Commit

Permalink
fix: conflicts solved
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNicolaeBucsa committed Jul 18, 2024
2 parents 7f346d3 + 264bec1 commit 425a5ca
Show file tree
Hide file tree
Showing 16 changed files with 304 additions and 62 deletions.
6 changes: 3 additions & 3 deletions components/landing-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ function LandingPage() {
const startingGuides = [
{
label: "Building your first agent",
path: "/guides/agents/installing-uagent",
path: "/guides/agents/quickstart",
image: buildYourAgent,
},
{
label: "Creating an executable function for AI",
path: "guides/agents/communicating-with-other-agents",
path: "/guides/agents/intermediate/agent-functions",
image: executable,
},
{
label: "The Fetch.ai technology stack",
path: "/guides/agentverse/creating-a-hosted-agent",
path: "/concepts/introducing-fetchai",
image: techStack,
},
];
Expand Down
16 changes: 13 additions & 3 deletions pages/apis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,27 @@ import { GuideBox } from "../components/feature-guide-tabs";
<Row>
<GuideBox
content={{
title: "DELTA-V Chat API",
title: "DELTA-V Chat APIs",
description: "Start working with DeltaV chat APIs.",
path: "/apis/ai-engine/chat"
}}
/>

<GuideBox
content={{
title: "DeltaV Functions API",
title: "DeltaV Functions APIs",
description: "Start working with Functions APIs.",
path: "/apis/ai-engine/services"
path: "/apis/ai-engine/functions"
}}
/>

</Row>
<Row>
<GuideBox
content={{
title: "DELTA-V Function Groups APIs",
description: "Explore DeltaV Function Groups APIs.",
path: "/apis/ai-engine/function_groups"
}}
/>

Expand Down
3 changes: 2 additions & 1 deletion pages/apis/ai-engine/function_groups.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
# DeltaV Function Groups API

<div className="nx-text-fetch-content">
Most of the endpoints depends on various instances and are considered parameters for the actual endpoint, but these are not meant to be passed directly by the user.

Most of the endpoints depends on various instances and are considered parameters for the actual endpoint, but these are not meant to be passed directly by the user.

Instead, these instance-dependent elements are integrated and managed directly by the backend system. We refer to them as `*name_parameter`, where the asterisk (\*) is used to denote a specific instance-dependent parameter that the route relies on.

Expand Down
4 changes: 2 additions & 2 deletions pages/concepts/introducing-fetchai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The **Agentverse** is a Software as a Service (SaaS) platform built primarily fo

The Agentverse provides multiple use cases ranging from simple "Hello World" to AI-driven recommendation systems. These use cases are only a click away from being edited, tweaked, and deployed for yourself.

You can post your agent(s) as a function on Agentverse so that the AI Engine can quickly find them and promote them to other users or agents via DeltaV.
You can post your agent(s) and their functions on Agentverse so that the AI Engine can quickly find them and promote them to other users or agents via DeltaV.

### DeltaV and the AI Engine: enabling user interactions

Expand All @@ -44,7 +44,7 @@ The **Fetch Name Service** works as a decentralized naming system which simplifi

The backbone of Fetch.ai decentralized infrastructure is represented by the **Fetch ledger**. It acts as a secure and immutable record-keeping system and provides a transparent record of transactions, fostering trust and reliability across the network. The Fetch ledger supports the decentralized economy, ensuring secure data sharing and transactional integrity.

The overall system we depicted runs on a specific fuel: **FET tokens**. These tokens hold intrinsic value and utility, drive transactions, promote active participation, and empower various decentralized services within the Fetch network. FET serves as a medium of exchange and facilitates interactions among users, Agents, and services within the Fetch ecosystem.
The overall system we depicted runs on a specific fuel: **FET tokens**. These tokens hold intrinsic value and utility, drive transactions, promote active participation, and empower various decentralized services within the Fetch network. FET serves as a medium of exchange and facilitates interactions among users, Agents, and Functions within the Fetch ecosystem.

### Next steps

Expand Down
99 changes: 78 additions & 21 deletions pages/examples/intermediate/agents-cleaning-demo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,38 @@ This example shows how to set up a cleaning service using Agents ann uAgents lib
### Supporting documentation

- [Creating an agent ↗️](/guides/agents/create-a-uagent)

- [Creating an interval task ↗️](/guides/agents/interval-task)
- [Communicating with other agents ↗️](/guides/agents/communicating-with-other-agents)
- [Register in Almanac ↗️](/guides/agents/register-in-almanac)

- [Almanac Contract ↗️](/references/contracts/uagents-almanac/almanac-overview)

- [Protocols ↗️](/references/uagents/uagents-protocols/agent-protocols)
- [Agents address ↗️](/guides/agents/getting-started/getting-uagent-address)

### The Protocols
#### __init__.py

This protocol acts as a bridge cleaning service providers and users requesting cleaning services.

The protocol defines the format for messages exchanged between the two parties. Users send `ServiceRequest` messages specifying details about their desired cleaning service, including location, time, duration, types of services needed, and their maximum budget. Providers respond with `ServiceResponse` messages indicating whether they can accept the request and, if so, their proposed price. Once a user confirms the booking with a `ServiceBooking` message containing all the agreed-upon details and price, the provider sends a `BookingResponse` message to confirm success or failure.

The protocol ensures the provider's services are available to the user's location. It uses the `geopy` library to calculate the distance between the user and the provider. Additionally, it verifies if the requested cleaning services are offered by the provider and if the desired cleaning time falls within the provider's pre-defined availability schedule. Finally, it compares the user's budget with the provider's minimum hourly price multiplied by the cleaning duration to ensure affordability.

### The agents
#### The Protocol
Here is the full code:

```py copy filename="__init__.py"
from datetime import datetime, timedelta
from typing import List

from geopy.geocoders import Nominatim
from geopy.distance import geodesic

from geopy.geocoders import Nominatim
from uagents import Context, Model, Protocol
from .models import Provider, Availability, User

from .models import Availability, Provider, User

PROTOCOL_NAME = "cleaning"
PROTOCOL_VERSION = "0.1.0"


class ServiceRequest(Model):
user: str
location: str
Expand Down Expand Up @@ -131,19 +140,69 @@ async def handle_book_request(ctx: Context, sender: str, msg: ServiceBooking):
await ctx.send(sender, BookingResponse(success=success))
```

#### models.py

We now need to define the data structure for the cleaning service application. We account for the following `Models`:

* `ServiceTypes`: to represent different cleaning services (floor, window, laundry, etc.).
* `Users`: for information like name, address, and creation time.
* `Service`: for cleaning service type offered.
* `Provider`: for details like name, location, creation time, and links to their availability and offered services.
* `Availability`: so to define the provider's service schedule, including maximum service distance, start and end times, and minimum hourly price.

Here is the full code:

```py copy filename="models.py"
from enum import IntEnum

from tortoise import fields, models

class ServiceType(IntEnum):
FLOOR = 1
WINDOW = 2
LAUNDRY = 3
IRON = 4
BATHROOM = 5

class User(models.Model):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=64)
address = fields.CharField(max_length=100)
created_at = fields.DatetimeField(auto_now_add=True)

class Service(models.Model):
id = fields.IntField(pk=True)
type = fields.IntEnumField(ServiceType)

class Provider(models.Model):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=64)
location = fields.CharField(max_length=64)
created_at = fields.DatetimeField(auto_now_add=True)
availability = fields.ReverseRelation["Availability"]
services = fields.ManyToManyField("models.Service")
markup = fields.FloatField(default=1.1)

class Availability(models.Model):
id = fields.IntField(pk=True)
provider = fields.OneToOneField("models.Provider", related_name="availability")
max_distance = fields.IntField(default=10)
time_start = fields.DatetimeField()
time_end = fields.DatetimeField()
min_hourly_price = fields.FloatField(default=0.0)
```

### Agents
#### The Cleaner Agent

```py copy filename="cleaner.py"
from datetime import datetime
from pytz import utc

from tortoise import Tortoise

from protocols.cleaning import cleaning_proto
from protocols.cleaning.models import Availability, Provider, Service, ServiceType

from pytz import utc
from tortoise import Tortoise
from uagents import Agent, Context
from uagents.setup import fund_agent_if_low

cleaner = Agent(
name="cleaner",
Expand All @@ -154,8 +213,6 @@ cleaner = Agent(
},
)

fund_agent_if_low(cleaner.wallet.address())

# build the cleaning service agent from the cleaning protocol
cleaner.include(cleaning_proto)

Expand Down Expand Up @@ -192,23 +249,24 @@ if __name__ == "__main__":
cleaner.run()
```

#### The User Agent
#### User

```py copy filename="user.py"
from datetime import datetime, timedelta
from pytz import utc

from protocols.cleaning import (
ServiceBooking,
BookingResponse,
ServiceBooking,
ServiceRequest,
ServiceResponse,
)
from protocols.cleaning.models import ServiceType
from pytz import utc
from uagents import Agent, Context
from uagents.setup import fund_agent_if_low

CLEANER_ADDRESS = "agent1qdfdx6952trs028fxyug7elgcktam9f896ays6u9art4uaf75hwy2j9m87w"
CLEANER_ADDRESS = (
"test-agent://agent1qdfdx6952trs028fxyug7elgcktam9f896ays6u9art4uaf75hwy2j9m87w"
)

user = Agent(
name="user",
Expand All @@ -219,7 +277,6 @@ user = Agent(
},
)

fund_agent_if_low(user.wallet.address())

request = ServiceRequest(
user=user.name,
Expand Down
Loading

0 comments on commit 425a5ca

Please sign in to comment.