Skip to content

Commit

Permalink
fix(docs): shortening content in Bureau guide (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNicolaeBucsa authored Dec 20, 2024
1 parent 5ae5f47 commit 5944486
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pages/guides/agents/intermediate/bureau.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Make sure you have read the following resources before going on with this guide:
- [Quick Start Guide for uAgents Framework ↗️](/guides/agents/quickstart)
- [Creating your first agent ↗️](/guides/agents/getting-started/create-a-uagent)
- [Agents address ↗️](/guides/agents/getting-started/getting-uagent-address)
- [Agent Handlers ↗️](/guides/agents/intermediate/handlers)
- [Almanac contract ↗️](/concepts/fetch-network/almanac)
- [Register in Almanac ↗️](/guides/agents/register-in-almanac)

Expand All @@ -24,11 +25,11 @@ Make sure you have read the following resources before going on with this guide:

## Walk-through

This walk-through will guide you through the process of setting up and running agents using the Bureau, demonstrating its key functionalities, including agent management, message handling, and external communication via endpoints.
This walk-through will guide you through the process of setting up and running Agents using the Bureau, demonstrating its key functionalities, including agent management, message handling, and external communication via endpoints.

### Step 1: Setting Up Agents

To begin, you need to create and define your agents. Each agent will have specific tasks and behaviors that can be scheduled or triggered by messages.
To begin, you need to create and define your Agents. Each Agent will have specific tasks and behaviors that can be scheduled or triggered by messages.

```py copy filename="agent-bureau.py"

Expand All @@ -44,7 +45,7 @@ agent_b = Agent(name="agent_b", seed="agent_b recovery phrase")

### Step 2: Defining Agent Behavior

Next, define the behavior of each agent, such as sending and receiving messages. This is done using decorators like on_interval to perform scheduled tasks and on_message to respond to incoming messages.
Next, define the behavior of each Agent, such as sending and receiving messages. This is done using decorators like `on_interval` to perform scheduled tasks and `on_message` to respond to incoming messages. Check out the [Agent Handlers ↗️](/guides/agents/intermediate/handlers) for additional information on Agent Handlers and their usage.

```py copy filename="agent-bureau.py"

Expand All @@ -67,21 +68,21 @@ async def agent_b_message_handler(ctx: Context, sender: str, msg: Message):

### Step 3: Creating the Bureau

Once the agents are set up, you can create a Bureau instance to manage them. The Bureau is responsible for running the agents, handling communication, and orchestrating tasks.
Once the Agents are set up, you can create a Bureau instance to manage them. The Bureau is responsible for running the Agents, handling communication, and orchestrating tasks.

#### Arguments the Bureau Takes:

The Bureau can be customized through a few important arguments when instantiated:

- `agents` (Optional[List[Agent]]): A list of agents to be managed by the Bureau. If you don't add agents during initialization, you can always add them later using the `add()` method.
- `agents` (Optional[List[Agent]]): A list of Agents to be managed by the Bureau. If you don't add Agents during initialization, you can always add them later using the `add()` method.

- `port` (Optional[int]): The port number on which the Bureau's ASGI server will run. This is crucial if your agents need to expose REST APIs for external communication. The default port is `8000`, but you can specify any available port.
- `port` (Optional[int]): The port number on which the Bureau's ASGI server will run. This is crucial if your Agents need to expose REST APIs for external communication. The default port is `8000`, but you can specify any available port.

- `endpoint` (Optional[Union[str, List[str], Dict[str, dict]]]): Configuration for the agent endpoints. You can specify how agents communicate with external systems via REST. This could be a string, a list of strings, or a dictionary defining more complex configurations. If you want agents external to the bureau to be able to communicate with the agents within the Bureau this must be defined.
- `endpoint` (Optional[Union[str, List[str], Dict[str, dict]]]): Configuration for the Agent endpoints. You can specify how Agents communicate with external systems via REST. This could be a string, a list of strings, or a dictionary defining more complex configurations. If you want Agents external to the bureau to be able to communicate with the Agents within the Bureau this must be defined.

- `loop` (Optional[asyncio.AbstractEventLoop]): The event loop that the Bureau will use to manage asynchronous tasks. By default, the Bureau creates an event loop if one is not provided.
- `loop` (Optional[asyncio.AbstractEventLoop]): The event loop used for managing asynchronous tasks. The Bureau creates one by default if none is provided.

- `log_level` (Optional[Union[int, str]]): The logging level for the Bureau. This allows you to control how much information is logged during the Bureau’s execution, using levels like `INFO`, `DEBUG`, or `ERROR`.
- `log_level` (Optional[Union[int, str]]): Sets the logging level, such as `INFO`, `DEBUG`, or `ERROR` to control the verbosity of execution logs.

```py
from uagents import Bureau
Expand All @@ -99,7 +100,7 @@ bureau.add(agent_b)

### Step 4: Running the Bureau

After adding your agents, it's time to run the Bureau. The Bureau will ensure that the agents communicate seamlessly and handle tasks like message delivery and API management if necessary.
After adding your Agents, it's time to run the Bureau. The Bureau will ensure that the Agents communicate seamlessly and handle tasks like message delivery and API management if necessary.

```py copy

Expand All @@ -110,7 +111,9 @@ if __name__ == "__main__":

Step 5: Message Handling and Communication

In this setup, `agent_a` sends a message to `agent_b` every 3 seconds. When `agent_b` receives the message, it replies back to `agent_a`. The Bureau handles the coordination and message passing between the agents. You’ll see logs indicating the messages sent and received by each agent.
In this setup, `agent_a` sends a message to `agent_b` every 3 seconds. When `agent_b` receives the message, it replies to `agent_a`.

The Bureau handles the coordination and message passing between the Agents. You'll see logs indicating the messages sent and received by each Agent.

The overall script for this example should look as follows:

Expand Down Expand Up @@ -168,4 +171,4 @@ The output would be:
INFO: [agent_b]: Received message from agent1q2n33nmfscfscnz49a9e6nj4054d7r46v7x7522g4zh798tcwgs5q855p6q: Hello from agent_a
INFO: [agent_a]: Received message from agent1q07ypwau2gv0y005m0ltycx7vpt3hpajsvvnltpu50wpgk87zzkmwc005ga: Reply from agent_b
```
```

0 comments on commit 5944486

Please sign in to comment.