Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install flask praisonai==2.1.4 gunicorn markdown
RUN pip install flask praisonai==2.1.5 gunicorn markdown
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's good to update the praisonai version. Is there a specific reason for upgrading to 2.1.5? It would be helpful to add a comment explaining the reason for the update, especially if it addresses a bug or introduces a new feature. This helps with future maintenance and understanding the context of the change.

RUN pip install flask praisonai==2.1.5 # Updated to address [bug/feature] in 2.1.5 gunicorn markdown

EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.chat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN pip install --no-cache-dir \
praisonaiagents>=0.0.4 \
praisonai_tools \
"praisonai==2.1.4" \
"praisonai==2.1.5" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same comment here regarding the praisonai version update. Adding a comment explaining the reason would be beneficial.

    "praisonai==2.1.5" # Updated to address [bug/feature] in 2.1.5

"praisonai[chat]" \
"embedchain[github,youtube]"

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN pip install --no-cache-dir \
praisonaiagents>=0.0.4 \
praisonai_tools \
"praisonai==2.1.4" \
"praisonai==2.1.5" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same comment here regarding the praisonai version update. Adding a comment explaining the reason would be beneficial.

    "praisonai==2.1.5" # Updated to address [bug/feature] in 2.1.5

"praisonai[ui]" \
"praisonai[chat]" \
"praisonai[realtime]" \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN pip install --no-cache-dir \
praisonaiagents>=0.0.4 \
praisonai_tools \
"praisonai==2.1.4" \
"praisonai==2.1.5" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same comment here regarding the praisonai version update. Adding a comment explaining the reason would be beneficial.

    "praisonai==2.1.5" # Updated to address [bug/feature] in 2.1.5

"praisonai[ui]" \
"praisonai[crewai]"

Expand Down
2 changes: 1 addition & 1 deletion docs/api/praisonai/deploy.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h2 id="raises">Raises</h2>
file.write(&#34;FROM python:3.11-slim\n&#34;)
file.write(&#34;WORKDIR /app\n&#34;)
file.write(&#34;COPY . .\n&#34;)
file.write(&#34;RUN pip install flask praisonai==2.1.4 gunicorn markdown\n&#34;)
file.write(&#34;RUN pip install flask praisonai==2.1.5 gunicorn markdown\n&#34;)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same comment here regarding the praisonai version update. Adding a comment explaining the reason would be beneficial.

Suggested change
file.write(&#34;RUN pip install flask praisonai==2.1.5 gunicorn markdown\n&#34;)
file.write(&#34;RUN pip install flask praisonai==2.1.5 # Updated to address [bug/feature] in 2.1.5 gunicorn markdown\n&#34;)

file.write(&#34;EXPOSE 8080\n&#34;)
file.write(&#39;CMD [&#34;gunicorn&#34;, &#34;-b&#34;, &#34;0.0.0.0:8080&#34;, &#34;api:app&#34;]\n&#39;)

Expand Down
210 changes: 210 additions & 0 deletions docs/deploy/multi-agents-deploy.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
---
title: "Deploying Multi-Agent Systems as APIs"
sidebarTitle: "Multi-Agent Deployment"
description: "Learn how to deploy PraisonAI multi-agent systems as RESTful APIs for production environments"
icon: "network-wired"
---

# Deploying Multi-Agent Systems as APIs

PraisonAI allows you to deploy sophisticated multi-agent systems as RESTful APIs, enabling seamless integration with various applications and services. This guide covers different approaches to deploying multi-agent systems.

## Quick Start

<Steps>
<Step title="Install Dependencies">
Make sure you have the required packages installed:
```bash
pip install "praisonaiagents[api]>=0.0.81"
```
</Step>
<Step title="Set API Key">
```bash
export OPENAI_API_KEY="your_api_key"
```
</Step>
<Step title="Deploy a Multi-Agent System">
Create a file named `multi-agents-api.py` with the following code:
```python
from praisonaiagents import Agent, Agents, Tools

research_agent = Agent(name="Research", instructions="You are a research agent to search internet about AI 2024", tools=[Tools.internet_search])
summarise_agent = Agent(name="Summarise", instructions="You are a summarize agent to summarise in points")
agents = Agents(agents=[research_agent, summarise_agent])
agents.launch(path="/agents", port=3030)
```
</Step>
<Step title="Run the API Server">
```bash
python multi-agents-api.py
```

Your multi-agent API will be available at `http://localhost:3030/agents`
</Step>
</Steps>

## Making API Requests

Once your multi-agent system is deployed, you can make POST requests to interact with it:

```bash
curl -X POST http://localhost:3030/agents \
-H "Content-Type: application/json" \
-d '{"message": "What are the latest developments in AI in 2024?"}'
```

The response will include the collaborative output from both the research and summarization agents:

```json
{
"response": "# Latest AI Developments in 2024\n\n- Multimodal AI models have become mainstream, combining text, image, audio, and video understanding\n- Significant advancements in AI reasoning capabilities with models like GPT-4o and Claude 3\n- Increased focus on AI alignment and safety research\n- Emergence of specialized AI agents for specific domains\n- Growth in open-source AI models and frameworks\n- Regulatory frameworks for AI being established globally"
}
```

## Multiple Agent Groups

You can deploy multiple agent groups on the same server, each with its own endpoint:

```python
from praisonaiagents import Agent, Agents, Tools

research_agent = Agent(name="Research", instructions="You are a research agent to search internet about AI 2024", tools=[Tools.internet_search])
summarise_agent = Agent(name="Summarise", instructions="You are a summarize agent to summarise in points")
agents = Agents(agents=[research_agent, summarise_agent])
agents2 = Agents(agents=[research_agent])
agents.launch(path="/agents", port=3030)
agents2.launch(path="/agents2", port=3030)
```

With this setup, you can access:
- The full agent group at `http://localhost:3030/agents`
- Just the research agent at `http://localhost:3030/agents2`

## Independent Multi-Agent Deployment

You can also deploy multiple independent agents on the same server:

```python
from praisonaiagents import Agent

weather_agent = Agent(
instructions="""You are a weather agent that can provide weather information for a given city.""",
llm="gpt-4o-mini"
)

stock_agent = Agent(
instructions="""You are a stock market agent that can provide information about stock prices and market trends.""",
llm="gpt-4o-mini"
)

travel_agent = Agent(
instructions="""You are a travel agent that can provide recommendations for destinations, hotels, and activities.""",
llm="gpt-4o-mini"
)

weather_agent.launch(path="/weather", port=3030)
stock_agent.launch(path="/stock", port=3030)
travel_agent.launch(path="/travel", port=3030)
```

## Production Deployment Options

For production environments, consider the following deployment options:

### Docker Deployment

<Steps>
<Step title="Create a Dockerfile">
```dockerfile
FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 3030

CMD ["python", "multi-agents-api.py"]
```
</Step>
<Step title="Create requirements.txt">
```
praisonaiagents[api]>=0.0.81
```
</Step>
<Step title="Build and Run Docker Container">
```bash
docker build -t praisonai-multi-agent .
docker run -p 3030:3030 -e OPENAI_API_KEY=your_api_key praisonai-multi-agent
```
</Step>
</Steps>

### Cloud Deployment

For detailed cloud deployment instructions, refer to:
- [AWS Deployment Guide](/deploy/aws)
- [Google Cloud Deployment Guide](/deploy/googlecloud)

## Scaling Multi-Agent Systems

When deploying multi-agent systems to production, consider these scaling strategies:

1. **Horizontal Scaling**: Deploy multiple instances behind a load balancer
2. **Vertical Scaling**: Allocate more CPU and memory resources for complex agent interactions
3. **Caching**: Implement response caching for frequently asked questions
4. **Asynchronous Processing**: Use message queues for handling long-running agent tasks

## API Configuration Options

When launching your multi-agent system as an API, you can customize various parameters:

```python
agents.launch(
path="/custom-endpoint", # API endpoint path
port=8080, # Port number
host="0.0.0.0", # Host address (0.0.0.0 for external access)
debug=True, # Enable debug mode
cors_origins=["*"], # CORS configuration
api_key="your-api-key" # Optional API key for authentication
)
```

## Securing Your Multi-Agent API

For production deployments, consider implementing:

1. **API Key Authentication**: Require API keys for all requests
2. **Rate Limiting**: Limit the number of requests per client
3. **HTTPS**: Use SSL/TLS certificates for encrypted communication
4. **Input Validation**: Validate all input data before processing
5. **Output Filtering**: Implement content filtering for agent responses

## Monitoring and Logging

For production environments, consider:

1. **Centralized Logging**: Collect logs from all agents in a central location
2. **Performance Metrics**: Track response times and resource usage
3. **Error Tracking**: Monitor and alert on agent failures
4. **Usage Analytics**: Track which agents are used most frequently

## Features

<CardGroup cols={2}>
<Card title="Collaborative Agents" icon="users-gear">
Deploy agent systems that collaborate to solve complex problems.
</Card>
<Card title="Specialized Endpoints" icon="sitemap">
Create dedicated endpoints for different agent groups or individual agents.
</Card>
<Card title="Tool Integration" icon="screwdriver-wrench">
Deploy agents with specialized tools like web search capabilities.
</Card>
<Card title="Scalable Architecture" icon="server">
Scale your multi-agent systems to handle production workloads.
</Card>
</CardGroup>
2 changes: 1 addition & 1 deletion docs/developers/local-development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ WORKDIR /app

COPY . .

RUN pip install flask praisonai==2.1.4 watchdog
RUN pip install flask praisonai==2.1.5 watchdog
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same comment here regarding the praisonai version update. Adding a comment explaining the reason would be beneficial.

RUN pip install flask praisonai==2.1.5 # Updated to address [bug/feature] in 2.1.5 watchdog


EXPOSE 5555

Expand Down
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
"group": "Deploy",
"pages": [
"deploy/deploy",
"deploy/multi-agents-deploy",
"deploy/aws",
"deploy/googlecloud"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/ui/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ To facilitate local development with live reload, you can use Docker. Follow the

COPY . .

RUN pip install flask praisonai==2.1.4 watchdog
RUN pip install flask praisonai==2.1.5 watchdog

EXPOSE 5555

Expand Down
2 changes: 1 addition & 1 deletion docs/ui/code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ To facilitate local development with live reload, you can use Docker. Follow the

COPY . .

RUN pip install flask praisonai==2.1.4 watchdog
RUN pip install flask praisonai==2.1.5 watchdog

EXPOSE 5555

Expand Down
6 changes: 6 additions & 0 deletions examples/api/multi-agents-api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from praisonaiagents import Agent, Agents, Tools

research_agent = Agent(name="Research", instructions="You are a research agent to search internet about AI 2024", tools=[Tools.internet_search])
summarise_agent = Agent(name="Summarise", instructions="You are a summarize agent to summarise in points")
agents = Agents(agents=[research_agent, summarise_agent])
agents.launch(path="/agents", port=3030)
8 changes: 8 additions & 0 deletions examples/api/multi-agents-group-api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from praisonaiagents import Agent, Agents, Tools

research_agent = Agent(name="Research", instructions="You are a research agent to search internet about AI 2024", tools=[Tools.internet_search])
summarise_agent = Agent(name="Summarise", instructions="You are a summarize agent to summarise in points")
agents = Agents(agents=[research_agent, summarise_agent])
agents2 = Agents(agents=[research_agent])
agents.launch(path="/agents", port=3030)
agents2.launch(path="/agents2", port=3030)
2 changes: 1 addition & 1 deletion praisonai/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def create_dockerfile(self):
file.write("FROM python:3.11-slim\n")
file.write("WORKDIR /app\n")
file.write("COPY . .\n")
file.write("RUN pip install flask praisonai==2.1.4 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.1.5 gunicorn markdown\n")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Same comment here regarding the praisonai version update. Adding a comment explaining the reason would be beneficial.

Suggested change
file.write("RUN pip install flask praisonai==2.1.5 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.1.5 # Updated to address [bug/feature] in 2.1.5 gunicorn markdown\n")

file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')

Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "PraisonAI"
version = "2.1.4"
version = "2.1.5"
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
readme = "README.md"
license = ""
Expand All @@ -12,7 +12,7 @@ dependencies = [
"rich>=13.7",
"markdown>=3.5",
"pyparsing>=3.0.0",
"praisonaiagents>=0.0.79",
"praisonaiagents>=0.0.81",
"python-dotenv>=0.19.0",
"instructor>=1.3.3",
"PyYAML>=6.0",
Expand Down Expand Up @@ -89,7 +89,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.15", "crewai"]

[tool.poetry]
name = "PraisonAI"
version = "2.1.4"
version = "2.1.5"
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
authors = ["Mervin Praison"]
license = ""
Expand All @@ -107,7 +107,7 @@ python = ">=3.10,<3.13"
rich = ">=13.7"
markdown = ">=3.5"
pyparsing = ">=3.0.0"
praisonaiagents = ">=0.0.79"
praisonaiagents = ">=0.0.81"
python-dotenv = ">=0.19.0"
instructor = ">=1.3.3"
PyYAML = ">=6.0"
Expand Down
Loading
Loading