### Install Agora Protocol and Agent Frameworks Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Commands to install the Agora Protocol library along with necessary dependencies for LangChain and Camel AI agent frameworks. ```bash pip install agora-protocol ``` ```bash pip install langchain_openai pip install Pillow requests_oauthlib # Dependencies for camel-ai pip install camel-ai ``` -------------------------------- ### Install Agora Protocol Python Library Source: https://github.com/agora-protocol/python/blob/main/README.md Installs the Agora Protocol Python library using pip, the Python package installer. This command adds the necessary dependencies to your environment. ```bash pip install agora-protocol ``` -------------------------------- ### Start Agora Receiver HTTP Server Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Code to instantiate and run an HTTP server for the Agora Receiver agent, making it accessible on a specified port for incoming requests from sender agents. ```python server = agora.ReceiverServer(receiver) server.run(port=5000) ``` -------------------------------- ### Receive Data with Agora Protocol Python Receiver Source: https://github.com/agora-protocol/python/blob/main/README.md This example illustrates how to set up an Agora receiver agent using a Camel toolformer. It defines a local tool function `weather_db` to handle incoming requests by providing temperature and precipitation data, and then starts a `ReceiverServer` to listen for connections on port 5000. ```python import agora import camel.types # Needs to be installed separately toolformer = agora.toolformers.CamelToolformer( camel.types.ModelPlatformType.OPENAI, camel.types.ModelType.GPT_4O ) def weather_db(city: str) -> dict: """Gets the temperature and precipitation in a city. Args: city: The name of the city for which to retrieve the weather Returns: A dictionary containing the temperature and precipitation in the city (both ints) """ # Put your tool logic here return { 'temperature': 25, 'precipitation': 12 } receiver = agora.Receiver.make_default(toolformer, tools=[weather_db]) server = agora.ReceiverServer(receiver) server.run(port=5000) ``` -------------------------------- ### Send Data with Agora Protocol Python Sender Source: https://github.com/agora-protocol/python/blob/main/README.md This example demonstrates how to configure an Agora sender agent using a LangChain toolformer. It defines a remote task `get_temperature` with parameters and return types, and shows how to invoke it, targeting a receiver at `http://localhost:5000` to retrieve weather data. ```python import agora from langchain_openai import ChatOpenAI # Needs to be installed separately model = ChatOpenAI(model="gpt-4o-mini") toolformer = agora.toolformers.LangChainToolformer(model) sender = agora.Sender.make_default(toolformer) @sender.task() def get_temperature(city : str) -> int: """ Get the temperature for a given city. Parameters: city: The name of the city for which to retrieve the weather Returns: The temperature in °C for the given city. """ pass response = get_temperature('New York', target='http://localhost:5000') print(response) # Output: 25 ``` -------------------------------- ### API: weather_db Tool Function Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Documentation for the `weather_db` tool function, detailing its arguments and the structure of its dictionary return value. This tool provides weather data for a city. ```APIDOC weather_db(city: str) -> dict Args: city: The name of the city for which to retrieve the weather Returns: A dictionary containing the temperature and precipitation in the city (both ints) ``` -------------------------------- ### Invoke Agora Sender Task Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Demonstrates how to call the `get_temperature` task, specifying the target receiver agent's URL. The Agora protocol handles the communication and returns the result. ```python response = get_temperature('New York', target='http://localhost:5000') print(response) # Output: 25 ``` -------------------------------- ### Define Agora Receiver Agent with Local Tool Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Sets up an Agora Receiver agent, integrating with Camel AI and defining a local Python function `weather_db` that acts as a tool. This tool can be invoked by sender agents. ```python import agora import camel.types # Needs to be installed separately toolformer = agora.toolformers.CamelToolformer( camel.types.ModelPlatformType.OPENAI, camel.types.ModelType.GPT_4O ) def weather_db(city: str) -> dict: """Gets the temperature and precipitation in a city. Args: city: The name of the city for which to retrieve the weather Returns: A dictionary containing the temperature and precipitation in the city (both ints) """ # Put your tool logic here return { 'temperature': 25, 'precipitation': 12 } ``` -------------------------------- ### API: get_temperature Task Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Documentation for the `get_temperature` task, outlining its parameters and return type. This task retrieves temperature data for a specified city. ```APIDOC get_temperature(city: str) -> int city: The name of the city for which to retrieve the weather Returns: The temperature in °C for the given city. ``` -------------------------------- ### Define Agora Sender Agent Task Source: https://github.com/agora-protocol/python/blob/main/docs/getting-started.md Initializes an Agora Sender agent with a LangChainToolformer and defines a remote task `get_temperature` using the `@sender.task` decorator. This function is automatically exposed for remote calls. ```python import agora from langchain_openai import ChatOpenAI model = ChatOpenAI(model="gpt-4o-mini") toolformer = agora.toolformers.LangChainToolformer(model) sender = agora.Sender.make_default(toolformer) @sender.task() def get_temperature(city : str) -> int: """ Get the temperature for a given city. Parameters: city: The name of the city for which to retrieve the weather Returns: The temperature in °C for the given city. """ pass ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.