Python library for the Agora Protocol.
Project description
python
Python library for the Agora Protocol.
The Agora Protocol is a protocol for efficient communication between heterogeneous agents. It allows agents of any framework to communicate with agents in any other framework, while maximizing efficiency.
Note: Agora Python is currently in Open Beta! Expect breaking changes from one version to the other.
Installation
pip install agora-protocol
Usage
There are two ways to use Agora: as a sender agent (i.e. a client) or as a receiver agent (i.e. a server). An agent can also act as both a sender and a receiver.
This is a quick example where two agents (a LangChain agent and a Camel agent) exchange weather data.
Sender
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)
# Any properly annotated function with Google-style docstrings
# can be automatically converted to a task. Refer to the documentation for other ways
# to describe tasks
@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
Receiver
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)
Contributing
If you want to contribute, join our Discord to find out more!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agora_protocol-0.2.0.tar.gz.
File metadata
- Download URL: agora_protocol-0.2.0.tar.gz
- Upload date:
- Size: 37.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.0-122-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
059ee7782381f208e478afc498ba05bb80465a5681e0d12fcd1d08778becb112
|
|
| MD5 |
c4a0fc702503283033b791567697ba1b
|
|
| BLAKE2b-256 |
da27c966f7be19d609ae76ee20acc37e4bef49e0e08c0efb8563b4d49ff37bb5
|
File details
Details for the file agora_protocol-0.2.0-py3-none-any.whl.
File metadata
- Download URL: agora_protocol-0.2.0-py3-none-any.whl
- Upload date:
- Size: 50.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.0-122-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8be30d55446ee6b1d62daf28e5ab4d933b467d2e4fd4cf9d6f47c40ec8a954f
|
|
| MD5 |
4dccb43d59d823f3c31d34e92a041ce1
|
|
| BLAKE2b-256 |
bf89d7009b761144b0a9cc65caf84009b6b1d9338aee49851d6917c1c3ce464a
|