Metadata-Version: 2.1
Name: agora-protocol
Version: 0.2.0
Summary: Python library for the Agora Protocol.
License: MIT
Author: Samuele Marro
Author-email: marrosamuele@gmail.com
Requires-Python: >=3.10,<3.13
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: camel-ai
Requires-Dist: PyYAML (>=6.0,<7.0)
Requires-Dist: RestrictedPython (>=7.4,<8.0)
Requires-Dist: camel-ai (>=0.2.6,<0.3.0) ; extra == "camel-ai"
Requires-Dist: flask (>=3.1,<4.0)
Requires-Dist: langchain (>=0.3.12,<0.4.0)
Requires-Dist: langchain-core (>=0.3.20,<0.4.0)
Requires-Dist: langgraph (>=0.2.60,<0.3.0)
Requires-Dist: requests (>=2.32,<3.0)
Description-Content-Type: text/markdown

# 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

```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)

# 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

```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)
```

## Contributing

If you want to contribute, join our [Discord](https://discord.gg/MXmfhwQ4FB) to find out more!

