diff --git a/components/code.tsx b/components/code.tsx index 7d5d607d..e1ac7fc8 100644 --- a/components/code.tsx +++ b/components/code.tsx @@ -17,7 +17,7 @@ interface CodeBlockProps { } type CodeBoxProps = { - filename?: string; + filename?: string[]; dataLanguage?: string; hasCopyCode?: boolean; children?: React.ReactNode; @@ -263,11 +263,14 @@ export const CustomPre: React.FC = ({ children, isLocalHostedFile, isOSFile, + filename, }) => { const [isCopied, setIsCopied] = useState(false); const codeRef = useRef(null); - const [selectedType, setSelectedType] = useState(agentType[0].name); + const [selectedType, setSelectedType] = useState( + filename[0].includes("local") ? agentType[0].name : agentType[1].name, + ); const [selectedOS, setSelectedOS] = useState("windows"); const renderChild = () => { @@ -279,6 +282,14 @@ export const CustomPre: React.FC = ({ }); }; + const filteredAgentType = + isLocalHostedFile && filename.length == 2 + ? agentType + : agentType.filter( + (type) => + type.label === (filename[0].includes("local") ? "local" : "hosted"), + ); + const matchFilename = (filename: string): boolean => { const regexMap = { self_hosted: /local/i, @@ -319,7 +330,7 @@ export const CustomPre: React.FC = ({ selectedOption={selectedType} onOptionSelect={setSelectedType} placeholder="Select Language" - options={agentType.map((item) => item.name)} + options={filteredAgentType.map((item) => item.name)} /> )} {isOSFile && ( @@ -476,12 +487,22 @@ export const CodeGroup: React.FC = ({ isLocalHostedFile, hasCopy, }) => { + const renderFileName = () => { + return React.Children.map(children, (child) => { + if (React.isValidElement(child)) { + return child.props.filename; + } + return null; + }); + }; + const filename = renderFileName(); return (
{children} diff --git a/pages/examples/advanced/async-loops.mdx b/pages/examples/advanced/async-loops.mdx index 42d51e5d..52fbae01 100644 --- a/pages/examples/advanced/async-loops.mdx +++ b/pages/examples/advanced/async-loops.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code"; + # Agent Asynchronous Loops ## Introduction @@ -15,7 +17,9 @@ In this example, we demonstrate how to use agents to communicate and exchange st #### Script 1 - ```py copy filename="external_loop_attach.py" + + + ```py copy filename="local-external_loop_attach.py" import asyncio import contextlib @@ -63,12 +67,14 @@ In this example, we demonstrate how to use agents to communicate and exchange st with contextlib.suppress(KeyboardInterrupt): loop.run_forever() ``` - + This script demonstrates how to run an agent using an external event loop. For this example to run correctly, remember to provide a `seed` phrase to the agent. It initializes an agent and attaches it to a loop where it performs continuous background work (`coro()` function) alongside the agent's operations. You can choose to run either the agent or the entire `bureau` with the external loop. This approach provides greater flexibility when integrating the agent with other asynchronous tasks. #### Script 2 - ```py copy filename="external_loop_run.py" + + + ```py copy filename="local-external_loop_run.py" import asyncio from uagents import Agent, Bureau, Context @@ -114,6 +120,7 @@ In this example, we demonstrate how to use agents to communicate and exchange st # > when starting the external loop from the bureau # bureau.run() ``` + This script shows how to run an agent with its own **internal event loop**. For this example to run correctly, remember to provide a `seed` phrase to the agent. The agent is initialized with the `loop`, and both the agent and its background coroutine (`coro()` function) run within the same loop. This setup simplifies the integration by keeping everything within a single event `loop`, which can be advantageous for applications where you want the agent's lifecycle tightly coupled with its event handling function. diff --git a/pages/examples/advanced/open-dialogue-chitchat.mdx b/pages/examples/advanced/open-dialogue-chitchat.mdx index 6c3d3ea1..93728dd7 100644 --- a/pages/examples/advanced/open-dialogue-chitchat.mdx +++ b/pages/examples/advanced/open-dialogue-chitchat.mdx @@ -205,23 +205,25 @@ The contents of this script are to be shared between the agents that want to use - Run `cd ..` to go out of `Dialogues` directory and create `agent1.py` Python script - + - ```py copy filename="mac" - touch agent1.py - ``` + ```py copy filename="mac" + touch agent1.py + ``` - ```py copy filename="windows" - echo. > agent1.py - ``` + ```py copy filename="windows" + echo. > agent1.py + ``` - ```py copy filename="ubuntu" - touch agent1.py - ``` + ```py copy filename="ubuntu" + touch agent1.py + ``` - + + + - ```python copy filename="agent1.py" + ```python copy filename="local-agent1.py" # Import required libraries import json @@ -335,28 +337,30 @@ The contents of this script are to be shared between the agents that want to use print(f"Agent address: {agent.address}") agent.run() ``` + - Create Python `agent2.py` script: - + - ```py copy filename="mac" - touch agent2.py - ``` + ```py copy filename="mac" + touch agent2.py + ``` - ```py copy filename="windows" - echo. > agent2.py - ``` - - ```py copy filename="ubuntu" - touch agent2.py - ``` - + ```py copy filename="windows" + echo. > agent2.py + ``` + + ```py copy filename="ubuntu" + touch agent2.py + ``` + - + + - ```python copy filename="agent2.py" + ```python copy filename="local-agent2.py" """Chit chat dialogue example""" from asyncio import sleep @@ -474,7 +478,7 @@ The contents of this script are to be shared between the agents that want to use print(f"Agent address: {agent.address}") agent.run() ``` - + Remember to update the agent's address to communicate to each other and seed phrase of own choice. diff --git a/pages/examples/advanced/predefined-dialogue-chitchat.mdx b/pages/examples/advanced/predefined-dialogue-chitchat.mdx index 064ab4a0..9f3390bb 100644 --- a/pages/examples/advanced/predefined-dialogue-chitchat.mdx +++ b/pages/examples/advanced/predefined-dialogue-chitchat.mdx @@ -240,8 +240,10 @@ These two agents use the `hardcoded_chitchat` dialogue system to automate the in - Navigate to your working directory and create a Python script named `agent1.py`. - Copy the following script into `agent1.py`: + + - ```python copy filename="agent1.py" + ```python copy filename="local-agent1.py" # Import required libraries import json @@ -297,7 +299,7 @@ These two agents use the `hardcoded_chitchat` dialogue system to automate the in agent.run() # Running agent ``` - + ### Setting up `agent2` `agent2` is configured to automatically initiate a dialogue with `agent1` using the predefined dialogue system. @@ -305,7 +307,9 @@ These two agents use the `hardcoded_chitchat` dialogue system to automate the in - Create a new Python script named `agent2.py` in the same directory. - Paste the following code into `agent2.py`: - ```python copy filename="agent2.py" + + + ```python copy filename="local-agent2.py" """Chit chat dialogue example""" from asyncio import sleep @@ -362,6 +366,8 @@ These two agents use the `hardcoded_chitchat` dialogue system to automate the in Remember to update the agent's address to communicate to each other and seed phrase of own choice. + + ## Step 3: Run the Dialogue - Start `agent1`: diff --git a/pages/examples/intermediate/agents-cleaning-demo.mdx b/pages/examples/intermediate/agents-cleaning-demo.mdx index 854d7f41..7b574f6e 100644 --- a/pages/examples/intermediate/agents-cleaning-demo.mdx +++ b/pages/examples/intermediate/agents-cleaning-demo.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Cleaning service with Agents ## Introduction @@ -27,7 +29,9 @@ The protocol ensures the provider's services are available to the user's locatio Here is the full code: -```py copy filename="__init__.py" + + +```py copy filename="local-__init__.py" from datetime import datetime, timedelta from typing import List @@ -140,6 +144,7 @@ async def handle_book_request(ctx: Context, sender: str, msg: ServiceBooking): # send the response await ctx.send(sender, BookingResponse(success=success)) ``` + #### models.py @@ -195,8 +200,9 @@ class Availability(models.Model): ### Agents #### The Cleaner Agent + -```py copy filename="cleaner.py" +```py copy filename="local-cleaner.py" from datetime import datetime from protocols.cleaning import cleaning_proto @@ -249,10 +255,12 @@ async def shutdown(_ctx: Context): if __name__ == "__main__": cleaner.run() ``` + #### User -```py copy filename="user.py" + +```py copy filename="local-user.py" from datetime import datetime, timedelta from protocols.cleaning import ( @@ -328,3 +336,4 @@ async def handle_book_response(ctx: Context, _sender: str, msg: BookingResponse) if __name__ == "__main__": user.run() ``` + diff --git a/pages/examples/intermediate/agents-with-docker.mdx b/pages/examples/intermediate/agents-with-docker.mdx index abbd9de3..181be4d0 100644 --- a/pages/examples/intermediate/agents-with-docker.mdx +++ b/pages/examples/intermediate/agents-with-docker.mdx @@ -1,3 +1,4 @@ +import { CodeGroup } from "../../../components/code" # Running an Agent with Docker @@ -42,8 +43,9 @@ This example shows how to run an agent using the uAgents library inside a Docker This example demonstrates a simple agent-based communication system using the uAgents library. The `data_sender` agent sends a `DataPacket` message to the `data_receiver` agent every 4 seconds. Upon receiving the message, `data_receiver` logs it and sends an acknowledgment back to data_sender. Both agents log the messages they receive. The agents are running with Docker Compose using Docker. + -```py copy filename="agent.py" +```py copy filename="local-agent.py" from uagents import Agent, Bureau, Context, Model @@ -114,6 +116,7 @@ bureau.add(data_receiver) if __name__ == "__main__": bureau.run() ``` + ### `Dockerfile` diff --git a/pages/examples/intermediate/broadcast.mdx b/pages/examples/intermediate/broadcast.mdx index 40cb5c78..4d5caa3a 100644 --- a/pages/examples/intermediate/broadcast.mdx +++ b/pages/examples/intermediate/broadcast.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Agents broadcast ## Introduction @@ -16,7 +18,9 @@ This file can be run on any platform supporting Python, with the necessary insta ### The script -```python copy filename="broadcast.py" + + +```python copy filename="local-broadcast.py" from uagents import Agent, Bureau, Context, Model, Protocol # create agents @@ -65,7 +69,7 @@ bureau.add(charles) if __name__ == "__main__": bureau.run() ``` - + ### Expected output ``` diff --git a/pages/examples/intermediate/langchain-rag.mdx b/pages/examples/intermediate/langchain-rag.mdx index 1f5f2fe9..756558ad 100644 --- a/pages/examples/intermediate/langchain-rag.mdx +++ b/pages/examples/intermediate/langchain-rag.mdx @@ -130,7 +130,10 @@ class RagRequest(Model): ### Langchain RAG agent This agent answers questions by fetching and summarizing information from a given website. It checks and scrapes URLs, uses LangChain to find important documents, and generates answers with OpenAI's GPT-4o-mini model. -```python copy filename="langchain_rag_agent.py" + + + +```python copy filename="local-langchain_rag_agent.py" import traceback from uagents import Agent, Context, Protocol import validators @@ -269,6 +272,7 @@ if __name__ == "__main__": agent.run() ``` + ### Langchain user agent diff --git a/pages/examples/intermediate/local-agent-langchain.mdx b/pages/examples/intermediate/local-agent-langchain.mdx index 10ce3a70..67535db7 100644 --- a/pages/examples/intermediate/local-agent-langchain.mdx +++ b/pages/examples/intermediate/local-agent-langchain.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Locally Hosted Agent with LangChain Integration ## Introduction @@ -22,7 +24,9 @@ This guide demonstrates how to run an agent on your own hardware or infrastructu ### The agent -```py copy filename = 'agent.py' + + +```py copy filename="local-agent.py" from langchain_community.tools import WikipediaQueryRun from langchain_community.utilities import WikipediaAPIWrapper from uagents.setup import fund_agent_if_low @@ -66,7 +70,7 @@ async def load_dalle(ctx: Context, sender: str, msg: WikiReq): WikiAgent.include(wiki_protocol, publish_manifest=True) WikiAgent.run() ``` - + ### Register Agent Function Head to this [guide ↗️](/guides/agentverse/agentverse-functions/registering-agent-services) for a detailed overview of the registration process of Agent Functions on the Agentverse. diff --git a/pages/examples/intermediate/mailbox-agents.mdx b/pages/examples/intermediate/mailbox-agents.mdx index a84f4491..e38ad00f 100644 --- a/pages/examples/intermediate/mailbox-agents.mdx +++ b/pages/examples/intermediate/mailbox-agents.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Agents communication using Agentverse Mailbox feature ## Introduction @@ -17,7 +19,9 @@ A **Mailbox** allows your agent to receive messages sent to its address even whe ### Agent 1: Local Agent - ```py copy filename="agent_1.py" + + + ```py copy filename="local-agent_1.py" from uagents import Agent, Context, Model from uagents.setup import fund_agent_if_low @@ -52,11 +56,13 @@ A **Mailbox** allows your agent to receive messages sent to its address even whe if __name__ == "__main__": agent.run() ``` - + ### Agent 2: Agentverse Agent - ```py copy filename="agent_2.py" + + + ```py copy filename="hosted-agent_2.py" from uagents import Agent, Context, Model class Message(Model): @@ -74,7 +80,7 @@ A **Mailbox** allows your agent to receive messages sent to its address even whe async def on_message(ctx: Context, sender: str, msg: Message): ctx.logger.info(f"Received message from {sender}: {msg.message}") ``` - + ### Output 1. Agentverse Agent output: diff --git a/pages/examples/intermediate/multiple-agents.mdx b/pages/examples/intermediate/multiple-agents.mdx index 7d2bb5f0..f1c785f4 100644 --- a/pages/examples/intermediate/multiple-agents.mdx +++ b/pages/examples/intermediate/multiple-agents.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Multiple agents communication ## Introduction @@ -12,7 +14,9 @@ This file can be run on any platform supporting Python, with the necessary insta #### The agent -```py copy filename="agents.py" + + +```py copy filename="local-agents.py" from uagents import Agent, Bureau, Context alice = Agent(name="alice") @@ -33,3 +37,4 @@ bureau.add(bob) if __name__ == "__main__": bureau.run() ``` + \ No newline at end of file diff --git a/pages/examples/intermediate/name-service.mdx b/pages/examples/intermediate/name-service.mdx index 6280a67f..0c2ad1c4 100644 --- a/pages/examples/intermediate/name-service.mdx +++ b/pages/examples/intermediate/name-service.mdx @@ -19,7 +19,9 @@ This file can be run on any platform supporting Python, with the necessary insta ### Agent 1 -```py copy filename="agent_1.py" + + +```py copy filename="local-agent_1.py" from cosmpy.aerial.wallet import LocalWallet from uagents.network import get_name_service_contract @@ -56,6 +58,7 @@ async def message_handler(ctx: Context, sender: str, msg: Message): if __name__ == "__main__": bob.run() ``` + ### Agent 2 diff --git a/pages/examples/intermediate/on-query-proxy.mdx b/pages/examples/intermediate/on-query-proxy.mdx index 3e78a117..9856d75b 100644 --- a/pages/examples/intermediate/on-query-proxy.mdx +++ b/pages/examples/intermediate/on-query-proxy.mdx @@ -18,7 +18,8 @@ This example shows how to query an agent using a proxy API. #### The agent -```py copy filename="hosted-agent.py" + +```py copy filename="local-agent.py" from uagents import Agent, Context, Model class TestRequest(Model): @@ -27,6 +28,13 @@ class TestRequest(Model): class Response(Model): text: str +agent = Agent( + name="your_agent_name_here", + seed="your_agent_seed_here", + port=8001, + endpoint="http://localhost:8001/submit", +) + @agent.on_event("startup") async def startup(ctx: Context): ctx.logger.info(f"Starting up {agent.name}") @@ -41,9 +49,12 @@ async def query_handler(ctx: Context, sender: str, _query: TestRequest): await ctx.send(sender, Response(text="success")) except Exception: await ctx.send(sender, Response(text="fail")) + +if __name__ == "__main__": + agent.run() ``` -```py copy filename="local-agent.py" +```py copy filename="hosted-agent.py" from uagents import Agent, Context, Model class TestRequest(Model): @@ -52,13 +63,6 @@ class TestRequest(Model): class Response(Model): text: str -agent = Agent( - name="your_agent_name_here", - seed="your_agent_seed_here", - port=8001, - endpoint="http://localhost:8001/submit", -) - @agent.on_event("startup") async def startup(ctx: Context): ctx.logger.info(f"Starting up {agent.name}") @@ -73,9 +77,6 @@ async def query_handler(ctx: Context, sender: str, _query: TestRequest): await ctx.send(sender, Response(text="success")) except Exception: await ctx.send(sender, Response(text="fail")) - -if __name__ == "__main__": - agent.run() ``` diff --git a/pages/examples/intermediate/on-query.mdx b/pages/examples/intermediate/on-query.mdx index 0842c373..81e59b1e 100644 --- a/pages/examples/intermediate/on-query.mdx +++ b/pages/examples/intermediate/on-query.mdx @@ -1,4 +1,5 @@ import { Callout } from 'nextra/components' +import { CodeGroup } from "../../../components/code" # On Query decorator example @@ -22,7 +23,9 @@ This documentation outlines the steps to set up and enable communication between This agent handles queries related to job searches using SerpAPI. It provides information about available jobs for a job title specified by the user. -```py copy filename="JobSearchAgent.py" + + +```py copy filename="local-JobSearchAgent.py" # import required libraries import json @@ -121,7 +124,7 @@ async def query_handler(ctx: Context, sender: str, msg: Request): if __name__ == "__main__": SearchAgent.run() ``` - + Please update agent's secret phrase and serpapi API key. You can find serpapi API key on [SerpAPI API key ↗️](https://serpapi.com/) ### Flask App Script diff --git a/pages/examples/intermediate/postgres-database-with-an-agent.mdx b/pages/examples/intermediate/postgres-database-with-an-agent.mdx index e1b1dffd..4f7c5939 100644 --- a/pages/examples/intermediate/postgres-database-with-an-agent.mdx +++ b/pages/examples/intermediate/postgres-database-with-an-agent.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Utilize the PostgreSQL database with the Agent ## Introduction @@ -222,8 +224,9 @@ This script sets up and runs two agents, `db_insert_agent` and `db_fetch_agent`, 2. **Inserting Data**: `db_insert_agent` will insert received employee data into the database. 3. **Fetching Data**: `db_fetch_agent` will fetch and log all employee details upon request. + -```py copy filename="main.py" +```py copy filename="local-main.py" from db.db_connection import create_connection from uagents import Agent, Context, Bureau from db.models.models import Employees, GetEmployees @@ -359,7 +362,7 @@ if __name__ == "__main__": bureau.run() ``` - + This constant file initializes a dictionary for storing employee data and configures the database connection parameters using environment variables. It also defines a constant for the address of the database fetch agent. diff --git a/pages/examples/intermediate/react_example.mdx b/pages/examples/intermediate/react_example.mdx index d5f1bcf5..ff9b0387 100644 --- a/pages/examples/intermediate/react_example.mdx +++ b/pages/examples/intermediate/react_example.mdx @@ -409,7 +409,9 @@ In this section we will setup agents and as well as flask app which will respond - **WebScraper agent:** Scraps the webpage content for the given url. - ```python copy filename="webscraper_agent.py" + + + ```python copy filename="local-webscraper_agent.py" # Import Required libraries import requests import aiohttp @@ -488,10 +490,13 @@ In this section we will setup agents and as well as flask app which will respond if __name__ == "__main__": webScraperAgent.run() ``` + - **Sentiment agent:** Provides sentiment of news content provided using HF API and finBERT model. - ```python copy filename="sentiment_agent.py" + + + ```python copy filename="local-sentiment_agent.py" # Import Required libraries import requests from uagents import Agent, Context, Model @@ -567,10 +572,11 @@ In this section we will setup agents and as well as flask app which will respond if __name__ == "__main__": SentimentAgent.run() ``` + - - Get your [Hugging Face Inference API ↗️](https://huggingface.co/docs/api-inference/en/index). - + + Get your [Hugging Face Inference API ↗️](https://huggingface.co/docs/api-inference/en/index). + 3. Requirement.txt: diff --git a/pages/examples/intermediate/running-an-agent-on-agentverse.mdx b/pages/examples/intermediate/running-an-agent-on-agentverse.mdx index cbbcd8ff..061a871d 100644 --- a/pages/examples/intermediate/running-an-agent-on-agentverse.mdx +++ b/pages/examples/intermediate/running-an-agent-on-agentverse.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Run Agents on Agentverse ## Introduction @@ -56,7 +58,9 @@ Whenever you create a local agent, you can either run a it on the Agentverse by Let's consider the following local agent code: - ```py copy filename="agent.py" + + + ```py copy filename="local-agent.py" from uagents.setup import fund_agent_if_low from uagents import Agent, Context, Protocol, Model @@ -84,6 +88,7 @@ Let's consider the following local agent code: agent.run() ``` + The agent is initialized with an **endpoint** and a **port** so that it can receive messages, and other agents know where to send them. @@ -109,6 +114,8 @@ When running the above local agent, you will see something like this in your ter Let's consider the following local agent example: + + ```py copy filename="agent.py" from uagents import Agent, Context, Model, Protocol @@ -135,7 +142,7 @@ Let's consider the following local agent example: if __name__ == "__main__": agent.run() ``` - + You can create a Mailbox by retrieving your **local agent address** and head over to the **Agentverse: My Agents** tab. Click on **Local Agents** and click on **Connect Local Agent** button. Provide the address and name of the local agent you wish to retrieve and wait for confirmation. You will then be able to see a **Mailbox API Key**. Copy and paste it within your local agent code by filling up the `AGENT_MAILBOX_KEY` field inline and restart the agent. For an example of a complete code for a local agent with protocols registered on the Agentverse using the Mailbox feature, checkout this [example ↗️](/examples/intermediate/local-agent-langchain). diff --git a/pages/examples/intermediate/send-tokens-agents.mdx b/pages/examples/intermediate/send-tokens-agents.mdx index 31ef6259..71bbbec6 100644 --- a/pages/examples/intermediate/send-tokens-agents.mdx +++ b/pages/examples/intermediate/send-tokens-agents.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Send tokens with Agents ## Introduction @@ -17,7 +19,8 @@ This example shows how to use Agents to make them send tokens to each other. ### The agent - ```py copy filename="sending_tokens.py" + + ```py copy filename="local-sending_tokens.py" from uagents import Agent, Bureau, Context, Model from uagents.network import wait_for_tx_to_complete from uagents.setup import fund_agent_if_low @@ -77,7 +80,7 @@ This example shows how to use Agents to make them send tokens to each other. if __name__ == "__main__": bureau.run() ``` - + ### Expected output ``` diff --git a/pages/examples/intermediate/sending-and-verifying-token-transactions-with-agent.mdx b/pages/examples/intermediate/sending-and-verifying-token-transactions-with-agent.mdx index 6a5d9843..588c8982 100644 --- a/pages/examples/intermediate/sending-and-verifying-token-transactions-with-agent.mdx +++ b/pages/examples/intermediate/sending-and-verifying-token-transactions-with-agent.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Sending and verifying token transactions with Agent ## Introduction @@ -82,8 +84,9 @@ This example demonstrates how to build a simple agent-based system for transferr #### 3. Transaction Verification: - Upon receiving the transaction receipt, `transaction_initiator` sends a `VerificationRequest` to the `verification_agent`. The `verification_agent` checks the transaction status on the blockchain and logs the result. + -```py copy filename="transaction.py" +```py copy filename="local-transaction.py" from uagents import Agent, Bureau, Context, Model from web3 import Web3 from dotenv import load_dotenv @@ -276,6 +279,7 @@ if __name__ == "__main__": bureau.run() ``` + ### Poetry Dependencies diff --git a/pages/examples/intermediate/simple-agent-communication.mdx b/pages/examples/intermediate/simple-agent-communication.mdx index d64eb74e..ebeafd2d 100644 --- a/pages/examples/intermediate/simple-agent-communication.mdx +++ b/pages/examples/intermediate/simple-agent-communication.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Agents communication ## Introduction @@ -12,8 +14,8 @@ This file can be run on any platform supporting Python, with the necessary insta - [Agents address ↗️](/guides/agents/getting-started/getting-uagent-address) #### The agent - - ```py copy filename="agents_communication.py" + + ```py copy filename="local-agents_communication.py" from uagents import Agent, Bureau, Context, Model class Message(Model): @@ -41,3 +43,4 @@ This file can be run on any platform supporting Python, with the necessary insta if __name__ == "__main__": bureau.run() ``` + \ No newline at end of file diff --git a/pages/examples/intermediate/verify-messages.mdx b/pages/examples/intermediate/verify-messages.mdx index 4fa16c1a..bfd9b57a 100644 --- a/pages/examples/intermediate/verify-messages.mdx +++ b/pages/examples/intermediate/verify-messages.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Verify messages with Agents ## Introduction @@ -16,7 +18,8 @@ This example shows how to use Agents to make them verify authenticity of message ### The agent - ```py copy filename="message_verification.py" + + ```py copy filename="local-message_verification.py" import hashlib from uagents import Agent, Bureau, Context, Model from uagents.crypto import Identity @@ -76,7 +79,7 @@ This example shows how to use Agents to make them verify authenticity of message if __name__ == "__main__": bureau.run() ``` - + ### Expected output ``` diff --git a/pages/examples/intermediate/wallet-messaging.mdx b/pages/examples/intermediate/wallet-messaging.mdx index 5571d4e7..dc55c7a9 100644 --- a/pages/examples/intermediate/wallet-messaging.mdx +++ b/pages/examples/intermediate/wallet-messaging.mdx @@ -1,3 +1,5 @@ +import { CodeGroup } from "../../../components/code" + # Communicating with other agents wallet ## Introduction @@ -86,7 +88,8 @@ In this example we will create two agents locally using `uagents` library and ma This section presents the entire script in one block, allowing users to easily copy and paste it for testing or deployment. - ```py filename=wallet_messaging.py + + ```py filename="local-wallet_messaging.py" from uagents import Agent, Bureau, Context from uagents.wallet_messaging import WalletMessage @@ -116,7 +119,7 @@ This section presents the entire script in one block, allowing users to easily c bureau.add(bob) bureau.run() ``` - + ### Script Execution - Open terminal and navigate to the folder where `wallet_messaging.py` is stored.