Skip to content

Commit

Permalink
fix(docs): addressed feedback in docs (#779)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Croft <32483134+devjsc@users.noreply.github.com>
  • Loading branch information
FelixNicolaeBucsa and devjsc authored Jul 18, 2024
1 parent 264bec1 commit ccc70f5
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pages/guides/agents/advanced/register-in-almanac.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The [Almanac ↗️](/references/contracts/uagents-almanac/almanac-overview) con

## Walk-through

1. First of all, create a Python script and name it by running: `touch registration.py`
1. First of all, create a Python script and name it: `touch registration.py`

2. Then, import the `Agent` class from the `uagents` library to create our agent, and the `fund_agent_if_low` class from the `uagents.setup` module. This function will check if you have enough tokens to register in the Almanac contract, if not it will add testnet tokens to your `Fetch Network address`. Then, create an agent, `alice`, providing `name`, `port`, `seed`, and `endpoint`:

Expand Down
5 changes: 4 additions & 1 deletion pages/guides/agents/getting-started/create-a-uagent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

## Introduction

Once you've [installed ↗️](/guides/agents/installing-uagent) the uAgents library, it's quite simple to get a minimal use case running. Let our first agent be a simple initialisation and printing out the agent's name.
Once you've [installed ↗️](/guides/agents/installing-uagent) the uAgents library, it's quite simple to get a minimal use case running.

The uAgents Framework streamlines agent creation by offering tools for communication, discovery, and publication within the Fetch.ai network. It empowers users and developers with flexibility, allowing them to build agents using anything from cutting-edge Large Language Models (LLMs) to simple APIs.

Let our first agent be a simple initialisation and printing out the agent's name and address.
### The agent

1. Let's create a Python script for this task, and name it by running: `touch agent.py`
Expand Down
36 changes: 17 additions & 19 deletions pages/guides/agents/getting-started/getting-uagent-address.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Each agent within the Fetch ecosystem is characterized by different addresses. T

It is possible to distinguish between two different types of addresses:

- `uAgent address`: this is the main agent identifier. Other agents can use this address to query the agent's information in the Almanac contract.
- `uAgent address`: this address identifies the agent within the Fetch Network. It's similar to a username within a chat platform, allowing other agents to discover and communicate with that specific agent by querying that agent's information from the Almanac contract.

- `Fetch network address`: this is the address providing the agent with the capabilities for interacting with the [Fetch Ledger ↗️](/concepts/fetch-network/ledger/intro), including [Registration in the Almanac ↗️](/guides/agents/register-in-almanac) contract.
- `Fetch network address`: this address is linked to the agent's wallet on the Fetch.ai network. It is essential to perform multiple functionalities like holding cryptocurrency, interacting with the [Fetch Ledger ↗️](/concepts/fetch-network/ledger/intro) , but also performing secure transactions. This address is also essential to register an agent on the [Almanac ↗️](/concepts/fetch-network/almanac) contract to ensure the agents has enough funds available to perform operations in the network.

If you want to retrieve the address of your agent, you can either use the `print()` function and specify which of the above addresses you wish to print out, or by calling the `Context` class and related methods to retrieve specific information.
If you want to retrieve the address of an agent, you can either use the `print()` function and specify which of the above addresses you wish to print out, or by calling the `.address()` and `.wallet.address()` methods using the `agent` object to retrieve specific information.

**Let's now check how these ways of retrieving addresses look like!**

## Print uAgent address

You can print the `uAgent address` related to your agent in the following way:

1. First of all, create a Python script and name it by running: `touch uagent-address.py`
1. First of all, create a Python script and name it: `touch uagent-address.py`

2. We then need to import the `Agent` class from the `uagents` library to create an agent, `alice`. Then, using the `print` function, we will print the related `uAgent address`. Importantly, remember that the `seed` parameter is used, when creating an agent, to set fixed addresses, otherwise a random address will be generated every time you run the agent:
2. We then need to import the `Agent` class from the `uagents` library to create an agent, `alice`. Then, using the `print()` function, we will print the related `uAgent address`. Importantly, remember that the `seed` parameter is used, when creating an agent, to set fixed addresses, otherwise a random address will be generated every time you run the agent:

```py copy filename="uagent-address.py"
from uagents import Agent
Expand All @@ -38,16 +38,16 @@ You can print the `uAgent address` related to your agent in the following way:
The output would be as follows:

```
uAgent address: agent1qww3ju3h6kfcuqf54gkghvt2pqe8qp97a7nzm2vp8plfxflc0epzcjsv79t
uAgent address: agent1qww3ju3h6kfcuqf54gkghvt2pqe8qp97a7nzm2vp8plflc0epzcjsv79t
```

## Print Fetch network address

You can print the `Fetch network address` related to your agent in the following way:

1. Let's create a Python script, and name it by running: `touch fetch-address.py`
1. Let's create a Python script, and name it: `touch fetch-address.py`

2. As before, we first need to import the `Agent` class from the `uagents` library to create a uAgent, `alice`. Then, using the `print()` function, we will print the related `Fetch Network address`:
2. As before, we first need to import the `Agent` class from the `uagents` library to create an Agent, `alice`. Then, using the `print()` function, we will print the related `Fetch Network address`:

```py copy filename="fetch-address.py"
from uagents import Agent
Expand All @@ -70,29 +70,27 @@ The output would be as follows:

## Print agent name and address using `name` and `address` methods

In this guide, we aim at showing how to create an agent being able to say hello and printing its `name` and `address` retrieving such information from the `Context` class imported from the `uagents` library.
In this guide, we aim at showing how to create an agent being able to say hello and printing its `name` and `address` using the `uagents` library tools. Indeed, it is possible to retrieve the `name` and `address` of any agent directly from the `agent` object representing the agent you create and initialise. More specifically, we refer to the following methods:

The `Context` class is a crucial component which represents the execution context of an agent. It encapsulates different attributes and methods which allow an agent to interact with its environment, send and receive messages, and manage its state and identity. Within this class, we can distinguish multiple attributes and methods, including:
- `.name()`: this returns the provided name of the agent, if specified, otherwise, if the agent's name is not explicitly set, then it will use the first ten characters of the agent's address as its name.

- `name`: which returns the provided name of the agent, if specified, otherwise, if the agent's name is not explicitly set, then it will use the first ten characters of the agent's address as its name.
- `.address()`: this returns the unique address of the agent in the form `agent1...`. This address is essential for other agents to interact with your agent.

- `address`: which returns the unique address of the agent in the form `agent1...`. This address is essential for other agents to interact with your agent.

**Let's get started and use the `Context` class to make our agent print its name and address!**
**Let's get started and use the `agent` object to make our agent print its name and address!**

### Walk-through

1. First of all, you need to create a Python script and name it by running: `touch my_agent.py`
1. First of all, you need to create a Python script and name it: `touch my_agent.py`

2. We then need to import the necessary classes `Agent` and `Context` from the `uagents` library, and then create an instance of the `Agent` class, `alice`:
2. We then need to import the necessary classes `Agent` and `Context` from the `uagents` library, and then create an instance of the `Agent` class, `alice`. Below you can see the `agent` object being initialised:

```py copy
from uagents import Agent, Context

agent = Agent(name="alice", seed="alice recovery phrase")
```

3. We would then need to assign the agent the behavior to be executed. In this case, `agent` could send a message when it is being run saying hello and printing its `name` and `address`:
3. We would then need to assign the agent the behavior to be executed. In this case, `agent` could send a message when it is being run saying hello and printing its `name` and `address` using the `agent` object:

```py copy
@agent.on_event("startup")
Expand Down Expand Up @@ -124,9 +122,9 @@ if __name__ == "__main__":

### Run the script

On your terminal, make sure to have activated the virtual environment.
If you are using a Poetry virtual environment, make sure that you have activated it.

Run the script: `my_agent.py`
On your terminal, run the script: `python my_agent.py`

The output should be as follows:

Expand Down
8 changes: 4 additions & 4 deletions pages/guides/agents/getting-started/whats-an-agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The **uAgents Framework** is a lightweight library designed to facilitate the de

![](src/images/concepts/ai-agents/Agents_interacting.svg)

Agents are programs that can interact autonomously with other agents in a decentralized environment. These agents can operate in a decentralized manner, but their decentralization remains optional and dependent on individual preferences or needs.
Agents are autonomous software program built using the uAgents framework and that can interact autonomously with other agents in a decentralized environment. These agents can operate in a decentralized manner, but their decentralization remains optional and dependent on individual preferences or needs.

Intelligent agents can fundamentally change the way we see complicated systems. For example, supply chain management could deploy Agents using the uAgents Framework to improve operations at various stages. Demand forecasting, inventory control, logistics optimization, supplier relationships monitoring, quality control and risk mitigation in all areas can be done with their help. Agents could transform supply chain operations by increasing efficiency, reducing costs, improving accuracy and providing real-time visibility.

Expand All @@ -28,12 +28,12 @@ The financial industry is another example. In this scenario, the automation of t

In this context, Fetch.ai introduces the **uAgents Framework**. Using this open-source framework, developers are able to create intelligent, autonomous agents and join a decentralized network of many agents to effectively tackle the challenges of the modern world. Agents only perform tasks specified by the developers, and these tasks can be precisely described by coding customizable behavior for specific use cases and scenarios.

The concept of Agents stands for autonomous, decentralized systems that overcome conventional limitations.
Agents provide a gateway to a future where intelligent agents, empowered by the Fetch network and the [AI Engine ↗️](/concepts/ai-engine/ai-engine-intro), can communicate, negotiate and collaborate to streamline complex tasks, solve complicated problems and improve decision-making processes in various fields.
TThe concept of agents refers to autonomous, decentralized systems that overcome conventional limitations. Agents provide a gateway to a future where intelligent agents, empowered by the Fetch network and the [AI Engine ↗️](/concepts/ai-engine/ai-engine-intro), can communicate, negotiate and collaborate to streamline complex tasks, solve complicated problems and improve decision-making processes in various fields.

### Get started with Agents development!

Visit the [GitHub repository ↗️](https://github.com/fetchai/uAgents) if you need to verify any additional information on the aforementioned topics. This will keep you informed about any updates made to the uAgents Framework.
Visit the [GitHub repository ↗️](https://github.com/fetchai/uAgents) for more information on the aforementioned topics.
. This will also keep you up-to-date with any update made to the uAgents Framework.

To learn more about how to create and connect Agents technology, check out the resources and guides for the [Agentverse ↗️](/concepts/agent-services/agentverse-intro), [AI Engine ↗️](/concepts/ai-engine/ai-engine-intro), and [DeltaV ↗️](/concepts/deltav/intro)!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Let's start with **local communication**. This is the first step you would need

The first step to better understand how agents communicate is to introduce how 2 agents perform a local communication. Let's consider a basic example in which two agents say hello to each other.

1. First of all, let's create a Python script for this task and name it by running: `touch agents_communication.py`
1. First of all, let's create a Python script for this task and name it: `agents_communication.py`

2. Then, we import `Agent`, `Context`, `Bureau`, and `Model` from the uagents library and we then define the message structure for messages to be exchanged between the agents using the class `Model`:

Expand Down Expand Up @@ -144,17 +144,17 @@ The output would be:

To speak, search or be found, your agent must register to the [Almanac contract ↗️](/references/contracts/uagents-almanac/almanac-overview). Agents then query this to retrieve an HTTP endpoint for a recipient agent. [Registration in the Almanac ↗️](/guides/agents/register-in-almanac) requires paying a small fee, so make sure to have enough funds to allow for this. You can query the Almanac now, by using the search feature on [Agentverse ↗️](https://agentverse.ai/).

Whenever an agent registers in the Almanac, it must specify the service [endpoints ↗️](/references/contracts/uagents-almanac/endpoints) alongside a weight parameter for each endpoint provided. Agents trying to communicate with your agent, will choose the service endpoints using a weighted random selection.
Whenever an agent registers in the Almanac, it must specify the service [endpoints ↗️](/references/contracts/uagents-almanac/endpoints) alongside a weight parameter for each endpoint provided. Agents trying to communicate with your agent will choose the service endpoints using a weighted random selection.

Here, we show you how to create two agents and make them remotely communicate by registering and using the Almanac Contract.

### Walk-through

The first step would be to create two different Python scripts for this task, each one representing a remote agent:

Slaanesh: `touch remote_agents_slaanesh.py`
Slaanesh: `remote_agents_slaanesh.py`

Sigmar: `touch remote_agents_sigmar.py`
Sigmar: `remote_agents_sigmar.py`

Let's start by defining the script for **sigmar**.

Expand Down
4 changes: 2 additions & 2 deletions pages/guides/agents/intermediate/handlers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Sometimes an agent will need to perform a task periodically. To do this we can u

### Walk-through

1. Let's create a Python script for this task, and name it: `touch interval-task.py`
1. Let's create a Python script for this task, and name it: `interval-task.py`
2. Then import the necessary classes from `uagents` library, `Agent` and `Context`, and create our agent:

```py copy
Expand Down Expand Up @@ -91,7 +91,7 @@ We now showcase a scenario where three agents, named `alice`, `bob`, and `charle

### Walk-through

1. First of all, let's create a Python script for this task, and name it: `touch broadcast.py`
1. First of all, let's create a Python script for this task, and name it: `broadcast.py`

2. We then need to import the `Agent`, `Bureau`, `Context`, `Model`, and `Protocol` classes from the `uagents` library, and the `fund_agent_if_low` from `uagents.setup`. Then, let's create the 3 different agents using the class `Agent`. Each agent is initialized with a unique name and a seed phrase for wallet recovery. Additionally, if an agent's wallet balance is low, the `fund_agent_if_low()` function is called to add funds to their wallet:

Expand Down
2 changes: 1 addition & 1 deletion pages/guides/agents/intermediate/mailbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Let's start by creating a local agent named `alice`, alice responds hello to any
agent.run()
```

We now need to create a Mailbox for this agent and retrieve a Mailbox API key which should be then pasted within your local agent code by filling up the `AGENT_MAILBOX_KEY` field inline.
We now need to create a Mailbox for this agent and retrieve a Mailbox API key which should be then pasted within your local agent code by filling up the `AGENT_MAILBOX_KEY` field.

Run the above code in your terminal to retrieve your agent's address. You will need it in the next steps to set up an Agentverse Mailbox!
When running the above agent, you should get something similar within your terminal output:
Expand Down
2 changes: 1 addition & 1 deletion pages/guides/agents/intermediate/send-tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Let's get started!

## Walk-through

1. First of all, create a Python script for this task, and name it by running: `touch sending_tokens.py`
1. First of all, create a Python script for this task, and name it: `touch sending_tokens.py`
2. Then, import the necessary modules from `uagents`, `uagents.network`, and `uagents.setup`. Let's then define two data models: `PaymentRequest` and `TransactionInfo`. We then need to set up the values for the `AMOUNT` and `DENOM` variables, which define the default amount and denomination for the payment requests:

```py copy
Expand Down
2 changes: 1 addition & 1 deletion pages/guides/agents/intermediate/storage-function.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this guide, we want to illustrate how storage functions are called and how to

## Walk-through

1. First of all, let's create a Python script, and name it by running: `touch storage.py`.
1. To start let's create a Python script and name it `storage.py`, we can do this in terminal with `touch storage.py`.

2. Then, we need to open the script in the text editor of choice and import the necessary classes, `Agent` and `Context`, from the `uagents` library.

Expand Down

0 comments on commit ccc70f5

Please sign in to comment.