mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-08 17:31:00 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f0e3c0507 | ||
|
|
5e11f7566d | ||
|
|
66a8c9e074 | ||
|
|
2ef8250d49 | ||
|
|
090f1d1339 | ||
|
|
e299a5aaf3 | ||
|
|
15bda4df81 | ||
|
|
57fdc5e4ed | ||
|
|
54cb01426f | ||
|
|
f3d61459fe | ||
|
|
53d7d7e7f7 | ||
|
|
c133e24816 | ||
|
|
318131bb92 | ||
|
|
6cfa8f30d7 | ||
|
|
f6b1517aa0 | ||
|
|
624837356e | ||
|
|
df12ae032f | ||
|
|
c405aaf121 | ||
|
|
03e2bb94f2 | ||
|
|
5e3e503dd9 | ||
|
|
633d724eb2 | ||
|
|
5cfda3fa54 | ||
|
|
370cb108f2 | ||
|
|
83cb80e907 | ||
|
|
f385de04e0 | ||
|
|
18695543e5 | ||
|
|
267f223a3e | ||
|
|
02bd52a06d | ||
|
|
076576af85 | ||
|
|
17547073ec | ||
|
|
124a95d7d0 | ||
|
|
8ca4e3285d | ||
|
|
5eac60dab3 | ||
|
|
59ee7cbbe5 | ||
|
|
81517b58e5 | ||
|
|
c1a8338a24 | ||
|
|
dba5a49569 | ||
|
|
6dab69e9d7 | ||
|
|
90563207f7 | ||
|
|
46330b0487 | ||
|
|
a133f0d5e2 | ||
|
|
fb22e6e1c7 | ||
|
|
e938fe63ea | ||
|
|
ef96e53843 | ||
|
|
036c463a43 | ||
|
|
0e6b4aefc3 | ||
|
|
bbb9f677ae | ||
|
|
0da201b3b6 | ||
|
|
a7b85043e1 | ||
|
|
dc393e1211 | ||
|
|
fdff17faf9 | ||
|
|
b3d893fae1 | ||
|
|
d92dede515 | ||
|
|
a1882233dc | ||
|
|
aa6b6ac62e | ||
|
|
c540ba34fb | ||
|
|
0abb1b659a | ||
|
|
81adb28688 | ||
|
|
5fbe6e948c | ||
|
|
6128e4c885 | ||
|
|
0e563989ed | ||
|
|
510a853e05 | ||
|
|
d6084cb7ce | ||
|
|
8d4b1c411b | ||
|
|
3be05c855b | ||
|
|
3e5a2f76f4 | ||
|
|
8eee881d2e | ||
|
|
d75f4be41a | ||
|
|
9ea89448ef | ||
|
|
0a5e2df278 | ||
|
|
cc3b64f89b | ||
|
|
546dc5a441 | ||
|
|
bd7422c7ca | ||
|
|
0c2c6da8dd | ||
|
|
b43688086f | ||
|
|
820619e8d9 | ||
|
|
94202adddd | ||
|
|
c7911629b1 | ||
|
|
5a4e3ba707 | ||
|
|
641057b622 | ||
|
|
db1dbf142e | ||
|
|
d9a19ae277 | ||
|
|
3c9d889b4f | ||
|
|
2f324e74db | ||
|
|
c22fef3e6d | ||
|
|
53bee19948 | ||
|
|
798fe68908 | ||
|
|
95796cd4c7 | ||
|
|
b447b7e6eb | ||
|
|
29dfe4b192 | ||
|
|
aca95b1713 | ||
|
|
b4cc3d7a8e | ||
|
|
eaf337b301 | ||
|
|
2f73cf1882 | ||
|
|
680949742e | ||
|
|
560219dcd7 |
No files matched your search
@@ -0,0 +1,37 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
@@ -15,15 +15,14 @@ jobs:
|
||||
with:
|
||||
python-version: 3.11
|
||||
|
||||
- name: Install Poetry
|
||||
- name: Install UV
|
||||
run: |
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
pip install uv
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
poetry install
|
||||
poetry run python -m pip install duckduckgo_search
|
||||
uv pip install ."[ui,gradio,api,agentops,google,openai,anthropic,cohere,chat,code,realtime,call,crewai,autogen]"
|
||||
uv pip install duckduckgo_search
|
||||
|
||||
- name: Set environment variables
|
||||
run: |
|
||||
@@ -33,4 +32,4 @@ jobs:
|
||||
|
||||
- name: Run specific unittest
|
||||
run: |
|
||||
poetry run python -m unittest tests.test.TestExamples
|
||||
uv run python -m unittest tests.test.TestExamples
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
PraisonAI is a production-ready Multi-AI Agents framework with self-reflection, designed to create AI Agents to automate and solve problems ranging from simple tasks to complex challenges. By integrating PraisonAI Agents, AutoGen, and CrewAI into a low-code solution, it streamlines the building and management of multi-agent LLM systems, emphasising simplicity, customisation, and effective human-agent collaboration.
|
||||
PraisonAI is a production-ready Multi-AI Agents framework with self-reflection, designed to create AI Agents to automate and solve problems ranging from simple tasks to complex challenges. By integrating PraisonAI Agents, AG2 (Formerly AutoGen), and CrewAI into a low-code solution, it streamlines the building and management of multi-agent LLM systems, emphasising simplicity, customisation, and effective human-agent collaboration.
|
||||
|
||||
<div align="center">
|
||||
<a href="https://docs.praison.ai">
|
||||
@@ -548,7 +548,7 @@ uv pip install -r pyproject.toml --extra "crewai,autogen"
|
||||
|
||||
## Other Features
|
||||
|
||||
- 🔄 Use CrewAI or AutoGen Framework
|
||||
- 🔄 Use CrewAI or AG2 (Formerly AutoGen) Framework
|
||||
- 💻 Chat with ENTIRE Codebase
|
||||
- 🎨 Interactive UIs
|
||||
- 📄 YAML-based Configuration
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip install flask praisonai==2.0.81 gunicorn markdown
|
||||
RUN pip install flask praisonai==2.2.2 gunicorn markdown
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
|
||||
@@ -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.0.18" \
|
||||
"praisonai==2.2.2" \
|
||||
"praisonai[chat]" \
|
||||
"embedchain[github,youtube]"
|
||||
|
||||
|
||||
@@ -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.0.18" \
|
||||
"praisonai==2.2.2" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[chat]" \
|
||||
"praisonai[realtime]" \
|
||||
|
||||
@@ -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.0.18" \
|
||||
"praisonai==2.2.2" \
|
||||
"praisonai[ui]" \
|
||||
"praisonai[crewai]"
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ Features:
|
||||
- Built-in tools
|
||||
- Structured workflows
|
||||
|
||||
### AutoGen Integration
|
||||
### AG2 (Formerly AutoGen) Integration
|
||||
Requires installation with:
|
||||
```bash
|
||||
pip install "praisonai[autogen]"
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ from praisonai.auto import AutoGenerator
|
||||
### praisonai.agents_generator
|
||||
Framework-specific agent generation and orchestration:
|
||||
- CrewAI support (requires `praisonai[crewai]`)
|
||||
- AutoGen support (requires `praisonai[autogen]`)
|
||||
- AG2 (Formerly AutoGen) support (requires `praisonai[autogen]`)
|
||||
|
||||
```python
|
||||
from praisonai.agents_generator import AgentsGenerator
|
||||
@@ -51,7 +51,7 @@ pip install praisonai
|
||||
|
||||
# Framework-specific installations
|
||||
pip install "praisonai[crewai]" # Install with CrewAI support
|
||||
pip install "praisonai[autogen]" # Install with AutoGen support
|
||||
pip install "praisonai[autogen]" # Install with AG2 support
|
||||
pip install "praisonai[crewai,autogen]" # Install both frameworks
|
||||
|
||||
# Additional features
|
||||
@@ -71,9 +71,9 @@ When installing with `pip install "praisonai[crewai]"`, you get:
|
||||
- Task delegation capabilities
|
||||
- Sequential and parallel task execution
|
||||
|
||||
### AutoGen
|
||||
### AG2 (Formerly AutoGen)
|
||||
When installing with `pip install "praisonai[autogen]"`, you get:
|
||||
- AutoGen framework support
|
||||
- AG2 framework support
|
||||
- PraisonAI tools integration
|
||||
- Multi-agent conversation capabilities
|
||||
- Code execution environment
|
||||
@@ -110,7 +110,7 @@ Loads environment variables from .env file or system and sets them.</p>
|
||||
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.0.81 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.2.2 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
---
|
||||
title: "Deploying to AWS"
|
||||
sidebarTitle: "AWS"
|
||||
description: "Deploy PraisonAI agents to Amazon Web Services for scalable production environments"
|
||||
icon: "aws"
|
||||
---
|
||||
|
||||
# Deploying PraisonAI Agents to AWS
|
||||
|
||||
This guide provides step-by-step instructions for deploying PraisonAI agents to Amazon Web Services (AWS), offering multiple deployment options to suit different requirements.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- AWS account with appropriate permissions
|
||||
- AWS CLI installed and configured
|
||||
- Docker installed on your local machine (for container-based deployments)
|
||||
- Basic knowledge of AWS services and cloud deployment
|
||||
|
||||
## Deployment Options
|
||||
|
||||
There are several ways to deploy PraisonAI agents to AWS:
|
||||
|
||||
1. **AWS Lambda with API Gateway** (for serverless deployments)
|
||||
2. **Amazon ECS/Fargate** (for containerized deployments)
|
||||
3. **Amazon EC2** (for traditional VM-based deployments)
|
||||
4. **AWS App Runner** (for simplified container deployments)
|
||||
|
||||
## Option 1: Deploying to EC2 (Traditional VM)
|
||||
|
||||
<Steps>
|
||||
<Step title="Launch an EC2 Instance">
|
||||
1. Go to the AWS Management Console
|
||||
2. Navigate to EC2 and click "Launch Instance"
|
||||
3. Choose Amazon Linux 2 or Ubuntu Server
|
||||
4. Select an instance type (t2.micro for testing, t2.medium or larger for production)
|
||||
5. Configure security groups to allow HTTP/HTTPS traffic
|
||||
6. Launch the instance and connect to it via SSH
|
||||
</Step>
|
||||
|
||||
<Step title="Set Up the Environment">
|
||||
```bash
|
||||
# Update system packages
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# Install Python and pip
|
||||
sudo apt install -y python3 python3-pip
|
||||
|
||||
# Install required packages
|
||||
pip3 install "praisonaiagents[api]>=0.0.79"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create the API Application">
|
||||
Create a file named `api.py`:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="""You are a helpful assistant.""", llm="gpt-4o-mini")
|
||||
agent.launch(path="/ask", port=8080, host="0.0.0.0")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Set Up a Systemd Service">
|
||||
Create a systemd service file to run your application as a background service:
|
||||
|
||||
```bash
|
||||
sudo nano /etc/systemd/system/praisonai-agent.service
|
||||
```
|
||||
|
||||
Add the following content:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=PraisonAI Agent API Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=ubuntu
|
||||
WorkingDirectory=/home/ubuntu
|
||||
Environment="OPENAI_API_KEY=your_api_key"
|
||||
ExecStart=/usr/bin/python3 /home/ubuntu/api.py
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Enable and start the service:
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable praisonai-agent
|
||||
sudo systemctl start praisonai-agent
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Set Up Nginx as a Reverse Proxy">
|
||||
```bash
|
||||
# Install Nginx
|
||||
sudo apt install -y nginx
|
||||
|
||||
# Create a configuration file
|
||||
sudo nano /etc/nginx/sites-available/praisonai-agent
|
||||
```
|
||||
|
||||
Add the following configuration:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your_domain.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Enable the site and restart Nginx:
|
||||
|
||||
```bash
|
||||
sudo ln -s /etc/nginx/sites-available/praisonai-agent /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Option 2: Deploying with Docker and ECS/Fargate
|
||||
|
||||
<Steps>
|
||||
<Step title="Create a Dockerfile">
|
||||
```dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Run the application
|
||||
CMD ["python", "api.py"]
|
||||
```
|
||||
|
||||
Create a `requirements.txt` file:
|
||||
```
|
||||
praisonaiagents[api]>=0.0.79
|
||||
```
|
||||
|
||||
Create your `api.py` file:
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="""You are a helpful assistant.""", llm="gpt-4o-mini")
|
||||
agent.launch(path="/ask", port=8080, host="0.0.0.0")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Build and Push the Docker Image to ECR">
|
||||
```bash
|
||||
# Create an ECR repository
|
||||
aws ecr create-repository --repository-name praisonai-agent
|
||||
|
||||
# Get the login command
|
||||
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
|
||||
|
||||
# Build the Docker image
|
||||
docker build -t praisonai-agent .
|
||||
|
||||
# Tag the image
|
||||
docker tag praisonai-agent:latest YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/praisonai-agent:latest
|
||||
|
||||
# Push the image to ECR
|
||||
docker push YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/praisonai-agent:latest
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create an ECS Cluster and Task Definition">
|
||||
```bash
|
||||
# Create an ECS cluster
|
||||
aws ecs create-cluster --cluster-name praisonai-cluster
|
||||
|
||||
# Create a task definition (JSON file)
|
||||
cat > task-definition.json << EOF
|
||||
{
|
||||
"family": "praisonai-agent",
|
||||
"networkMode": "awsvpc",
|
||||
"executionRoleArn": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/ecsTaskExecutionRole",
|
||||
"containerDefinitions": [
|
||||
{
|
||||
"name": "praisonai-agent",
|
||||
"image": "YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/praisonai-agent:latest",
|
||||
"essential": true,
|
||||
"portMappings": [
|
||||
{
|
||||
"containerPort": 8080,
|
||||
"hostPort": 8080,
|
||||
"protocol": "tcp"
|
||||
}
|
||||
],
|
||||
"environment": [
|
||||
{
|
||||
"name": "OPENAI_API_KEY",
|
||||
"value": "your_api_key"
|
||||
}
|
||||
],
|
||||
"logConfiguration": {
|
||||
"logDriver": "awslogs",
|
||||
"options": {
|
||||
"awslogs-group": "/ecs/praisonai-agent",
|
||||
"awslogs-region": "us-east-1",
|
||||
"awslogs-stream-prefix": "ecs"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"requiresCompatibilities": [
|
||||
"FARGATE"
|
||||
],
|
||||
"cpu": "256",
|
||||
"memory": "512"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Register the task definition
|
||||
aws ecs register-task-definition --cli-input-json file://task-definition.json
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a Fargate Service">
|
||||
```bash
|
||||
# Create a service
|
||||
aws ecs create-service \
|
||||
--cluster praisonai-cluster \
|
||||
--service-name praisonai-service \
|
||||
--task-definition praisonai-agent:1 \
|
||||
--desired-count 1 \
|
||||
--launch-type FARGATE \
|
||||
--network-configuration "awsvpcConfiguration={subnets=[subnet-12345678],securityGroups=[sg-12345678],assignPublicIp=ENABLED}" \
|
||||
--load-balancers "targetGroupArn=arn:aws:elasticloadbalancing:us-east-1:YOUR_AWS_ACCOUNT_ID:targetgroup/praisonai-tg/1234567890abcdef,containerName=praisonai-agent,containerPort=8080"
|
||||
```
|
||||
|
||||
Note: You'll need to create an Application Load Balancer and target group before running this command.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Multi-Agent Deployment
|
||||
|
||||
For deploying multiple agents, you can use a single service with different endpoints:
|
||||
|
||||
```python
|
||||
# multi-agent-api.py
|
||||
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=8080, host="0.0.0.0")
|
||||
stock_agent.launch(path="/stock", port=8080, host="0.0.0.0")
|
||||
travel_agent.launch(path="/travel", port=8080, host="0.0.0.0")
|
||||
```
|
||||
|
||||
## Option 3: Serverless Deployment with AWS Lambda
|
||||
|
||||
For lightweight agents that don't require long-running processes, you can use AWS Lambda with API Gateway:
|
||||
|
||||
```python
|
||||
# lambda_function.py
|
||||
from praisonaiagents import Agent
|
||||
import json
|
||||
|
||||
# Initialize the agent outside the handler for better cold start performance
|
||||
agent = Agent(instructions="""You are a helpful assistant.""", llm="gpt-4o-mini")
|
||||
|
||||
def lambda_handler(event, context):
|
||||
try:
|
||||
# Extract the message from the event
|
||||
body = json.loads(event.get('body', '{}'))
|
||||
message = body.get('message', '')
|
||||
|
||||
# Process the message with the agent
|
||||
response = agent.process(message)
|
||||
|
||||
# Return the response
|
||||
return {
|
||||
'statusCode': 200,
|
||||
'headers': {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
},
|
||||
'body': json.dumps({
|
||||
'response': response
|
||||
})
|
||||
}
|
||||
except Exception as e:
|
||||
return {
|
||||
'statusCode': 500,
|
||||
'headers': {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
},
|
||||
'body': json.dumps({
|
||||
'error': str(e)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## Scaling and Performance
|
||||
|
||||
### Auto Scaling
|
||||
|
||||
For EC2 deployments, set up an Auto Scaling group:
|
||||
|
||||
```bash
|
||||
# Create a launch template
|
||||
aws ec2 create-launch-template \
|
||||
--launch-template-name praisonai-template \
|
||||
--version-description "Initial version" \
|
||||
--launch-template-data '{"ImageId":"ami-12345678","InstanceType":"t2.medium","UserData":"#!/bin/bash\ncd /home/ubuntu\npython3 api.py &"}'
|
||||
|
||||
# Create an Auto Scaling group
|
||||
aws autoscaling create-auto-scaling-group \
|
||||
--auto-scaling-group-name praisonai-asg \
|
||||
--launch-template "LaunchTemplateName=praisonai-template,Version=1" \
|
||||
--min-size 1 \
|
||||
--max-size 5 \
|
||||
--desired-capacity 2 \
|
||||
--vpc-zone-identifier "subnet-12345678,subnet-87654321" \
|
||||
--target-group-arns "arn:aws:elasticloadbalancing:us-east-1:YOUR_AWS_ACCOUNT_ID:targetgroup/praisonai-tg/1234567890abcdef"
|
||||
```
|
||||
|
||||
### Load Balancing
|
||||
|
||||
Set up an Application Load Balancer to distribute traffic:
|
||||
|
||||
```bash
|
||||
# Create a load balancer
|
||||
aws elbv2 create-load-balancer \
|
||||
--name praisonai-alb \
|
||||
--subnets subnet-12345678 subnet-87654321 \
|
||||
--security-groups sg-12345678
|
||||
|
||||
# Create a target group
|
||||
aws elbv2 create-target-group \
|
||||
--name praisonai-tg \
|
||||
--protocol HTTP \
|
||||
--port 8080 \
|
||||
--vpc-id vpc-12345678 \
|
||||
--target-type instance
|
||||
|
||||
# Create a listener
|
||||
aws elbv2 create-listener \
|
||||
--load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:YOUR_AWS_ACCOUNT_ID:loadbalancer/app/praisonai-alb/1234567890abcdef \
|
||||
--protocol HTTP \
|
||||
--port 80 \
|
||||
--default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:YOUR_AWS_ACCOUNT_ID:targetgroup/praisonai-tg/1234567890abcdef
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
1. **Secret Management**: Use AWS Secrets Manager for API keys
|
||||
```bash
|
||||
# Store a secret
|
||||
aws secretsmanager create-secret \
|
||||
--name OPENAI_API_KEY \
|
||||
--secret-string "your_api_key"
|
||||
```
|
||||
|
||||
2. **IAM Roles**: Use the principle of least privilege
|
||||
3. **VPC**: Deploy in a private subnet with controlled access
|
||||
4. **WAF**: Set up AWS WAF to protect against common web exploits
|
||||
5. **API Gateway**: Implement request validation and throttling
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
1. **CloudWatch**: Set up dashboards and alarms
|
||||
```bash
|
||||
# Create a CloudWatch alarm for high CPU utilization
|
||||
aws cloudwatch put-metric-alarm \
|
||||
--alarm-name praisonai-high-cpu \
|
||||
--alarm-description "Alarm when CPU exceeds 80%" \
|
||||
--metric-name CPUUtilization \
|
||||
--namespace AWS/EC2 \
|
||||
--statistic Average \
|
||||
--period 300 \
|
||||
--threshold 80 \
|
||||
--comparison-operator GreaterThanThreshold \
|
||||
--dimensions Name=AutoScalingGroupName,Value=praisonai-asg \
|
||||
--evaluation-periods 2 \
|
||||
--alarm-actions arn:aws:sns:us-east-1:YOUR_AWS_ACCOUNT_ID:praisonai-alerts
|
||||
```
|
||||
|
||||
2. **X-Ray**: Enable tracing for detailed request analysis
|
||||
3. **CloudTrail**: Monitor API calls for security analysis
|
||||
4. **Log Insights**: Query and analyze logs with CloudWatch Log Insights
|
||||
@@ -0,0 +1,223 @@
|
||||
---
|
||||
title: "Deploying PraisonAI Agents as APIs"
|
||||
sidebarTitle: "API Deployment"
|
||||
description: "Learn how to deploy PraisonAI agents as RESTful APIs for production environments"
|
||||
icon: "server"
|
||||
---
|
||||
|
||||
PraisonAI agents can be easily deployed as RESTful APIs, allowing you to integrate them into various applications and services. This guide covers how to deploy both single and multiple agents as APIs.
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[api]"
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
```bash
|
||||
export OPENAI_API_KEY="your_api_key"
|
||||
```
|
||||
</Step>
|
||||
<Step title="Deploy a Simple Agent API">
|
||||
Create a file named `simple-api.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="""You are a helpful assistant.""", llm="gpt-4o-mini")
|
||||
agent.launch(path="/ask", port=3030)
|
||||
```
|
||||
</Step>
|
||||
<Step title="Run the API Server">
|
||||
```bash
|
||||
python simple-api.py
|
||||
```
|
||||
|
||||
Your API will be available at `http://localhost:3030/ask`
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Making API Requests
|
||||
|
||||
Once your agent is deployed, you can make POST requests to interact with it:
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:3030/ask \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"message": "What is artificial intelligence?"}'
|
||||
```
|
||||
|
||||
The response will be in JSON format:
|
||||
|
||||
```json
|
||||
{
|
||||
"response": "Artificial intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think and learn like humans. It encompasses various technologies including machine learning, natural language processing, computer vision, and robotics. AI systems can perform tasks that typically require human intelligence such as understanding natural language, recognizing patterns, solving problems, and making decisions."
|
||||
}
|
||||
```
|
||||
|
||||
## Multi-Agent API Deployment
|
||||
|
||||
You can deploy multiple agents on the same server, each with its own endpoint:
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
With this setup, you can access:
|
||||
- Weather agent at `http://localhost:3030/weather`
|
||||
- Stock agent at `http://localhost:3030/stock`
|
||||
- Travel agent at `http://localhost:3030/travel`
|
||||
|
||||
## 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", "api.py"]
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create requirements.txt">
|
||||
```
|
||||
praisonaiagents[api]>=0.0.79
|
||||
```
|
||||
</Step>
|
||||
<Step title="Build and Run Docker Container">
|
||||
```bash
|
||||
docker build -t praisonai-api .
|
||||
docker run -p 3030:3030 -e OPENAI_API_KEY=your_api_key praisonai-api
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
### Cloud Deployment
|
||||
|
||||
#### Deploying to AWS
|
||||
|
||||
<Steps>
|
||||
<Step title="Create an EC2 Instance">
|
||||
Launch an EC2 instance with Ubuntu or Amazon Linux.
|
||||
</Step>
|
||||
<Step title="Install Dependencies">
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y python3-pip
|
||||
pip install "praisonaiagents[api]"
|
||||
```
|
||||
</Step>
|
||||
<Step title="Configure Security Group">
|
||||
Make sure to open port 3030 in your security group settings.
|
||||
</Step>
|
||||
<Step title="Run with Systemd">
|
||||
Create a systemd service file for automatic startup and management.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
#### Deploying to Google Cloud Run
|
||||
|
||||
<Steps>
|
||||
<Step title="Build Docker Image">
|
||||
```bash
|
||||
docker build -t gcr.io/your-project/praisonai-api .
|
||||
```
|
||||
</Step>
|
||||
<Step title="Push to Container Registry">
|
||||
```bash
|
||||
docker push gcr.io/your-project/praisonai-api
|
||||
```
|
||||
</Step>
|
||||
<Step title="Deploy to Cloud Run">
|
||||
```bash
|
||||
gcloud run deploy praisonai-api \
|
||||
--image gcr.io/your-project/praisonai-api \
|
||||
--platform managed \
|
||||
--allow-unauthenticated \
|
||||
--set-env-vars="OPENAI_API_KEY=your_api_key"
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## API Configuration Options
|
||||
|
||||
When launching your agent as an API, you can customize various parameters:
|
||||
|
||||
```python
|
||||
agent.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 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
|
||||
|
||||
## Monitoring and Scaling
|
||||
|
||||
For production environments, consider:
|
||||
|
||||
1. **Load Balancing**: Distribute traffic across multiple instances
|
||||
2. **Auto-Scaling**: Automatically adjust resources based on demand
|
||||
3. **Logging**: Implement comprehensive logging for debugging
|
||||
4. **Monitoring**: Set up alerts for errors and performance issues
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="RESTful API" icon="server">
|
||||
Deploy your agents as standard RESTful APIs for easy integration.
|
||||
</Card>
|
||||
<Card title="Multi-Agent Support" icon="users">
|
||||
Deploy multiple agents with different endpoints on the same server.
|
||||
</Card>
|
||||
<Card title="Customizable" icon="gear">
|
||||
Configure ports, paths, CORS settings, and more.
|
||||
</Card>
|
||||
<Card title="Production-Ready" icon="rocket">
|
||||
Easily deploy to Docker, AWS, Google Cloud, or other cloud platforms.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,248 @@
|
||||
---
|
||||
title: "Deploying to Google Cloud"
|
||||
sidebarTitle: "Google Cloud"
|
||||
description: "Deploy PraisonAI agents to Google Cloud Platform for scalable production environments"
|
||||
icon: "google"
|
||||
---
|
||||
|
||||
# Deploying PraisonAI Agents to Google Cloud
|
||||
|
||||
This guide provides step-by-step instructions for deploying PraisonAI agents to Google Cloud Platform using Cloud Run, which offers a serverless environment for containerized applications.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Google Cloud account with billing enabled
|
||||
- Google Cloud SDK installed and configured
|
||||
- Docker installed on your local machine
|
||||
- Basic knowledge of containerization and cloud deployment
|
||||
|
||||
## Deployment Options
|
||||
|
||||
There are several ways to deploy PraisonAI agents to Google Cloud:
|
||||
|
||||
1. **Google Cloud Run** (recommended for most use cases)
|
||||
2. **Google Compute Engine** (for custom VM requirements)
|
||||
3. **Google Kubernetes Engine** (for complex, scalable deployments)
|
||||
|
||||
This guide focuses on Cloud Run as it's the simplest and most cost-effective option for most deployments.
|
||||
|
||||
## Deploying to Google Cloud Run
|
||||
|
||||
<Steps>
|
||||
<Step title="Prepare Your Application">
|
||||
Create a simple API file named `api.py`:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="""You are a helpful assistant.""", llm="gpt-4o-mini")
|
||||
agent.launch(path="/ask", port=8080, host="0.0.0.0")
|
||||
```
|
||||
|
||||
Note: Cloud Run expects your application to listen on the port defined by the `PORT` environment variable, which defaults to 8080.
|
||||
</Step>
|
||||
|
||||
<Step title="Create a Dockerfile">
|
||||
```dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Set environment variables
|
||||
ENV PORT=8080
|
||||
|
||||
# Run the application
|
||||
CMD exec python api.py
|
||||
```
|
||||
|
||||
Create a `requirements.txt` file:
|
||||
```
|
||||
praisonaiagents[api]>=0.0.79
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Build and Push the Docker Image">
|
||||
```bash
|
||||
# Build the Docker image
|
||||
docker build -t gcr.io/YOUR_PROJECT_ID/praisonai-agent .
|
||||
|
||||
# Configure Docker to use Google Cloud credentials
|
||||
gcloud auth configure-docker
|
||||
|
||||
# Push the image to Google Container Registry
|
||||
docker push gcr.io/YOUR_PROJECT_ID/praisonai-agent
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Deploy to Cloud Run">
|
||||
```bash
|
||||
gcloud run deploy praisonai-agent \
|
||||
--image gcr.io/YOUR_PROJECT_ID/praisonai-agent \
|
||||
--platform managed \
|
||||
--region us-central1 \
|
||||
--allow-unauthenticated \
|
||||
--set-env-vars="OPENAI_API_KEY=your_api_key"
|
||||
```
|
||||
|
||||
Note: For production deployments, it's recommended to use Secret Manager for API keys instead of environment variables.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Multi-Agent Deployment
|
||||
|
||||
For deploying multiple agents, you can use a single Cloud Run service with different endpoints:
|
||||
|
||||
```python
|
||||
# multi-agent-api.py
|
||||
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=8080, host="0.0.0.0")
|
||||
stock_agent.launch(path="/stock", port=8080, host="0.0.0.0")
|
||||
travel_agent.launch(path="/travel", port=8080, host="0.0.0.0")
|
||||
```
|
||||
|
||||
## Scaling and Performance
|
||||
|
||||
Google Cloud Run automatically scales based on traffic, from zero to many instances. You can configure:
|
||||
|
||||
- **Minimum instances**: Keep a certain number of instances warm to avoid cold starts
|
||||
- **Maximum instances**: Limit the number of instances to control costs
|
||||
- **Memory allocation**: Allocate more memory for complex agents
|
||||
- **CPU allocation**: Allocate dedicated CPUs for compute-intensive workloads
|
||||
|
||||
```bash
|
||||
gcloud run services update praisonai-agent \
|
||||
--min-instances=1 \
|
||||
--max-instances=10 \
|
||||
--memory=2Gi \
|
||||
--cpu=1
|
||||
```
|
||||
|
||||
## Continuous Deployment
|
||||
|
||||
Set up continuous deployment with Cloud Build:
|
||||
|
||||
```yaml
|
||||
# cloudbuild.yaml
|
||||
steps:
|
||||
# Build the container image
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args: ['build', '-t', 'gcr.io/$PROJECT_ID/praisonai-agent', '.']
|
||||
# Push the container image to Container Registry
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args: ['push', 'gcr.io/$PROJECT_ID/praisonai-agent']
|
||||
# Deploy container image to Cloud Run
|
||||
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
|
||||
entrypoint: gcloud
|
||||
args:
|
||||
- 'run'
|
||||
- 'deploy'
|
||||
- 'praisonai-agent'
|
||||
- '--image'
|
||||
- 'gcr.io/$PROJECT_ID/praisonai-agent'
|
||||
- '--region'
|
||||
- 'us-central1'
|
||||
- '--platform'
|
||||
- 'managed'
|
||||
- '--allow-unauthenticated'
|
||||
substitutions:
|
||||
_REGION: us-central1
|
||||
images:
|
||||
- 'gcr.io/$PROJECT_ID/praisonai-agent'
|
||||
```
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
Google Cloud provides comprehensive monitoring and logging capabilities:
|
||||
|
||||
- **Cloud Monitoring**: Set up dashboards and alerts for your deployed agents
|
||||
- **Cloud Logging**: View and analyze logs from your applications
|
||||
- **Error Reporting**: Automatically detect and group errors
|
||||
|
||||
Access logs through the Google Cloud Console or using the gcloud command:
|
||||
|
||||
```bash
|
||||
gcloud logging read "resource.type=cloud_run_revision AND resource.labels.service_name=praisonai-agent" --limit=10
|
||||
```
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
Cloud Run charges based on the resources your service uses only when it's processing requests. To optimize costs:
|
||||
|
||||
1. Set appropriate memory and CPU allocations
|
||||
2. Configure minimum instances based on traffic patterns
|
||||
3. Use regional deployments closest to your users
|
||||
4. Implement caching for frequent requests
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
1. **Secret Management**: Store API keys and credentials in Secret Manager
|
||||
```bash
|
||||
# Create a secret
|
||||
echo -n "your_api_key" | gcloud secrets create openai-api-key --data-file=-
|
||||
|
||||
# Grant access to the Cloud Run service
|
||||
gcloud secrets add-iam-policy-binding openai-api-key \
|
||||
--member=serviceAccount:YOUR_SERVICE_ACCOUNT \
|
||||
--role=roles/secretmanager.secretAccessor
|
||||
|
||||
# Reference in deployment
|
||||
gcloud run deploy praisonai-agent \
|
||||
--image gcr.io/YOUR_PROJECT_ID/praisonai-agent \
|
||||
--set-secrets=OPENAI_API_KEY=openai-api-key:latest
|
||||
```
|
||||
|
||||
2. **Service Identity**: Use dedicated service accounts with minimal permissions
|
||||
3. **Network Security**: Configure VPC Service Controls for sensitive deployments
|
||||
4. **API Authentication**: Implement authentication for your API endpoints
|
||||
|
||||
## All in One
|
||||
|
||||
```bash
|
||||
gcloud init
|
||||
gcloud services enable run.googleapis.com
|
||||
gcloud services enable containerregistry.googleapis.com
|
||||
gcloud services enable cloudbuild.googleapis.com
|
||||
|
||||
export OPENAI_MODEL_NAME="gpt-4o"
|
||||
export OPENAI_API_KEY="Enter your API key"
|
||||
export OPENAI_API_BASE="https://api.openai.com/v1"
|
||||
|
||||
yes | gcloud auth configure-docker us-central1-docker.pkg.dev
|
||||
gcloud artifacts repositories create praisonai-repository --repository-format=docker --location=us-central1
|
||||
|
||||
PROJECT_ID=$(gcloud config get-value project)
|
||||
TAG="latest"
|
||||
docker build --platform linux/amd64 -t gcr.io/${PROJECT_ID}/praisonai-app:${TAG} .
|
||||
docker tag gcr.io/${PROJECT_ID}/praisonai-app:${TAG} us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG}
|
||||
docker push us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG}
|
||||
|
||||
gcloud run deploy praisonai-service \
|
||||
--image us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG} \
|
||||
--platform managed \
|
||||
--region us-central1 \
|
||||
--allow-unauthenticated \
|
||||
--set-env-vars OPENAI_MODEL_NAME=${OPENAI_MODEL_NAME},OPENAI_API_KEY=${OPENAI_API_KEY},OPENAI_API_BASE=${OPENAI_API_BASE}
|
||||
```
|
||||
@@ -0,0 +1,405 @@
|
||||
---
|
||||
title: "Deploying MCP Servers"
|
||||
sidebarTitle: "MCP Servers"
|
||||
description: "Learn how to deploy Model Context Protocol (MCP) servers for production environments"
|
||||
icon: "server-rack"
|
||||
---
|
||||
|
||||
# Deploying MCP Servers
|
||||
|
||||
This guide focuses on deploying Model Context Protocol (MCP) servers for production environments. MCP servers allow AI models to access tools and external systems through a standardized protocol.
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[mcp]"
|
||||
```
|
||||
|
||||
For the multi-agent example with search capabilities:
|
||||
```bash
|
||||
pip install "praisonaiagents[mcp]" duckduckgo-search
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create MCP Server Files">
|
||||
**Single Agent MCP Server**
|
||||
|
||||
Create a file named `simple-mcp-server.py`:
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="Create a Tweet based on the topic provided")
|
||||
agent.launch(port=8080, host="0.0.0.0", protocol="mcp")
|
||||
```
|
||||
|
||||
**Multi-Agent MCP Server with Custom Tools**
|
||||
|
||||
Create a file named `simple-mcp-multi-agents-server.py`:
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents
|
||||
from duckduckgo_search import DDGS
|
||||
|
||||
def internet_search_tool(query: str):
|
||||
results = []
|
||||
ddgs = DDGS()
|
||||
for result in ddgs.text(keywords=query, max_results=5):
|
||||
results.append({
|
||||
"title": result.get("title", ""),
|
||||
"url": result.get("href", ""),
|
||||
"snippet": result.get("body", "")
|
||||
})
|
||||
return results
|
||||
|
||||
agent = Agent(instructions="You Search the internet for information", tools=[internet_search_tool])
|
||||
agent2 = Agent(instructions="You Summarise the information")
|
||||
|
||||
agents = Agents(agents=[agent, agent2])
|
||||
agents.launch(port=8080, host="0.0.0.0", protocol="mcp")
|
||||
```
|
||||
|
||||
**Simple Multi-Agent MCP Server**
|
||||
|
||||
Create a file named `simple-multi-agents-server.py`:
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents
|
||||
|
||||
agent = Agent(instructions="You Search the internet for information")
|
||||
agent2 = Agent(instructions="You Summarise the information")
|
||||
|
||||
agents = Agents(agents=[agent, agent2])
|
||||
agents.launch(port=8080, host="0.0.0.0", protocol="mcp")
|
||||
```
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents
|
||||
from duckduckgo_search import DDGS
|
||||
|
||||
def internet_search_tool(query: str):
|
||||
results = []
|
||||
ddgs = DDGS()
|
||||
for result in ddgs.text(keywords=query, max_results=5):
|
||||
results.append({
|
||||
"title": result.get("title", ""),
|
||||
"url": result.get("href", ""),
|
||||
"snippet": result.get("body", "")
|
||||
})
|
||||
return results
|
||||
|
||||
agent = Agent(instructions="You Search the internet for information", tools=[internet_search_tool])
|
||||
agent2 = Agent(instructions="You Summarise the information")
|
||||
|
||||
agents = Agents(agents=[agent, agent2])
|
||||
agents.launch(port=8080, host="0.0.0.0", protocol="mcp")
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Containerization with Docker
|
||||
|
||||
<Steps>
|
||||
<Step title="Create a Dockerfile">
|
||||
```dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the MCP server
|
||||
CMD ["python", "simple-mcp-server.py"]
|
||||
```
|
||||
|
||||
Create a `requirements.txt` file:
|
||||
```
|
||||
praisonaiagents[mcp]
|
||||
duckduckgo-search # Only needed for the multi-agent example
|
||||
```
|
||||
</Step>
|
||||
<Step title="Build and Run the Docker Container">
|
||||
```bash
|
||||
# Build the Docker image
|
||||
docker build -t mcp-server .
|
||||
|
||||
# Run the container
|
||||
docker run -p 8080:8080 -e OPENAI_API_KEY=your_api_key mcp-server
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Cloud Deployment
|
||||
|
||||
### AWS Elastic Container Service (ECS)
|
||||
|
||||
<Steps>
|
||||
<Step title="Push Docker Image to ECR">
|
||||
```bash
|
||||
# Create an ECR repository
|
||||
aws ecr create-repository --repository-name mcp-server
|
||||
|
||||
# Authenticate Docker to ECR
|
||||
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
|
||||
|
||||
# Tag and push the image
|
||||
docker tag mcp-server:latest YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mcp-server:latest
|
||||
docker push YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mcp-server:latest
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create ECS Task Definition">
|
||||
```json
|
||||
{
|
||||
"family": "mcp-server",
|
||||
"networkMode": "awsvpc",
|
||||
"executionRoleArn": "arn:aws:iam::YOUR_AWS_ACCOUNT_ID:role/ecsTaskExecutionRole",
|
||||
"containerDefinitions": [
|
||||
{
|
||||
"name": "mcp-server",
|
||||
"image": "YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mcp-server:latest",
|
||||
"essential": true,
|
||||
"portMappings": [
|
||||
{
|
||||
"containerPort": 8080,
|
||||
"hostPort": 8080,
|
||||
"protocol": "tcp"
|
||||
}
|
||||
],
|
||||
"environment": [
|
||||
{
|
||||
"name": "OPENAI_API_KEY",
|
||||
"value": "your_api_key"
|
||||
}
|
||||
],
|
||||
"logConfiguration": {
|
||||
"logDriver": "awslogs",
|
||||
"options": {
|
||||
"awslogs-group": "/ecs/mcp-server",
|
||||
"awslogs-region": "us-east-1",
|
||||
"awslogs-stream-prefix": "ecs"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"requiresCompatibilities": [
|
||||
"FARGATE"
|
||||
],
|
||||
"cpu": "256",
|
||||
"memory": "512"
|
||||
}
|
||||
```
|
||||
</Step>
|
||||
<Step title="Deploy to ECS">
|
||||
```bash
|
||||
# Create a service
|
||||
aws ecs create-service \
|
||||
--cluster your-cluster \
|
||||
--service-name mcp-server \
|
||||
--task-definition mcp-server:1 \
|
||||
--desired-count 1 \
|
||||
--launch-type FARGATE \
|
||||
--network-configuration "awsvpcConfiguration={subnets=[subnet-12345678],securityGroups=[sg-12345678],assignPublicIp=ENABLED}" \
|
||||
--load-balancers "targetGroupArn=arn:aws:elasticloadbalancing:us-east-1:YOUR_AWS_ACCOUNT_ID:targetgroup/mcp-server-tg/1234567890abcdef,containerName=mcp-server,containerPort=8080"
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
### Google Cloud Run
|
||||
|
||||
<Steps>
|
||||
<Step title="Push Docker Image to Google Container Registry">
|
||||
```bash
|
||||
# Configure Docker to use Google Cloud credentials
|
||||
gcloud auth configure-docker
|
||||
|
||||
# Build and tag the image
|
||||
docker build -t gcr.io/YOUR_PROJECT_ID/mcp-server .
|
||||
|
||||
# Push the image
|
||||
docker push gcr.io/YOUR_PROJECT_ID/mcp-server
|
||||
```
|
||||
</Step>
|
||||
<Step title="Deploy to Cloud Run">
|
||||
```bash
|
||||
gcloud run deploy mcp-server \
|
||||
--image gcr.io/YOUR_PROJECT_ID/mcp-server \
|
||||
--platform managed \
|
||||
--region us-central1 \
|
||||
--allow-unauthenticated \
|
||||
--set-env-vars="OPENAI_API_KEY=your_api_key"
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Production Configuration
|
||||
|
||||
### Security
|
||||
|
||||
For production deployments, implement these security measures:
|
||||
|
||||
1. **API Key Authentication**:
|
||||
```python
|
||||
agent.launch(port=8080, host="0.0.0.0", protocol="mcp", api_key="your-secret-key")
|
||||
```
|
||||
|
||||
2. **HTTPS with SSL/TLS**:
|
||||
Set up a reverse proxy like Nginx with SSL certificates:
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name your-mcp-server.com;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. **Secret Management**:
|
||||
Use environment variables or a secrets manager for API keys:
|
||||
```bash
|
||||
# AWS Secrets Manager
|
||||
aws secretsmanager create-secret \
|
||||
--name OPENAI_API_KEY \
|
||||
--secret-string "your_api_key"
|
||||
|
||||
# Google Secret Manager
|
||||
echo -n "your_api_key" | gcloud secrets create openai-api-key --data-file=-
|
||||
```
|
||||
|
||||
### Scaling
|
||||
|
||||
For high-traffic MCP servers, consider these scaling strategies:
|
||||
|
||||
1. **Load Balancing**:
|
||||
Deploy multiple instances behind a load balancer.
|
||||
|
||||
2. **Auto Scaling**:
|
||||
Configure auto-scaling based on CPU/memory usage or request count.
|
||||
|
||||
3. **Resource Allocation**:
|
||||
Allocate sufficient CPU and memory for your MCP servers:
|
||||
```bash
|
||||
# AWS ECS
|
||||
aws ecs update-service \
|
||||
--cluster your-cluster \
|
||||
--service mcp-server \
|
||||
--desired-count 3
|
||||
|
||||
# Google Cloud Run
|
||||
gcloud run services update mcp-server \
|
||||
--min-instances=2 \
|
||||
--max-instances=10 \
|
||||
--memory=2Gi \
|
||||
--cpu=1
|
||||
```
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
Set up comprehensive monitoring for your MCP servers:
|
||||
|
||||
1. **Application Logging**:
|
||||
```python
|
||||
import logging
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler("mcp-server.log"),
|
||||
logging.StreamHandler()
|
||||
]
|
||||
)
|
||||
|
||||
logger = logging.getLogger("mcp-server")
|
||||
```
|
||||
|
||||
2. **Health Checks**:
|
||||
Create a health check endpoint:
|
||||
```python
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/health')
|
||||
def health_check():
|
||||
return {"status": "healthy"}, 200
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=8081)
|
||||
```
|
||||
|
||||
3. **Metrics Collection**:
|
||||
Use Prometheus or similar tools to collect metrics.
|
||||
|
||||
## Testing MCP Servers
|
||||
|
||||
Before deploying to production, thoroughly test your MCP server:
|
||||
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
def test_mcp_server():
|
||||
url = "http://localhost:8080/v1/chat/completions"
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
data = {
|
||||
"messages": [
|
||||
{"role": "user", "content": "Create a tweet about artificial intelligence"}
|
||||
]
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, data=json.dumps(data))
|
||||
|
||||
print(f"Status Code: {response.status_code}")
|
||||
print(f"Response: {response.json()}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_mcp_server()
|
||||
```
|
||||
|
||||
## Deployment Checklist
|
||||
|
||||
Before going live with your MCP server, ensure you've addressed these items:
|
||||
|
||||
- [ ] Implemented proper authentication
|
||||
- [ ] Set up HTTPS with valid SSL certificates
|
||||
- [ ] Configured proper logging and monitoring
|
||||
- [ ] Tested the server under load
|
||||
- [ ] Implemented rate limiting
|
||||
- [ ] Secured all API keys and credentials
|
||||
- [ ] Set up automated backups
|
||||
- [ ] Created a disaster recovery plan
|
||||
- [ ] Documented the deployment process
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Containerized Deployment" icon="docker">
|
||||
Package your MCP servers in Docker containers for consistent deployment.
|
||||
</Card>
|
||||
<Card title="Cloud-Ready" icon="cloud">
|
||||
Deploy to AWS, Google Cloud, or other cloud providers with ease.
|
||||
</Card>
|
||||
<Card title="Scalable Architecture" icon="server">
|
||||
Scale your MCP servers to handle production workloads.
|
||||
</Card>
|
||||
<Card title="Security-Focused" icon="shield">
|
||||
Implement best practices for secure MCP server deployments.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -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>
|
||||
@@ -27,7 +27,7 @@ WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN pip install flask praisonai==2.0.18 watchdog
|
||||
RUN pip install flask praisonai==2.2.2 watchdog
|
||||
|
||||
EXPOSE 5555
|
||||
|
||||
|
||||
@@ -65,14 +65,14 @@ def basic(): # Basic Mode
|
||||
def advanced(): # Advanced Mode with options
|
||||
praisonai = PraisonAI(
|
||||
agent_file="agents.yaml",
|
||||
framework="autogen",
|
||||
framework="autogen", # use AG2 framework (Formerly AutoGen)
|
||||
)
|
||||
praisonai.run()
|
||||
|
||||
def auto(): # Full Automatic Mode
|
||||
praisonai = PraisonAI(
|
||||
auto="Create a movie script about car in mars",
|
||||
framework="autogen"
|
||||
framework="autogen" # use AG2 framework
|
||||
)
|
||||
print(praisonai.framework)
|
||||
praisonai.run()
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
---
|
||||
title: "AutoGen with PraisonAI"
|
||||
description: "Guide for using AutoGen framework with PraisonAI, including installation, setup, and multi-agent conversation capabilities"
|
||||
title: "AG2 with PraisonAI"
|
||||
description: "Guide for using AG2 framework with PraisonAI, including installation, setup, and multi-agent conversation capabilities"
|
||||
icon: "robot"
|
||||
---
|
||||
|
||||
# AutoGen with PraisonAI
|
||||
# AG2 with PraisonAI
|
||||
|
||||
Low-code solution to run AutoGen with integrated tools and features.
|
||||
Low-code solution to run AG2 with integrated tools and features.
|
||||
AutoGen is being evolved into AG2, check the new look [here](https://docs.ag2.ai/docs/Home/)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -16,7 +17,7 @@ pip install "praisonai[autogen]"
|
||||
```
|
||||
|
||||
This installation includes:
|
||||
- AutoGen framework
|
||||
- AG2 framework
|
||||
- PraisonAI tools integration
|
||||
- Multi-agent conversation capabilities
|
||||
- Code execution environment
|
||||
@@ -27,7 +28,7 @@ This installation includes:
|
||||
# Set your OpenAI API key
|
||||
export OPENAI_API_KEY=xxxxxxxxxx
|
||||
|
||||
# Initialize with AutoGen
|
||||
# Initialize with AG2
|
||||
praisonai --framework autogen --init "Create a Movie Script About Cat in Mars"
|
||||
|
||||
# Run the agents
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "Praison AI"
|
||||
sidebarTitle: "Home"
|
||||
description: "Comprehensive guide to PraisonAI - an AI Agents Framework with Self Reflection, combining PraisonAI Agents, AutoGen, and CrewAI for building multi-agent LLM systems"
|
||||
description: "Comprehensive guide to PraisonAI - an AI Agents Framework with Self Reflection, combining PraisonAI Agents, AG2 (Formerly AutoGen), and CrewAI for building multi-agent LLM systems"
|
||||
icon: "house"
|
||||
openGraph:
|
||||
url: "/"
|
||||
@@ -46,7 +46,7 @@ seo:
|
||||
</div>
|
||||
|
||||
<Tip>
|
||||
PraisonAI combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration.
|
||||
PraisonAI combines PraisonAI Agents, AG2 (Formerly AutoGen), and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration.
|
||||
</Tip>
|
||||
|
||||
## Key Features
|
||||
@@ -56,7 +56,7 @@ seo:
|
||||
Automated creation and management of AI agents with self-reflection capabilities
|
||||
</Card>
|
||||
<Card title="Framework Integration" icon="puzzle-piece">
|
||||
Seamless integration with CrewAI and AutoGen frameworks
|
||||
Seamless integration with CrewAI and AG2 frameworks
|
||||
</Card>
|
||||
<Card title="LLM Support" icon="brain">
|
||||
Support for 100+ Language Learning Models
|
||||
@@ -301,8 +301,8 @@ seo:
|
||||
<Card title="CrewAI Framework" icon="users-gear" href="/framework/crewai">
|
||||
Build collaborative AI teams with CrewAI integration
|
||||
</Card>
|
||||
<Card title="AutoGen Framework" icon="robot" href="/framework/autogen">
|
||||
Create autonomous agent networks using AutoGen
|
||||
<Card title="AG2 Framework" icon="robot" href="/framework/autogen">
|
||||
Create autonomous agent networks using AG2 (Formerly AutoGen)
|
||||
</Card>
|
||||
<Card title="Multimodal Agents" icon="icons" href="/framework/multimodalagents">
|
||||
Work with agents that can process text, images, and other data types
|
||||
@@ -316,7 +316,7 @@ seo:
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Multi Agents UI" icon="users" href="/ui/ui">
|
||||
Work with CrewAI or AutoGen multi-agent systems
|
||||
Work with CrewAI or AG2 multi-agent systems
|
||||
</Card>
|
||||
<Card title="Chat Interface" icon="comments" href="/ui/chat">
|
||||
Chat with 100+ LLMs using a single AI Agent
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "Praison AI"
|
||||
sidebarTitle: "Home"
|
||||
description: "PraisonAI is a production-ready Multi-AI Agents framework with self-reflection, designed to create AI Agents to automate and solve problems ranging from simple tasks to complex challenges. By integrating PraisonAI Agents, AutoGen, and CrewAI into a low-code solution, it streamlines the building and management of multi-agent LLM systems, emphasising simplicity, customisation, and effective human-agent collaboration."
|
||||
description: "PraisonAI is a production-ready Multi-AI Agents framework with self-reflection, designed to create AI Agents to automate and solve problems ranging from simple tasks to complex challenges. By integrating PraisonAI Agents, AG2 (Formerly AutoGen), and CrewAI into a low-code solution, it streamlines the building and management of multi-agent LLM systems, emphasising simplicity, customisation, and effective human-agent collaboration."
|
||||
icon: "house"
|
||||
openGraph:
|
||||
url: "/"
|
||||
@@ -45,7 +45,7 @@ seo:
|
||||
Automated creation and management of AI agents with self-reflection capabilities
|
||||
</Card>
|
||||
<Card title="Framework Integration" icon="puzzle-piece">
|
||||
Seamless integration with CrewAI and AutoGen frameworks
|
||||
Seamless integration with CrewAI and AG2 frameworks
|
||||
</Card>
|
||||
<Card title="LLM Support" icon="brain">
|
||||
Support for 100+ Language Learning Models
|
||||
@@ -711,8 +711,8 @@ flowchart LR
|
||||
<Card title="CrewAI Framework" icon="users-gear" href="/framework/crewai">
|
||||
Build collaborative AI teams with CrewAI integration
|
||||
</Card>
|
||||
<Card title="AutoGen Framework" icon="robot" href="/framework/autogen">
|
||||
Create autonomous agent networks using AutoGen
|
||||
<Card title="AG2 Framework" icon="robot" href="/framework/autogen">
|
||||
Create autonomous agent networks using AG2 (Formerly AutoGen)
|
||||
</Card>
|
||||
<Card title="Multimodal Agents" icon="icons" href="/framework/multimodalagents">
|
||||
Work with agents that can process text, images, and other data types
|
||||
@@ -726,7 +726,7 @@ flowchart LR
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Multi Agents UI" icon="users" href="/ui/ui">
|
||||
Work with CrewAI or AutoGen multi-agent systems
|
||||
Work with CrewAI or AG2 multi-agent systems
|
||||
</Card>
|
||||
<Card title="Chat Interface" icon="comments" href="/ui/chat">
|
||||
Chat with 100+ LLMs using a single AI Agent
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
---
|
||||
title: "Airbnb MCP Integration"
|
||||
sidebarTitle: "Airbnb"
|
||||
description: "Guide for integrating Airbnb booking capabilities with PraisonAI agents using MCP"
|
||||
icon: "airbnb"
|
||||
---
|
||||
|
||||
## Add Airbnb Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `airbnb_search.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("I want to book an apartment in Paris for 2 nights. 03/28 - 03/30 for 2 adults")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python airbnb_search.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
|
||||
## Gradio UI
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import gradio as gr
|
||||
|
||||
def search_airbnb(query):
|
||||
agent = Agent(
|
||||
instructions="You help book apartments on Airbnb.",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
result = agent.start(query)
|
||||
return f"## Airbnb Search Results\n\n{result}"
|
||||
|
||||
demo = gr.Interface(
|
||||
fn=search_airbnb,
|
||||
inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
|
||||
outputs=gr.Markdown(),
|
||||
title="Airbnb Booking Assistant",
|
||||
description="Enter your booking requirements below:"
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Accommodation Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Booking Details" icon="calendar">
|
||||
Specify dates, guests, and location preferences in natural language.
|
||||
</Card>
|
||||
<Card title="NPM Package" icon="js">
|
||||
Leverages the official Airbnb MCP server package.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
title: "Anthropic MCP Integration"
|
||||
sidebarTitle: "Anthropic"
|
||||
description: "Guide for integrating Anthropic's Claude models with PraisonAI agents using MCP"
|
||||
icon: "a"
|
||||
---
|
||||
|
||||
## Add Anthropic Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your Anthropic API key as an environment variable in your terminal:
|
||||
```zsh
|
||||
export ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `anthropic_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get API key from environment variable
|
||||
anthropic_api_key = os.environ.get("ANTHROPIC_API_KEY")
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="anthropic/claude-3-7-sonnet-20250219",
|
||||
tools=MCP(
|
||||
command="npx",
|
||||
args=["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"],
|
||||
env={"ANTHROPIC_API_KEY": anthropic_api_key}
|
||||
)
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python anthropic_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Anthropic API key
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Claude 3.7 Sonnet" icon="brain">
|
||||
Leverage Anthropic's powerful Claude 3.7 Sonnet model.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Environment Variables" icon="key">
|
||||
Securely pass API keys using environment variables.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
title: "AWS KB Retrieval MCP Integration"
|
||||
sidebarTitle: "AWS KB Retrieval"
|
||||
description: "Guide for integrating AWS Knowledge Base retrieval capabilities with PraisonAI agents using MCP"
|
||||
icon: "aws"
|
||||
---
|
||||
|
||||
## Add AWS KB Retrieval Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[AWS KB Retrieval MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF9900,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Keys">
|
||||
Set your AWS credentials as environment variables in your terminal:
|
||||
```bash
|
||||
export AWS_ACCESS_KEY_ID=your_aws_access_key_id_here
|
||||
export AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key_here
|
||||
export AWS_REGION=your_aws_region_here
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `aws_kb_retrieval.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get AWS credentials from environment
|
||||
aws_access_key = os.getenv("AWS_ACCESS_KEY_ID")
|
||||
aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY")
|
||||
aws_region = os.getenv("AWS_REGION")
|
||||
|
||||
# Use a single string command with AWS KB Retrieval configuration
|
||||
aws_kb_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with AWS Knowledge Base.
|
||||
Use the available tools when relevant to retrieve and process AWS information.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-aws-kb-retrieval",
|
||||
env={
|
||||
"AWS_ACCESS_KEY_ID": aws_access_key,
|
||||
"AWS_SECRET_ACCESS_KEY": aws_secret_key,
|
||||
"AWS_REGION": aws_region
|
||||
})
|
||||
)
|
||||
|
||||
aws_kb_agent.start("Search AWS documentation about EC2 instances")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python aws_kb_retrieval.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- AWS credentials (Access Key ID, Secret Access Key, and Region)
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
title: "Brave Search MCP Integration"
|
||||
sidebarTitle: "Brave Search"
|
||||
description: "Guide for integrating Brave Search capabilities with PraisonAI agents using MCP"
|
||||
icon: "searchengin"
|
||||
---
|
||||
|
||||
## Add Brave Search Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Brave Search MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#4169E1,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your Brave Search API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export BRAVE_API_KEY=your_brave_api_key_here
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
|
||||
You can obtain a Brave Search API key from [Brave Search API](https://brave.com/search/api/).
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `brave_search.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use the API key from environment or set it directly
|
||||
brave_api_key = os.getenv("BRAVE_API_KEY") or "your_brave_api_key_here"
|
||||
|
||||
# Use a single string command with environment variables
|
||||
search_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can search the web for information.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-brave-search", env={"BRAVE_API_KEY": brave_api_key})
|
||||
)
|
||||
|
||||
search_agent.start("Search more information about AI News")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python brave_search.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Brave Search API key
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,103 @@
|
||||
---
|
||||
title: "Custom Python MCP Client"
|
||||
sidebarTitle: "Custom Python Client"
|
||||
description: "Guide for creating a client to interact with a custom Python MCP server"
|
||||
icon: "person-digging"
|
||||
---
|
||||
|
||||
## Custom Python MCP Client
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Client[Python MCP Client]
|
||||
Client --> Server[Python MCP Server]
|
||||
Server --> Client
|
||||
Client --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Client fill:#3776AB,color:#fff
|
||||
style Server fill:#3776AB,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Overview
|
||||
|
||||
The Custom Python MCP Client demonstrates how to integrate a custom Python MCP server with a PraisonAI agent. This client connects to a stock price MCP server to retrieve real-time stock information.
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Install the required packages:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set Up the Server">
|
||||
First, set up the Custom Python MCP Server.
|
||||
</Step>
|
||||
<Step title="Create Custom Python Client">
|
||||
Save the code above to a file named `custom-python-client.py`.
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
agent = Agent(
|
||||
instructions="""You are a helpful assistant that can check stock prices and perform other tasks.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools = MCP("/Users/praison/miniconda3/envs/mcp/bin/python /Users/praison/stockprice/custom-python-server.py")
|
||||
)
|
||||
|
||||
# NOTE: Python Path replace with yours: /Users/praison/miniconda3/envs/mcp/bin/python
|
||||
# NOTE: custom-python-server.py file path, replace it with yours: /Users/praison/stockprice/custom-python-server.py
|
||||
|
||||
agent.start("What is the stock price of Tesla?")
|
||||
```
|
||||
</Step>
|
||||
<Step title="Run the Client">
|
||||
Execute the client script:
|
||||
```bash
|
||||
python custom-python-client.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- praisonaiagents and mcp packages
|
||||
- A properly configured custom Python MCP server
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
|
||||
## Environment Variables
|
||||
|
||||
For better security and flexibility, you can modify the client to use environment variables:
|
||||
|
||||
```python
|
||||
import os
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
# Get paths from environment variables or use defaults
|
||||
python_path = os.getenv("PYTHON_PATH", "/path/to/python")
|
||||
server_path = os.getenv("SERVER_PATH", "/path/to/server.py")
|
||||
|
||||
agent = Agent(
|
||||
instructions="""You are a helpful assistant that can check stock prices and perform other tasks.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP(f"{python_path} {server_path}")
|
||||
)
|
||||
|
||||
agent.start("What is the stock price of Tesla?")
|
||||
```
|
||||
|
||||
This approach allows you to set the paths using environment variables:
|
||||
|
||||
```bash
|
||||
export PYTHON_PATH=/Users/praison/miniconda3/envs/mcp/bin/python
|
||||
export SERVER_PATH=/Users/praison/stockprice/app.py
|
||||
```
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
title: "Custom Python MCP Server"
|
||||
sidebarTitle: "Custom Python Server"
|
||||
description: "Guide for creating a custom Python MCP server for stock price retrieval"
|
||||
icon: "server"
|
||||
---
|
||||
|
||||
## Custom Python MCP Server
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Client[Python MCP Client]
|
||||
Client --> Server[Python MCP Server]
|
||||
Server --> Client
|
||||
Client --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Client fill:#3776AB,color:#fff
|
||||
style Server fill:#3776AB,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Overview
|
||||
|
||||
The Custom Python MCP Server is a simple implementation of the Model Context Protocol (MCP) that provides stock price information using the yfinance library. This server can be used with PraisonAI agents to retrieve real-time stock prices.
|
||||
|
||||
## Server Implementation
|
||||
|
||||
Below is the complete implementation of the custom Python MCP server:
|
||||
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Install the required packages:
|
||||
```bash
|
||||
pip install yfinance mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Save the Server Code">
|
||||
Save the code above to a file named `custom-python-server.py`.
|
||||
```python
|
||||
import yfinance as yf
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("stock_prices")
|
||||
|
||||
@mcp.tool()
|
||||
async def get_stock_price(ticker: str) -> str:
|
||||
"""Get the current stock price for a given ticker symbol.
|
||||
|
||||
Args:
|
||||
ticker: Stock ticker symbol (e.g., AAPL, MSFT, GOOG)
|
||||
|
||||
Returns:
|
||||
Current stock price as a string
|
||||
"""
|
||||
if not ticker:
|
||||
return "No ticker provided"
|
||||
try:
|
||||
stock = yf.Ticker(ticker)
|
||||
info = stock.info
|
||||
current_price = info.get('currentPrice') or info.get('regularMarketPrice')
|
||||
if not current_price:
|
||||
return f"Could not retrieve price for {ticker}"
|
||||
return f"${current_price:.2f}"
|
||||
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport='stdio')
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- yfinance package
|
||||
- mcp package
|
||||
</Note>
|
||||
@@ -0,0 +1,168 @@
|
||||
---
|
||||
title: "Custom Python MCP Server"
|
||||
sidebarTitle: "Custom Python MCP"
|
||||
description: "Guide for creating and using custom Python MCP servers with PraisonAI agents"
|
||||
icon: "python"
|
||||
---
|
||||
|
||||
# Custom Python MCP Server
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Custom Python MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#3776AB,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Create MCP Server">
|
||||
Create a new file `app.py` with your custom MCP server implementation:
|
||||
```python
|
||||
import yfinance as yf
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("stock_prices")
|
||||
|
||||
@mcp.tool()
|
||||
async def get_stock_price(ticker: str) -> str:
|
||||
"""Get the current stock price for a given ticker symbol.
|
||||
|
||||
Args:
|
||||
ticker: Stock ticker symbol (e.g., AAPL, MSFT, GOOG)
|
||||
|
||||
Returns:
|
||||
Current stock price as a string
|
||||
"""
|
||||
if not ticker:
|
||||
return "No ticker provided"
|
||||
try:
|
||||
stock = yf.Ticker(ticker)
|
||||
info = stock.info
|
||||
current_price = info.get('currentPrice') or info.get('regularMarketPrice')
|
||||
if not current_price:
|
||||
return f"Could not retrieve price for {ticker}"
|
||||
return f"${current_price:.2f}"
|
||||
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport='stdio')
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Install the required dependencies in a conda environment:
|
||||
```bash
|
||||
pip install yfinance mcp
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create Agent Integration">
|
||||
Create a new file `stock_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
agent = Agent(
|
||||
instructions="""You are a helpful assistant that can check stock prices and perform other tasks.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools = MCP("/path/to/python /path/to/app.py")
|
||||
)
|
||||
|
||||
# NOTE: Replace with your actual Python path and app.py file path
|
||||
|
||||
agent.start("What is the stock price of Tesla?")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python stock_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Conda for environment management
|
||||
- yfinance package for stock data
|
||||
- mcp-python-sdk for MCP server implementation
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Custom Tools" icon="wrench">
|
||||
Create your own custom tools with Python.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Type Hints" icon="code">
|
||||
Strong typing for better code reliability.
|
||||
</Card>
|
||||
<Card title="Async Support" icon="bolt">
|
||||
Built-in support for asynchronous functions.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### FastMCP Class
|
||||
|
||||
The `FastMCP` class from the `mcp-python-sdk` package provides a simple way to create MCP servers in Python:
|
||||
|
||||
```python
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
# Create an MCP server with a name
|
||||
mcp = FastMCP("my_tools")
|
||||
|
||||
# Define a tool using the @mcp.tool decorator
|
||||
@mcp.tool()
|
||||
async def my_tool(param1: str, param2: int) -> str:
|
||||
"""Tool description with clear documentation.
|
||||
|
||||
Args:
|
||||
param1: Description of param1
|
||||
param2: Description of param2
|
||||
|
||||
Returns:
|
||||
Description of the return value
|
||||
"""
|
||||
# Tool implementation
|
||||
return f"Processed {param1} with {param2}"
|
||||
|
||||
# Run the server with stdio transport
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport='stdio')
|
||||
```
|
||||
|
||||
### Agent Integration
|
||||
|
||||
To use your custom MCP server with PraisonAI agents, use the `MCP` class to specify the command to run your Python script:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
agent = Agent(
|
||||
instructions="Agent instructions",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP(
|
||||
command="python", # Or full path to Python
|
||||
args=["path/to/your/mcp_server.py"] # Path to your MCP server script
|
||||
)
|
||||
)
|
||||
```
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
title: "Everart MCP Integration"
|
||||
sidebarTitle: "Everart"
|
||||
description: "Guide for integrating Everart AI art generation capabilities with PraisonAI agents using MCP"
|
||||
icon: "palette"
|
||||
---
|
||||
|
||||
## Add Everart Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Everart MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF6B6B,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your Everart API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export EVERART_API_KEY=your_everart_api_key_here
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `everart_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get Everart API key from environment
|
||||
everart_api_key = os.getenv("EVERART_API_KEY")
|
||||
|
||||
# Use a single string command with Everart configuration
|
||||
everart_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Everart.
|
||||
Use the available tools when relevant to generate and manage art.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-everart",
|
||||
env={"EVERART_API_KEY": everart_api_key})
|
||||
)
|
||||
|
||||
everart_agent.start("Generate an artistic image of a sunset")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python everart_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Everart API key
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
title: "Filesystem MCP Integration"
|
||||
sidebarTitle: "Filesystem"
|
||||
description: "Guide for integrating filesystem operations with PraisonAI agents using MCP"
|
||||
icon: "folder-open"
|
||||
---
|
||||
|
||||
## Add Filesystem Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Filesystem MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FFA500,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `filesystem_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Define allowed directories for filesystem access
|
||||
allowed_dirs = [
|
||||
"/Users/username/Desktop",
|
||||
"/path/to/other/allowed/dir"
|
||||
]
|
||||
|
||||
# Use a single string command with allowed directories
|
||||
filesystem_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with the filesystem.
|
||||
Use the available tools when relevant to manage files and directories.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-filesystem", args=allowed_dirs)
|
||||
)
|
||||
|
||||
filesystem_agent.start("List files in the allowed directories")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python filesystem_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
- Read/write access to the specified directories
|
||||
</Note>
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
title: "Google Drive MCP Integration"
|
||||
sidebarTitle: "Google Drive"
|
||||
description: "Guide for integrating Google Drive file management with PraisonAI agents using MCP"
|
||||
icon: "google-drive"
|
||||
---
|
||||
|
||||
## Add Google Drive Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Google Drive MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#0F9D58,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set up Google Drive Credentials">
|
||||
Set your Google Drive credentials path as an environment variable in your terminal:
|
||||
```bash
|
||||
export GDRIVE_CREDENTIALS_PATH=path/to/your/gcp-oauth.keys.json
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `gdrive_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the credentials path from environment
|
||||
gdrive_credentials = os.getenv("GDRIVE_CREDENTIALS_PATH", "servers/gcp-oauth.keys.json")
|
||||
|
||||
# Use a single string command with Google Drive configuration
|
||||
gdrive_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Google Drive.
|
||||
Use the available tools when relevant to manage files and folders.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-gdrive",
|
||||
env={"GDRIVE_CREDENTIALS_PATH": gdrive_credentials})
|
||||
)
|
||||
|
||||
gdrive_agent.start("List files in my Google Drive")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python gdrive_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Google Drive API credentials (OAuth keys)
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
title: "Gemini MCP Integration"
|
||||
sidebarTitle: "Gemini"
|
||||
description: "Guide for integrating Google's Gemini models with PraisonAI agents using MCP"
|
||||
icon: "google"
|
||||
---
|
||||
|
||||
## Add Gemini Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your Google API key as an environment variable in your terminal:
|
||||
```zsh
|
||||
export GOOGLE_API_KEY=your_google_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `gemini_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get API key from environment variable
|
||||
google_api_key = os.environ.get("GOOGLE_API_KEY")
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="gemini/gemini-2.5-pro-exp-03-25",
|
||||
tools=MCP(
|
||||
command="npx",
|
||||
args=["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"],
|
||||
env={"GOOGLE_API_KEY": google_api_key}
|
||||
)
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python gemini_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Google API key for Gemini models
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Gemini 2.5 Pro" icon="brain">
|
||||
Leverage Google's advanced Gemini 2.5 Pro model.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Environment Variables" icon="key">
|
||||
Securely pass API keys using environment variables.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
title: "GitHub MCP Integration"
|
||||
sidebarTitle: "GitHub"
|
||||
description: "Guide for integrating GitHub repository management with PraisonAI agents using MCP"
|
||||
icon: "github"
|
||||
---
|
||||
|
||||
## Add GitHub Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[GitHub MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#181717,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your GitHub Personal Access Token as an environment variable in your terminal:
|
||||
```bash
|
||||
export GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token_here
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `github_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use the API key from environment or set it directly
|
||||
github_token = os.getenv("GITHUB_PERSONAL_ACCESS_TOKEN")
|
||||
|
||||
# Use a single string command with environment variables
|
||||
github_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with GitHub.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-github",
|
||||
env={"GITHUB_PERSONAL_ACCESS_TOKEN": github_token})
|
||||
)
|
||||
|
||||
github_agent.start("List my GitHub repositories")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python github_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- GitHub Personal Access Token
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
title: "GitLab MCP Integration"
|
||||
sidebarTitle: "GitLab"
|
||||
description: "Guide for integrating GitLab repository management with PraisonAI agents using MCP"
|
||||
icon: "gitlab"
|
||||
---
|
||||
|
||||
## Add GitLab Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[GitLab MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FC6D26,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Keys">
|
||||
Set your GitLab credentials as environment variables in your terminal:
|
||||
```bash
|
||||
export GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token_here
|
||||
export GITLAB_API_URL=https://gitlab.com/api/v4
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `gitlab_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use the API token and URL from environment or set directly
|
||||
gitlab_token = os.getenv("GITLAB_PERSONAL_ACCESS_TOKEN")
|
||||
gitlab_api_url = os.getenv("GITLAB_API_URL", "https://gitlab.com/api/v4")
|
||||
|
||||
# Use a single string command with environment variables
|
||||
gitlab_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with GitLab.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-gitlab",
|
||||
env={
|
||||
"GITLAB_PERSONAL_ACCESS_TOKEN": gitlab_token,
|
||||
"GITLAB_API_URL": gitlab_api_url
|
||||
})
|
||||
)
|
||||
|
||||
gitlab_agent.start("List my GitLab projects")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python gitlab_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- GitLab Personal Access Token
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
title: "Google Maps MCP Integration"
|
||||
sidebarTitle: "Google Maps"
|
||||
description: "Guide for integrating Google Maps location services with PraisonAI agents using MCP"
|
||||
icon: "map"
|
||||
---
|
||||
|
||||
## Add Google Maps Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Google Maps MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#4285F4,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your Google Maps API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `google_maps_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the API key from environment
|
||||
maps_api_key = os.getenv("GOOGLE_MAPS_API_KEY")
|
||||
|
||||
# Use a single string command with Google Maps configuration
|
||||
maps_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Google Maps.
|
||||
Use the available tools when relevant to handle location-based queries.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-google-maps",
|
||||
env={"GOOGLE_MAPS_API_KEY": maps_api_key})
|
||||
)
|
||||
|
||||
maps_agent.start("Find nearby restaurants in London")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python google_maps_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Google Maps API key
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
title: "Groq MCP Integration"
|
||||
sidebarTitle: "Groq"
|
||||
description: "Guide for integrating Groq models with PraisonAI agents using MCP"
|
||||
icon: "bolt"
|
||||
---
|
||||
|
||||
## Add Groq Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your Groq API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export GROQ_API_KEY=your_groq_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `groq_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="groq/llama-3.2-90b-vision-preview",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python groq_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Groq API key
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Ultra-Fast Inference" icon="bolt">
|
||||
Utilize Groq's high-performance LPU inference for rapid responses.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Advanced Models" icon="brain">
|
||||
Access to Llama 3.2 90B and other powerful models.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,212 @@
|
||||
---
|
||||
title: "MCP Servers"
|
||||
sidebarTitle: "MCP Servers"
|
||||
description: "Learn how to create Model Context Protocol (MCP) servers with PraisonAI agents"
|
||||
icon: "server"
|
||||
---
|
||||
|
||||
# Creating MCP Servers
|
||||
|
||||
This guide demonstrates how to create Model Context Protocol (MCP) servers using PraisonAI agents. MCP is a protocol that enables AI models to use tools and communicate with external systems in a standardized way.
|
||||
|
||||
## Single Agent MCP Server
|
||||
|
||||
The simplest way to create an MCP server is with a single agent. This approach is ideal for specialized tasks where you need just one agent with a specific capability.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[mcp]>=0.0.81"
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create a Simple MCP Server">
|
||||
Create a file named `simple-mcp-server.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="Create a Tweet based on the topic provided")
|
||||
agent.launch(port=8080, protocol="mcp")
|
||||
```
|
||||
</Step>
|
||||
<Step title="Run the Server">
|
||||
```bash
|
||||
python simple-mcp-server.py
|
||||
```
|
||||
|
||||
Your MCP server will be available at `http://localhost:8080`
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Multi-Agent MCP Server with Custom Tools
|
||||
|
||||
For more complex scenarios, you can create an MCP server with multiple agents and custom tools. This approach allows for collaborative problem-solving and specialized capabilities.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Additional Dependencies">
|
||||
```bash
|
||||
pip install "praisonaiagents[mcp]" duckduckgo-search
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create a Multi-Agent MCP Server">
|
||||
Create a file named `simple-mcp-multi-agents-server.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents
|
||||
from duckduckgo_search import DDGS
|
||||
|
||||
def internet_search_tool(query: str):
|
||||
results = []
|
||||
ddgs = DDGS()
|
||||
for result in ddgs.text(keywords=query, max_results=5):
|
||||
results.append({
|
||||
"title": result.get("title", ""),
|
||||
"url": result.get("href", ""),
|
||||
"snippet": result.get("body", "")
|
||||
})
|
||||
return results
|
||||
|
||||
agent = Agent(instructions="You Search the internet for information", tools=[internet_search_tool])
|
||||
agent2 = Agent(instructions="You Summarise the information")
|
||||
|
||||
agents = Agents(agents=[agent, agent2])
|
||||
agents.launch(port=8080, protocol="mcp")
|
||||
```
|
||||
</Step>
|
||||
<Step title="Run the Multi-Agent Server">
|
||||
```bash
|
||||
python simple-mcp-multi-agents-server.py
|
||||
```
|
||||
|
||||
Your multi-agent MCP server will be available at `http://localhost:8080`
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Multi-Agent MCP Server (Simple)
|
||||
|
||||
For scenarios where you need multiple agents to collaborate without custom tools, you can create a simpler multi-agent MCP server:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents
|
||||
|
||||
agent = Agent(instructions="You Search the internet for information")
|
||||
agent2 = Agent(instructions="You Summarise the information")
|
||||
|
||||
agents = Agents(agents=[agent, agent2])
|
||||
agents.launch(port=8080, protocol="mcp")
|
||||
```
|
||||
|
||||
This approach is ideal for cases where you want agents with different specializations to work together using their built-in capabilities.
|
||||
|
||||
## Connecting to MCP Servers
|
||||
|
||||
You can connect to MCP servers using various clients:
|
||||
|
||||
### Using PraisonAI Agents
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
client_agent = Agent(
|
||||
instructions="Use the MCP server to complete tasks",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("http://localhost:8080")
|
||||
)
|
||||
|
||||
response = client_agent.start("Create a tweet about artificial intelligence")
|
||||
print(response)
|
||||
```
|
||||
|
||||
### Using JavaScript/TypeScript
|
||||
|
||||
```typescript
|
||||
import { MCPClient } from '@modelcontextprotocol/client';
|
||||
|
||||
async function main() {
|
||||
const client = new MCPClient('http://localhost:8080');
|
||||
|
||||
const response = await client.chat([
|
||||
{ role: 'user', content: 'Create a tweet about artificial intelligence' }
|
||||
]);
|
||||
|
||||
console.log(response.choices[0].message.content);
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Custom Port and Host
|
||||
|
||||
```python
|
||||
agent.launch(port=9000, host="0.0.0.0", protocol="mcp")
|
||||
```
|
||||
|
||||
### Authentication
|
||||
|
||||
```python
|
||||
agent.launch(port=8080, protocol="mcp", api_key="your-secret-key")
|
||||
```
|
||||
|
||||
### CORS Configuration
|
||||
|
||||
```python
|
||||
agent.launch(port=8080, protocol="mcp", cors_origins=["https://yourdomain.com"])
|
||||
```
|
||||
|
||||
## Deployment Options
|
||||
|
||||
For production deployments, consider:
|
||||
|
||||
1. **Docker Containerization**:
|
||||
```dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["python", "simple-mcp-server.py"]
|
||||
```
|
||||
|
||||
2. **Cloud Deployment**: Deploy to AWS, Google Cloud, or Azure using their container services.
|
||||
|
||||
3. **Kubernetes**: For scalable deployments, use Kubernetes to manage your MCP server containers.
|
||||
|
||||
## Security Considerations
|
||||
|
||||
1. **API Authentication**: Always use API keys in production
|
||||
2. **Rate Limiting**: Implement rate limiting to prevent abuse
|
||||
3. **Input Validation**: Validate all incoming requests
|
||||
4. **HTTPS**: Use SSL/TLS for all production deployments
|
||||
5. **Tool Permissions**: Limit what custom tools can access
|
||||
|
||||
## Features and Benefits
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Standardized Protocol" icon="diagram-project">
|
||||
MCP provides a standardized way for AI models to interact with tools and services.
|
||||
</Card>
|
||||
<Card title="Custom Tools" icon="screwdriver-wrench">
|
||||
Easily integrate custom tools like web search, database access, or API calls.
|
||||
</Card>
|
||||
<Card title="Multi-Agent Collaboration" icon="users-gear">
|
||||
Create systems where multiple specialized agents collaborate on complex tasks.
|
||||
</Card>
|
||||
<Card title="Language Agnostic" icon="language">
|
||||
Connect to MCP servers from any programming language that supports HTTP.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Agent Instructions**: Provide clear, specific instructions for each agent
|
||||
2. **Tool Documentation**: Document your custom tools thoroughly
|
||||
3. **Error Handling**: Implement robust error handling in your tools
|
||||
4. **Monitoring**: Set up logging and monitoring for your MCP servers
|
||||
5. **Testing**: Test your MCP servers thoroughly before deployment
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: "Memory MCP Integration"
|
||||
sidebarTitle: "Memory"
|
||||
description: "Guide for integrating memory storage capabilities with PraisonAI agents using MCP"
|
||||
icon: "memory"
|
||||
---
|
||||
|
||||
## Add Memory Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Memory MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#4B0082,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `memory_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the memory file path from environment
|
||||
memory_file_path = os.getenv("MEMORY_FILE_PATH", "/path/to/custom/memory.json")
|
||||
|
||||
# Use a single string command with Memory configuration
|
||||
memory_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can store and retrieve information.
|
||||
Use the available tools when relevant to manage memory operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-memory",
|
||||
env={"MEMORY_FILE_PATH": memory_file_path})
|
||||
)
|
||||
|
||||
memory_agent.start("Store this conversation in memory")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python memory_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
- Write access to the specified memory file path
|
||||
</Note>
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
title: "Mistral MCP Integration"
|
||||
sidebarTitle: "Mistral"
|
||||
description: "Guide for integrating Mistral models with PraisonAI agents using MCP"
|
||||
icon: "wind"
|
||||
---
|
||||
|
||||
## Add Mistral Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your Mistral API key as an environment variable in your terminal:
|
||||
```zsh
|
||||
export MISTRAL_API_KEY=your_mistral_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `mistral_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get API key from environment variable
|
||||
mistral_api_key = os.environ.get("MISTRAL_API_KEY")
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="mistral/mistral-large-latest",
|
||||
tools=MCP(
|
||||
command="npx",
|
||||
args=["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"],
|
||||
env={"MISTRAL_API_KEY": mistral_api_key}
|
||||
)
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python mistral_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Mistral API key
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Mistral Large" icon="brain">
|
||||
Leverage Mistral's powerful large language model.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Environment Variables" icon="key">
|
||||
Securely pass API keys using environment variables.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,90 @@
|
||||
---
|
||||
title: "Ollama Python MCP Integration"
|
||||
sidebarTitle: "Ollama Python"
|
||||
description: "Guide for integrating Ollama models with Python MCP servers using PraisonAI agents"
|
||||
icon: "python"
|
||||
---
|
||||
|
||||
## Add Ollama Python Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Stock Price MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#3776AB,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set Up Ollama">
|
||||
Make sure you have Ollama installed and running locally:
|
||||
```bash
|
||||
# Install Ollama from https://ollama.ai/
|
||||
# Pull the llama3.2 model
|
||||
ollama pull llama3.2
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `ollama_stock.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
stock_agent = Agent(
|
||||
instructions="""You are a Stock Price Assistant.""",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("/Users/praison/miniconda3/envs/mcp/bin/python /Users/praison/stockprice/app.py")
|
||||
)
|
||||
|
||||
# NOTE: Python Path replace with yours: /Users/praison/miniconda3/envs/mcp/bin/python
|
||||
# NOTE: app.py file path, replace it with yours: /Users/praison/stockprice/app.py
|
||||
|
||||
stock_agent.start("What is the Stock Price of Apple?")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]" yfinance mcp
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python ollama_stock.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Ollama installed and running locally
|
||||
- yfinance and mcp packages installed
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Local LLM" icon="server">
|
||||
Run models locally using Ollama without relying on external APIs.
|
||||
</Card>
|
||||
<Card title="Stock Data" icon="chart-line">
|
||||
Retrieve real-time stock price information using the yfinance library.
|
||||
</Card>
|
||||
<Card title="Python MCP" icon="python">
|
||||
Use Python-based MCP servers for custom tool functionality.
|
||||
</Card>
|
||||
<Card title="Privacy-Focused" icon="shield-alt">
|
||||
Keep sensitive data local with on-device inference.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: "Ollama MCP Integration"
|
||||
sidebarTitle: "Ollama"
|
||||
description: "Guide for integrating Ollama models with PraisonAI agents using MCP"
|
||||
icon: "dragon"
|
||||
---
|
||||
|
||||
## Add Ollama Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set Up Ollama">
|
||||
Make sure you have Ollama installed and running locally:
|
||||
```bash
|
||||
# Install Ollama from https://ollama.ai/
|
||||
# Pull the llama3.2 model
|
||||
ollama pull llama3.2
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `ollama_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python ollama_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Ollama installed and running locally
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Local LLM" icon="server">
|
||||
Run models locally using Ollama without relying on external APIs.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Privacy-Focused" icon="shield-alt">
|
||||
Keep sensitive data local with on-device inference.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,128 @@
|
||||
---
|
||||
title: "OpenAI MCP Integration"
|
||||
sidebarTitle: "OpenAI"
|
||||
description: "Guide for integrating OpenAI models with PraisonAI agents using MCP"
|
||||
icon: "folder-open"
|
||||
---
|
||||
|
||||
## Add OpenAI Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```zsh
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `openai_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get API key from environment variable
|
||||
openai_api_key = os.environ.get("OPENAI_API_KEY")
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP(
|
||||
command="npx",
|
||||
args=["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"],
|
||||
env={"OPENAI_API_KEY": openai_api_key}
|
||||
)
|
||||
)
|
||||
|
||||
search_agent.start("I want to book an apartment in Paris for 2 nights. 03/28 - 03/30 for 2 adults")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```zsh
|
||||
pip install praisonaiagents
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```zsh
|
||||
python openai_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
|
||||
## Gradio UI
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import gradio as gr
|
||||
import os
|
||||
|
||||
# Get API key from environment variable
|
||||
openai_api_key = os.environ.get("OPENAI_API_KEY")
|
||||
|
||||
def search_airbnb(query):
|
||||
agent = Agent(
|
||||
instructions="You help book apartments on Airbnb.",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP(
|
||||
command="npx",
|
||||
args=["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"],
|
||||
env={"OPENAI_API_KEY": openai_api_key}
|
||||
)
|
||||
)
|
||||
result = agent.start(query)
|
||||
return f"## Airbnb Search Results\n\n{result}"
|
||||
|
||||
demo = gr.Interface(
|
||||
fn=search_airbnb,
|
||||
inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
|
||||
outputs=gr.Markdown(),
|
||||
title="Airbnb Booking Assistant",
|
||||
description="Enter your booking requirements below:"
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="GPT-4o-mini" icon="brain">
|
||||
Uses OpenAI's efficient GPT-4o-mini model for optimal performance.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Environment Variables" icon="key">
|
||||
Securely pass API keys using environment variables.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
title: "OpenRouter MCP Integration"
|
||||
sidebarTitle: "OpenRouter"
|
||||
description: "Guide for integrating OpenRouter models with PraisonAI agents using MCP"
|
||||
icon: "network-wired"
|
||||
---
|
||||
|
||||
## Add OpenRouter Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenRouter API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENROUTER_API_KEY=your_openrouter_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `openrouter_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="openrouter/google/gemini-2.0-flash-exp:free",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python openrouter_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenRouter API key
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Model Flexibility" icon="layer-group">
|
||||
Access to various models through OpenRouter's unified API.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="Cost Effective" icon="money-bill">
|
||||
Use free tier models like Gemini Flash through OpenRouter.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: "Perplexity MCP Integration"
|
||||
sidebarTitle: "Perplexity"
|
||||
description: "Guide for integrating Perplexity search with PraisonAI agents using MCP"
|
||||
icon: "magnifying-glass"
|
||||
---
|
||||
|
||||
## Add Perplexity Search Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Perplexity MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#4B0082,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your Perplexity API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export PERPLEXITY_API_KEY=your_perplexity_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `perplexity_search.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get API key from environment variable
|
||||
api_key = os.getenv("PERPLEXITY_API_KEY")
|
||||
|
||||
agent = Agent(
|
||||
instructions="You are a helpful assistant that can search the web for information. Use the available tools when relevant to answer user questions.",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("uvx perplexity-mcp",
|
||||
env={"PERPLEXITY_API_KEY": api_key, "PERPLEXITY_MODEL": "sonar" })
|
||||
)
|
||||
|
||||
result = agent.start("What is the latest news on AI?, Pass only the query parameter to the tool")
|
||||
|
||||
print(result)
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python perplexity_search.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Perplexity API key
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Web Search" icon="globe">
|
||||
Search the web for real-time information using Perplexity's powerful search API.
|
||||
</Card>
|
||||
<Card title="Sonar Model" icon="radar">
|
||||
Utilize Perplexity's Sonar model for high-quality search results.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Environment Variables" icon="key">
|
||||
Securely pass API keys using environment variables.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "PostgreSQL MCP Integration"
|
||||
sidebarTitle: "PostgreSQL"
|
||||
description: "Guide for integrating PostgreSQL database operations with PraisonAI agents using MCP"
|
||||
icon: "database"
|
||||
---
|
||||
|
||||
## Add PostgreSQL Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[PostgreSQL MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#336791,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set up PostgreSQL">
|
||||
Ensure you have PostgreSQL running locally or specify your PostgreSQL connection URL.
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `postgres_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# PostgreSQL connection string
|
||||
postgres_url = "postgresql://localhost/mydb"
|
||||
|
||||
# Use a single string command with PostgreSQL configuration
|
||||
postgres_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with PostgreSQL databases.
|
||||
Use the available tools when relevant to manage database operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-postgres", args=[postgres_url])
|
||||
)
|
||||
|
||||
postgres_agent.start("List all tables in the database")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python postgres_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- PostgreSQL server running locally or remotely
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "Puppeteer MCP Integration"
|
||||
sidebarTitle: "Puppeteer"
|
||||
description: "Guide for integrating web automation capabilities with PraisonAI agents using Puppeteer MCP"
|
||||
icon: "chrome"
|
||||
---
|
||||
|
||||
## Add Puppeteer Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Puppeteer MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#00B4FF,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `puppeteer_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use a single string command with Puppeteer configuration
|
||||
puppeteer_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can automate web browser interactions.
|
||||
Use the available tools when relevant to perform web automation tasks.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-puppeteer")
|
||||
)
|
||||
|
||||
puppeteer_agent.start("Navigate to example.com and take a screenshot")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python puppeteer_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
- Chrome or Chromium browser installed on your system
|
||||
</Note>
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "Redis MCP Integration"
|
||||
sidebarTitle: "Redis"
|
||||
description: "Guide for integrating Redis database operations with PraisonAI agents using MCP"
|
||||
icon: "database"
|
||||
---
|
||||
|
||||
## Add Redis Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Redis MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#DC382D,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set up Redis">
|
||||
Ensure you have Redis running locally or specify your Redis connection URL.
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `redis_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Redis connection string
|
||||
redis_url = "redis://localhost:6379"
|
||||
|
||||
# Use a single string command with Redis configuration
|
||||
redis_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Redis.
|
||||
Use the available tools when relevant to manage Redis operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-redis", args=[redis_url])
|
||||
)
|
||||
|
||||
redis_agent.start("Set a key-value pair in Redis")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python redis_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Redis server running locally or remotely
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: "Sequential Thinking MCP Integration"
|
||||
sidebarTitle: "Sequential Thinking"
|
||||
description: "Guide for integrating sequential thinking capabilities with PraisonAI agents using MCP"
|
||||
icon: "brain"
|
||||
---
|
||||
|
||||
## Add Sequential Thinking Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Sequential Thinking MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#6A5ACD,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `sequential_thinking.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use a single string command with Sequential Thinking configuration
|
||||
sequential_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can break down complex problems.
|
||||
Use the available tools when relevant to perform step-by-step analysis.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-sequential-thinking")
|
||||
)
|
||||
|
||||
sequential_agent.start("Break down the process of making a cup of tea")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python sequential_thinking.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
title: "Slack MCP Integration"
|
||||
sidebarTitle: "Slack"
|
||||
description: "Guide for integrating Slack messaging capabilities with PraisonAI agents using MCP"
|
||||
icon: "slack"
|
||||
---
|
||||
|
||||
## Add Slack Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Slack MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#4A154B,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install praisonaiagents mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Keys">
|
||||
Set your Slack credentials as environment variables in your terminal:
|
||||
```bash
|
||||
export SLACK_BOT_TOKEN=your_slack_bot_token_here
|
||||
export SLACK_TEAM_ID=your_slack_team_id_here
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `slack_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get Slack credentials from environment
|
||||
slack_token = os.getenv("SLACK_BOT_TOKEN")
|
||||
slack_team_id = os.getenv("SLACK_TEAM_ID")
|
||||
|
||||
# Use a single string command with Slack configuration
|
||||
slack_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Slack.
|
||||
Use the available tools when relevant to manage Slack communications.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-slack",
|
||||
env={
|
||||
"SLACK_BOT_TOKEN": slack_token,
|
||||
"SLACK_TEAM_ID": slack_team_id
|
||||
})
|
||||
)
|
||||
|
||||
slack_agent.start("Send a message to the general channel")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python slack_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- Slack Bot Token and Team ID
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
@@ -0,0 +1,248 @@
|
||||
---
|
||||
title: "MCP SSE Integration"
|
||||
sidebarTitle: "MCP SSE"
|
||||
description: "Guide for integrating Server-Sent Events (SSE) with PraisonAI agents using MCP"
|
||||
icon: "server"
|
||||
---
|
||||
|
||||
## Add SSE Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[SSE MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#4169E1,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Create a client file">
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You are a weather agent that can provide weather information for a given city.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("http://localhost:8080/sse")
|
||||
)
|
||||
|
||||
search_agent.start("What is the weather in London?")
|
||||
```
|
||||
|
||||
</Step>
|
||||
<Step title="Set Up SSE MCP Server">
|
||||
|
||||
```python
|
||||
# python mcp-sse-direct-server.py --host 127.0.0.1 --port 8080
|
||||
from typing import Any
|
||||
import httpx
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
from starlette.applications import Starlette
|
||||
from mcp.server.sse import SseServerTransport
|
||||
from starlette.requests import Request
|
||||
from starlette.routing import Mount, Route
|
||||
from mcp.server import Server
|
||||
import uvicorn
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import inspect
|
||||
|
||||
# Set up logging based on environment variable
|
||||
log_level = os.environ.get("LOGLEVEL", "info").upper()
|
||||
logging.basicConfig(level=getattr(logging, log_level))
|
||||
logger = logging.getLogger("mcp-server")
|
||||
|
||||
# Initialize FastMCP server for simple tools (SSE)
|
||||
mcp = FastMCP("simple-tools")
|
||||
|
||||
@mcp.tool()
|
||||
async def get_greeting(name: str) -> str:
|
||||
"""Get a personalized greeting.
|
||||
|
||||
Args:
|
||||
name: Name of the person to greet
|
||||
"""
|
||||
logger.debug(f"get_greeting called with name: {name}")
|
||||
return f"Hello, {name}! Welcome to our MCP SSE server."
|
||||
|
||||
@mcp.tool()
|
||||
async def get_weather(city: str) -> str:
|
||||
"""Get a simulated weather report for a city.
|
||||
|
||||
Args:
|
||||
city: Name of the city
|
||||
"""
|
||||
logger.debug(f"get_weather called with city: {city}")
|
||||
# This is a mock implementation
|
||||
weather_data = {
|
||||
"Paris": "Sunny with a temperature of 22°C",
|
||||
"London": "Rainy with a temperature of 15°C",
|
||||
"New York": "Cloudy with a temperature of 18°C",
|
||||
"Tokyo": "Clear skies with a temperature of 25°C",
|
||||
"Sydney": "Partly cloudy with a temperature of 20°C"
|
||||
}
|
||||
|
||||
return weather_data.get(city, f"Weather data not available for {city}")
|
||||
|
||||
def create_starlette_app(mcp_server: Server, *, debug: bool = False) -> Starlette:
|
||||
"""Create a Starlette application that can serve the provided mcp server with SSE."""
|
||||
sse = SseServerTransport("/messages/")
|
||||
|
||||
async def handle_sse(request: Request) -> None:
|
||||
logger.debug(f"SSE connection request received from {request.client}")
|
||||
async with sse.connect_sse(
|
||||
request.scope,
|
||||
request.receive,
|
||||
request._send, # noqa: SLF001
|
||||
) as (read_stream, write_stream):
|
||||
await mcp_server.run(
|
||||
read_stream,
|
||||
write_stream,
|
||||
mcp_server.create_initialization_options(),
|
||||
)
|
||||
|
||||
return Starlette(
|
||||
debug=debug,
|
||||
routes=[
|
||||
Route("/sse", endpoint=handle_sse),
|
||||
Mount("/messages/", app=sse.handle_post_message),
|
||||
],
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp_server = mcp._mcp_server # noqa: WPS437
|
||||
|
||||
parser = argparse.ArgumentParser(description='Run MCP SSE-based server')
|
||||
parser.add_argument('--host', default='localhost', help='Host to bind to')
|
||||
parser.add_argument('--port', type=int, default=8080, help='Port to listen on')
|
||||
args = parser.parse_args()
|
||||
|
||||
print(f"Starting MCP SSE server on {args.host}:{args.port}")
|
||||
|
||||
# Hardcode the tool names since we know what they are
|
||||
tool_names = ["get_greeting", "get_weather"]
|
||||
print(f"Available tools: {', '.join(tool_names)}")
|
||||
|
||||
# Bind SSE request handling to MCP server
|
||||
starlette_app = create_starlette_app(mcp_server, debug=True)
|
||||
|
||||
uvicorn.run(starlette_app, host=args.host, port=args.port)
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]" mcp starlette uvicorn httpx
|
||||
```
|
||||
</Step>
|
||||
<Step title="Export API Key">
|
||||
```bash
|
||||
export OPENAI_API_KEY="your_api_key"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Server and Agent">
|
||||
First, start the SSE server:
|
||||
```bash
|
||||
python mcp-sse-direct-server.py --host 127.0.0.1 --port 8080
|
||||
```
|
||||
|
||||
Then, in a new terminal, run the agent:
|
||||
```bash
|
||||
python weather_agent.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- MCP server dependencies
|
||||
</Note>
|
||||
|
||||
## Alternative LLM Integrations
|
||||
|
||||
### Using Groq with SSE
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
weather_agent = Agent(
|
||||
instructions="""You are a weather agent that can provide weather information for a given city.""",
|
||||
llm="groq/llama-3.2-90b-vision-preview",
|
||||
tools=MCP("http://localhost:8080/sse")
|
||||
)
|
||||
|
||||
weather_agent.start("What is the weather in London?")
|
||||
```
|
||||
|
||||
### Using Ollama with SSE
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
weather_agent = Agent(
|
||||
instructions="""You are a weather agent that can provide weather information for a given city.""",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("http://localhost:8080/sse")
|
||||
)
|
||||
|
||||
weather_agent.start("What is the weather in London? Use get_weather tool, city is the required parameter.")
|
||||
```
|
||||
|
||||
## Gradio UI Integration
|
||||
|
||||
Create a Gradio UI for your weather service:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import gradio as gr
|
||||
|
||||
def get_weather_info(query):
|
||||
weather_agent = Agent(
|
||||
instructions="""You are a weather agent that can provide weather information for a given city.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("http://localhost:8080/sse")
|
||||
)
|
||||
|
||||
result = weather_agent.start(query)
|
||||
return f"## Weather Information\n\n{result}"
|
||||
|
||||
demo = gr.Interface(
|
||||
fn=get_weather_info,
|
||||
inputs=gr.Textbox(placeholder="What's the weather in London?"),
|
||||
outputs=gr.Markdown(),
|
||||
title="Weather MCP Agent",
|
||||
description="Ask about the weather in any major city:"
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Real-time Updates" icon="bolt">
|
||||
Receive server-sent events in real-time from your AI agent.
|
||||
</Card>
|
||||
<Card title="Multi-Agent Support" icon="users">
|
||||
Combine SSE with other MCP tools for complex workflows.
|
||||
</Card>
|
||||
<Card title="Multiple LLM Options" icon="brain">
|
||||
Use with OpenAI, Groq, Ollama, or other supported LLMs.
|
||||
</Card>
|
||||
<Card title="Gradio UI" icon="window">
|
||||
Create user-friendly interfaces for your SSE integrations.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,221 @@
|
||||
---
|
||||
title: "MCP STDIO Integration"
|
||||
sidebarTitle: "MCP STDIO"
|
||||
description: "Guide for integrating Standard Input/Output (STDIO) with PraisonAI agents using MCP"
|
||||
icon: "terminal"
|
||||
---
|
||||
|
||||
## Add STDIO Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[STDIO MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#000000,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Create a client file">
|
||||
Create a new file `calculator_client.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
calculator_agent = Agent(
|
||||
instructions="""You are a calculator agent that can perform basic arithmetic operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python calculator_server.py")
|
||||
)
|
||||
|
||||
calculator_agent.start("What is 25 * 16?")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Set Up STDIO MCP Server">
|
||||
Create a file `calculator_server.py` with the following code:
|
||||
```python
|
||||
# calculator_server.py
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
import logging
|
||||
import sys
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO, filename="calculator_server.log")
|
||||
logger = logging.getLogger("calculator-server")
|
||||
|
||||
# Initialize FastMCP server for simple tools
|
||||
mcp = FastMCP("calculator-tools")
|
||||
|
||||
@mcp.tool()
|
||||
def add(a: float, b: float) -> float:
|
||||
"""Add two numbers.
|
||||
|
||||
Args:
|
||||
a: First number
|
||||
b: Second number
|
||||
|
||||
Returns:
|
||||
The sum of a and b
|
||||
"""
|
||||
logger.info(f"Adding {a} + {b}")
|
||||
return a + b
|
||||
|
||||
@mcp.tool()
|
||||
def subtract(a: float, b: float) -> float:
|
||||
"""Subtract b from a.
|
||||
|
||||
Args:
|
||||
a: First number
|
||||
b: Second number
|
||||
|
||||
Returns:
|
||||
The result of a - b
|
||||
"""
|
||||
logger.info(f"Subtracting {b} from {a}")
|
||||
return a - b
|
||||
|
||||
@mcp.tool()
|
||||
def multiply(a: float, b: float) -> float:
|
||||
"""Multiply two numbers.
|
||||
|
||||
Args:
|
||||
a: First number
|
||||
b: Second number
|
||||
|
||||
Returns:
|
||||
The product of a and b
|
||||
"""
|
||||
logger.info(f"Multiplying {a} * {b}")
|
||||
return a * b
|
||||
|
||||
@mcp.tool()
|
||||
def divide(a: float, b: float) -> float:
|
||||
"""Divide a by b.
|
||||
|
||||
Args:
|
||||
a: First number (numerator)
|
||||
b: Second number (denominator)
|
||||
|
||||
Returns:
|
||||
The result of a / b
|
||||
"""
|
||||
if b == 0:
|
||||
raise ValueError("Cannot divide by zero")
|
||||
logger.info(f"Dividing {a} / {b}")
|
||||
return a / b
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run the MCP server using STDIO transport
|
||||
mcp.run()
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]" mcp
|
||||
```
|
||||
</Step>
|
||||
<Step title="Export API Key">
|
||||
```bash
|
||||
export OPENAI_API_KEY="your_api_key"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Run the agent which will automatically start the calculator server:
|
||||
```bash
|
||||
python calculator_client.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- MCP package
|
||||
</Note>
|
||||
|
||||
## Alternative LLM Integrations
|
||||
|
||||
### Using Groq with STDIO
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
calculator_agent = Agent(
|
||||
instructions="""You are a calculator agent that can perform basic arithmetic operations.""",
|
||||
llm="groq/llama-3.2-90b-vision-preview",
|
||||
tools=MCP("python calculator_server.py")
|
||||
)
|
||||
|
||||
calculator_agent.start("What is 144 divided by 12?")
|
||||
```
|
||||
|
||||
### Using Ollama with STDIO
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
calculator_agent = Agent(
|
||||
instructions="""You are a calculator agent that can perform basic arithmetic operations.""",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("python calculator_server.py")
|
||||
)
|
||||
|
||||
calculator_agent.start("What is 15 + 27? Use the add tool with parameters a and b.")
|
||||
```
|
||||
|
||||
## Gradio UI Integration
|
||||
|
||||
Create a Gradio UI for your calculator service:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import gradio as gr
|
||||
|
||||
def calculate(query):
|
||||
calculator_agent = Agent(
|
||||
instructions="""You are a calculator agent that can perform basic arithmetic operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python calculator_server.py")
|
||||
)
|
||||
|
||||
result = calculator_agent.start(query)
|
||||
return f"## Calculation Result\n\n{result}"
|
||||
|
||||
demo = gr.Interface(
|
||||
fn=calculate,
|
||||
inputs=gr.Textbox(placeholder="What is 25 * 16?"),
|
||||
outputs=gr.Markdown(),
|
||||
title="Calculator MCP Agent",
|
||||
description="Ask any arithmetic question:"
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Simple Integration" icon="plug">
|
||||
Use standard input/output for easy integration with any tool or service.
|
||||
</Card>
|
||||
<Card title="Cross-Platform" icon="laptop">
|
||||
Works on any operating system that supports Python.
|
||||
</Card>
|
||||
<Card title="Multiple LLM Options" icon="brain">
|
||||
Use with OpenAI, Groq, Ollama, or other supported LLMs.
|
||||
</Card>
|
||||
<Card title="Gradio UI" icon="window">
|
||||
Create user-friendly interfaces for your STDIO integrations.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,153 @@
|
||||
---
|
||||
title: "Stock Price MCP Integration"
|
||||
sidebarTitle: "Stock Price"
|
||||
description: "Guide for integrating stock price retrieval capabilities with PraisonAI agents using MCP"
|
||||
icon: "chart-line"
|
||||
---
|
||||
|
||||
## Add Stock Price Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[Query] --> Agent[AI Agent]
|
||||
Agent --> Tool[Stock Price MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Answer]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#2E8B57,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
Create a conda environment and install the required packages:
|
||||
```bash
|
||||
zsh -c "source $(conda info --base)/etc/profile.d/conda.sh && conda create -n windsurf python=3.10 -y"
|
||||
zsh -c "source $(conda info --base)/etc/profile.d/conda.sh && conda activate windsurf && pip install praisonaiagents mcp yfinance"
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_openai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create the MCP Server">
|
||||
Create a new file `stock_price_server.py` with the following code:
|
||||
```python
|
||||
import yfinance as yf
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("stock_prices")
|
||||
|
||||
@mcp.tool()
|
||||
async def get_stock_price(ticker: str) -> str:
|
||||
"""Get the current stock price for a given ticker symbol.
|
||||
|
||||
Args:
|
||||
ticker: Stock ticker symbol (e.g., AAPL, MSFT, GOOG)
|
||||
|
||||
Returns:
|
||||
Current stock price as a string
|
||||
"""
|
||||
if not ticker:
|
||||
return "No ticker provided"
|
||||
try:
|
||||
stock = yf.Ticker(ticker)
|
||||
info = stock.info
|
||||
current_price = info.get('currentPrice') or info.get('regularMarketPrice')
|
||||
if not current_price:
|
||||
return f"Could not retrieve price for {ticker}"
|
||||
return f"${current_price:.2f}"
|
||||
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport='stdio')
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create the Agent">
|
||||
Create a new file `stock_price_agent.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the path to your Python interpreter and the server file
|
||||
python_path = os.getenv("PYTHON_PATH", "/path/to/your/python")
|
||||
server_path = os.getenv("SERVER_PATH", "/path/to/your/stock_price_server.py")
|
||||
|
||||
# Create the agent with the stock price MCP tool
|
||||
agent = Agent(
|
||||
instructions="""You are a helpful assistant that can check stock prices.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP(f"{python_path} {server_path}")
|
||||
)
|
||||
|
||||
agent.start("What is the stock price of Tesla?")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
zsh -c "source $(conda info --base)/etc/profile.d/conda.sh && conda activate windsurf && python stock_price_agent.py"
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- yfinance package
|
||||
- mcp-python-sdk package
|
||||
- praisonaiagents package
|
||||
- OpenAI API key (for the agent's LLM)
|
||||
</Note>
|
||||
|
||||
## Gradio UI Example
|
||||
|
||||
You can also create a simple web UI for your stock price agent using Gradio:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
import gradio as gr
|
||||
import os
|
||||
|
||||
# Get the path to your Python interpreter and the server file
|
||||
python_path = os.getenv("PYTHON_PATH", "/path/to/your/python")
|
||||
server_path = os.getenv("SERVER_PATH", "/path/to/your/stock_price_server.py")
|
||||
|
||||
# Create the agent with the stock price MCP tool
|
||||
agent = Agent(
|
||||
instructions="""You are a helpful assistant that can check stock prices.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP(f"{python_path} {server_path}")
|
||||
)
|
||||
|
||||
def chat(message, history):
|
||||
return agent.chat(message)
|
||||
|
||||
demo = gr.ChatInterface(
|
||||
chat,
|
||||
title="Stock Price Assistant",
|
||||
description="Ask about any stock price and get real-time information",
|
||||
theme="soft"
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
Install Gradio with:
|
||||
```bash
|
||||
zsh -c "source $(conda info --base)/etc/profile.d/conda.sh && conda activate windsurf && pip install gradio"
|
||||
```
|
||||
@@ -0,0 +1,185 @@
|
||||
---
|
||||
title: "WhatsApp MCP Integration"
|
||||
sidebarTitle: "WhatsApp"
|
||||
description: "Guide for integrating WhatsApp messaging with PraisonAI agents using MCP"
|
||||
icon: "whatsapp"
|
||||
---
|
||||
|
||||
## Add WhatsApp Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[WhatsApp MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#25D366,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set Up WhatsApp MCP Server">
|
||||
Clone and set up the WhatsApp MCP server:
|
||||
```bash
|
||||
git clone https://github.com/lharries/whatsapp-mcp.git
|
||||
cd whatsapp-mcp
|
||||
cd whatsapp-bridge
|
||||
go run main.go
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create a file">
|
||||
Create a new file `whatsapp_message.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
whatsapp_agent = Agent(
|
||||
instructions="Whatsapp Agent",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
|
||||
)
|
||||
|
||||
whatsapp_agent.start("Send Hello to Mervin Praison")
|
||||
```
|
||||
|
||||
Note: Replace `/path/to/whatsapp-mcp` with the actual path to your WhatsApp MCP server.
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have the required packages installed:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]" mcp gradio
|
||||
```
|
||||
</Step>
|
||||
<Step title="Export API Key">
|
||||
```bash
|
||||
export OPENAI_API_KEY="your_api_key"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python whatsapp_message.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- WhatsApp MCP server set up and configured
|
||||
</Note>
|
||||
|
||||
## Multi-Agent Integration
|
||||
|
||||
You can also combine WhatsApp with other MCP tools, such as Airbnb search:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents, MCP
|
||||
|
||||
airbnb_agent = Agent(
|
||||
instructions="""Search for Apartments in Paris for 2 nights on Airbnb. 04/28 - 04/30 for 2 adults""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
whatsapp_agent = Agent(
|
||||
instructions="""Send AirBnb Search Result to 'Mervin Praison'""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
|
||||
)
|
||||
|
||||
agents = Agents(agents=[airbnb_agent, whatsapp_agent])
|
||||
|
||||
agents.start()
|
||||
```
|
||||
|
||||
## Alternative LLM Integrations
|
||||
|
||||
### Using Groq with WhatsApp
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
whatsapp_agent = Agent(
|
||||
instructions="Whatsapp Agent",
|
||||
llm="groq/llama-3.2-90b-vision-preview",
|
||||
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
|
||||
)
|
||||
|
||||
whatsapp_agent.start("Send Hello to Mervin Praison")
|
||||
```
|
||||
|
||||
### Using Ollama with WhatsApp
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
whatsapp_agent = Agent(
|
||||
instructions="Whatsapp Agent",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
|
||||
)
|
||||
|
||||
whatsapp_agent.start("Send Hello to Mervin Praison. Use send_message tool, recipient and message are the required parameters.")
|
||||
```
|
||||
|
||||
## Gradio UI Integration
|
||||
|
||||
Create a Gradio UI for your WhatsApp and Airbnb integration:
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Agents, MCP
|
||||
import gradio as gr
|
||||
|
||||
def search_airbnb(query):
|
||||
airbnb_agent = Agent(
|
||||
instructions=query+" on Airbnb",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
whatsapp_agent = Agent(
|
||||
instructions="""Send AirBnb Search Result to 'Mervin Praison'. Don't include Phone Number in Response, but include the AirBnb Search Result""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
|
||||
)
|
||||
|
||||
agents = Agents(agents=[airbnb_agent, whatsapp_agent])
|
||||
|
||||
result = agents.start()
|
||||
return f"## Airbnb Search Results\n\n{result}"
|
||||
|
||||
demo = gr.Interface(
|
||||
fn=search_airbnb,
|
||||
inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
|
||||
outputs=gr.Markdown(),
|
||||
title="WhatsApp MCP Agent",
|
||||
description="Enter your booking requirements below:"
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="WhatsApp Messaging" icon="message">
|
||||
Send messages to WhatsApp contacts directly from your AI agent.
|
||||
</Card>
|
||||
<Card title="Multi-Agent Support" icon="users">
|
||||
Combine WhatsApp with other MCP tools for complex workflows.
|
||||
</Card>
|
||||
<Card title="Multiple LLM Options" icon="brain">
|
||||
Use with OpenAI, Groq, Ollama, or other supported LLMs.
|
||||
</Card>
|
||||
<Card title="Gradio UI" icon="window">
|
||||
Create user-friendly interfaces for your WhatsApp integrations.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
title: "xAI MCP Integration"
|
||||
sidebarTitle: "xAI"
|
||||
description: "Guide for integrating XAI's Grok model with PraisonAI agents using MCP"
|
||||
icon: "robot"
|
||||
---
|
||||
|
||||
## Add XAI Tool to AI Agent
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
In[In] --> Agent[AI Agent]
|
||||
Agent --> Tool[Airbnb MCP]
|
||||
Tool --> Agent
|
||||
Agent --> Out[Out]
|
||||
|
||||
style In fill:#8B0000,color:#fff
|
||||
style Agent fill:#2E8B57,color:#fff
|
||||
style Tool fill:#FF5A5F,color:#fff
|
||||
style Out fill:#8B0000,color:#fff
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Set API Key">
|
||||
Set your XAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export XAI_API_KEY=your_xai_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `xai_airbnb.py` with the following code:
|
||||
```python
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="xai/grok-2-latest",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Install Dependencies">
|
||||
Make sure you have Node.js installed, as the MCP server requires it:
|
||||
```bash
|
||||
pip install "praisonaiagents[llm]"
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Agent">
|
||||
Execute your script:
|
||||
```bash
|
||||
python xai_airbnb.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- Node.js installed on your system
|
||||
- XAI API key (for the Grok model)
|
||||
</Note>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Grok Integration" icon="robot">
|
||||
Uses XAI's Grok model for advanced natural language understanding.
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="plug">
|
||||
Seamless integration with Model Context Protocol.
|
||||
</Card>
|
||||
<Card title="Airbnb Search" icon="hotel">
|
||||
Search for accommodations on Airbnb with natural language queries.
|
||||
</Card>
|
||||
<Card title="NPM Package" icon="js">
|
||||
Leverages the official Airbnb MCP server package.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
+60
-10
@@ -55,14 +55,6 @@
|
||||
}
|
||||
],
|
||||
"tabs": [
|
||||
{
|
||||
"name": "Documentation",
|
||||
"url": "/index"
|
||||
},
|
||||
{
|
||||
"name": "Examples",
|
||||
"url": "/examples"
|
||||
},
|
||||
{
|
||||
"name": "Agents",
|
||||
"url": "/agents"
|
||||
@@ -75,6 +67,18 @@
|
||||
"name": "Tools",
|
||||
"url": "/tools"
|
||||
},
|
||||
{
|
||||
"name": "MCP",
|
||||
"url": "/mcp"
|
||||
},
|
||||
{
|
||||
"name": "Deploy",
|
||||
"url": "/deploy"
|
||||
},
|
||||
{
|
||||
"name": "Examples",
|
||||
"url": "/examples"
|
||||
},
|
||||
{
|
||||
"name": "JS",
|
||||
"url": "/js"
|
||||
@@ -230,6 +234,43 @@
|
||||
"agents/recommendation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "MCP",
|
||||
"pages": [
|
||||
"mcp/airbnb",
|
||||
"mcp/stdio",
|
||||
"mcp/sse",
|
||||
"mcp/mcp-server",
|
||||
"mcp/ollama",
|
||||
"mcp/groq",
|
||||
"mcp/openrouter",
|
||||
"mcp/xai",
|
||||
"mcp/openai",
|
||||
"mcp/anthropic",
|
||||
"mcp/gemini",
|
||||
"mcp/mistral",
|
||||
"mcp/whatsapp",
|
||||
"mcp/perplexity",
|
||||
"mcp/ollama-python",
|
||||
"mcp/bravesearch",
|
||||
"mcp/custom",
|
||||
"mcp/sequential-thinking",
|
||||
"mcp/filesystem",
|
||||
"mcp/github",
|
||||
"mcp/gdrive",
|
||||
"mcp/gitlab",
|
||||
"mcp/google-maps",
|
||||
"mcp/memory",
|
||||
"mcp/redis",
|
||||
"mcp/stockprice",
|
||||
"mcp/postgres",
|
||||
"mcp/puppeteer",
|
||||
"mcp/everart",
|
||||
"mcp/slack",
|
||||
"mcp/custom-python-client",
|
||||
"mcp/custom-python-server"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Tools",
|
||||
"pages": [
|
||||
@@ -332,6 +373,16 @@
|
||||
"ui/code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Deploy",
|
||||
"pages": [
|
||||
"deploy/deploy",
|
||||
"deploy/multi-agents-deploy",
|
||||
"deploy/mcp-server-deploy",
|
||||
"deploy/aws",
|
||||
"deploy/googlecloud"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Monitoring",
|
||||
"pages": ["monitoring/agentops"]
|
||||
@@ -345,8 +396,7 @@
|
||||
"developers/wrapper-tools",
|
||||
"developers/googlecolab",
|
||||
"developers/googlecolab-tools",
|
||||
"developers/local-development",
|
||||
"deploy"
|
||||
"developers/local-development"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
title: "Auto Generation Mode"
|
||||
description: "Guide to PraisonAI's automatic agent generation feature, supporting both CrewAI and AutoGen frameworks for automated task execution"
|
||||
description: "Guide to PraisonAI's automatic agent generation feature, supporting both CrewAI and AG2 frameworks for automated task execution"
|
||||
icon: "robot"
|
||||
---
|
||||
|
||||
PraisonAI supports automatic agent generation with PraisonAI Agents, CrewAI and AutoGen frameworks.
|
||||
PraisonAI supports automatic agent generation with PraisonAI Agents, CrewAI and AG2 frameworks.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -17,7 +17,7 @@ pip install praisonai
|
||||
# For CrewAI
|
||||
pip install "praisonai[crewai]"
|
||||
|
||||
# For AutoGen
|
||||
# For AG2 (Formerly AutoGen)
|
||||
pip install "praisonai[autogen]"
|
||||
|
||||
# For both frameworks
|
||||
@@ -36,7 +36,7 @@ praisonai --auto "create a movie script about Dog in Moon"
|
||||
praisonai --framework crewai --auto "create a movie script about Dog in Moon"
|
||||
```
|
||||
|
||||
### With AutoGen
|
||||
### With AG2
|
||||
```bash
|
||||
praisonai --framework autogen --auto "create a movie script about Dog in Moon"
|
||||
```
|
||||
@@ -49,7 +49,7 @@ praisonai --framework autogen --auto "create a movie script about Dog in Moon"
|
||||
- Built-in tools integration
|
||||
- Structured agent-task relationships
|
||||
|
||||
### AutoGen
|
||||
### AG2 (Formerly AutoGen)
|
||||
- Multi-agent conversation capabilities
|
||||
- Code execution environment
|
||||
- Built-in tools integration
|
||||
|
||||
@@ -28,13 +28,13 @@ Includes:
|
||||
- Task delegation capabilities
|
||||
- Sequential and parallel task execution
|
||||
|
||||
### AutoGen Support
|
||||
### AG2 Support
|
||||
```bash
|
||||
pip install "praisonai[autogen]"
|
||||
```
|
||||
|
||||
Includes:
|
||||
- AutoGen framework
|
||||
- AG2 framework
|
||||
- PraisonAI tools integration
|
||||
- Multi-agent conversation capabilities
|
||||
- Code execution environment
|
||||
|
||||
@@ -21,7 +21,7 @@ icon: "hand-wave"
|
||||
Create and orchestrate sophisticated multi-agent systems with ease
|
||||
</Card>
|
||||
<Card title="Framework Integration" icon="puzzle-piece">
|
||||
Seamlessly integrates AutoGen and CrewAI capabilities
|
||||
Seamlessly integrates AG2 and CrewAI capabilities
|
||||
</Card>
|
||||
<Card title="Low-Code Design" icon="code">
|
||||
Build complex AI systems with minimal coding required
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "TL;DR"
|
||||
description: "Quick start guide for PraisonAI with CrewAI, AutoGen, and UI setup instructions"
|
||||
description: "Quick start guide for PraisonAI with CrewAI, AG2 (Formerly AutoGen), and UI setup instructions"
|
||||
icon: "bolt"
|
||||
---
|
||||
|
||||
@@ -32,10 +32,10 @@ praisonai --framework crewai --init "create a movie script about dog in moon"
|
||||
praisonai --framework crewai
|
||||
```
|
||||
|
||||
## Quick Start with AutoGen
|
||||
## Quick Start with AG2
|
||||
|
||||
```bash
|
||||
# Install with AutoGen support
|
||||
# Install with AG2 support
|
||||
pip install "praisonai[autogen]"
|
||||
|
||||
# Set your API key
|
||||
|
||||
@@ -71,7 +71,7 @@ To run the PraisonAI tool, simply type the following command in your terminal:
|
||||
praisonai
|
||||
```
|
||||
|
||||
If you want to run the `autogen` framework, use:
|
||||
If you want to run the AG2 framework (Formerly AutoGen), use:
|
||||
|
||||
```bash
|
||||
praisonai --framework autogen
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ icon: "comments"
|
||||
|
||||
| Interface | Description | URL |
|
||||
|---|---|---|
|
||||
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praison.ai/ui/ui](https://docs.praison.ai/ui/ui) |
|
||||
| **UI** | Multi Agents such as CrewAI or AG2 | [https://docs.praison.ai/ui/ui](https://docs.praison.ai/ui/ui) |
|
||||
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praison.ai/ui/chat](https://docs.praison.ai/ui/chat) |
|
||||
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praison.ai/ui/code](https://docs.praison.ai/ui/code) |
|
||||
|
||||
@@ -155,7 +155,7 @@ To facilitate local development with live reload, you can use Docker. Follow the
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN pip install flask praisonai==2.0.18 watchdog
|
||||
RUN pip install flask praisonai==2.2.2 watchdog
|
||||
|
||||
EXPOSE 5555
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ PraisonAI Code helps you to interact with your whole codebase using the power of
|
||||
|
||||
| Interface | Description | URL |
|
||||
|---|---|---|
|
||||
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praison.ai/ui/ui](https://docs.praison.ai/ui/ui) |
|
||||
| **UI** | Multi Agents such as CrewAI or AG2 | [https://docs.praison.ai/ui/ui](https://docs.praison.ai/ui/ui) |
|
||||
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praison.ai/ui/chat](https://docs.praison.ai/ui/chat) |
|
||||
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praison.ai/ui/code](https://docs.praison.ai/ui/code) |
|
||||
|
||||
@@ -208,7 +208,7 @@ To facilitate local development with live reload, you can use Docker. Follow the
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN pip install flask praisonai==2.0.18 watchdog
|
||||
RUN pip install flask praisonai==2.2.2 watchdog
|
||||
|
||||
EXPOSE 5555
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ icon: "browser"
|
||||
|---|---|---|
|
||||
| **Streamlit** | Create interactive web apps with Python | [https://docs.praison.ai/ui/streamlit](/ui/streamlit) |
|
||||
| **Gradio** | Build machine learning web apps rapidly | [https://docs.praison.ai/ui/gradio](/ui/gradio) |
|
||||
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praison.ai/ui/ui](/ui/ui) |
|
||||
| **UI** | Multi Agents such as CrewAI or AG2 | [https://docs.praison.ai/ui/ui](/ui/ui) |
|
||||
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praison.ai/ui/chat](/ui/chat) |
|
||||
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praison.ai/ui/code](/ui/code) |
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
qa_agent = Agent(
|
||||
instructions="""You are a Question Answering Agent.""",
|
||||
llm="openai/gpt-4o-mini",
|
||||
tools=MCP("http://localhost:8080/agents/sse")
|
||||
)
|
||||
|
||||
qa_agent.start("AI in 2025")
|
||||
@@ -0,0 +1,20 @@
|
||||
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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -0,0 +1,8 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You are a weather agent that can provide weather information for a given city.""",
|
||||
llm="openai/gpt-4o-mini",
|
||||
tools=MCP("http://localhost:8080/sse")
|
||||
)
|
||||
search_agent.launch(path="/weather", port=3030)
|
||||
@@ -0,0 +1,4 @@
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(instructions="""You are a helpful assistant.""", llm="gpt-4o-mini")
|
||||
agent.launch(path="/ask", port=3030)
|
||||
@@ -0,0 +1,19 @@
|
||||
from praisonaiagents import Agent, Agents
|
||||
from duckduckgo_search import DDGS
|
||||
|
||||
def internet_search_tool(query: str):
|
||||
results = []
|
||||
ddgs = DDGS()
|
||||
for result in ddgs.text(keywords=query, max_results=5):
|
||||
results.append({
|
||||
"title": result.get("title", ""),
|
||||
"url": result.get("href", ""),
|
||||
"snippet": result.get("body", "")
|
||||
})
|
||||
return results
|
||||
|
||||
agent = Agent(name="SearchAgent", instructions="You Search the internet for information", tools=[internet_search_tool])
|
||||
agent2 = Agent(name="SummariseAgent", instructions="You Summarise the information")
|
||||
|
||||
agents = Agents(name="MultiAgents", agents=[agent, agent2])
|
||||
agents.launch(port=8080, protocol="mcp")
|
||||
@@ -0,0 +1,4 @@
|
||||
from praisonaiagents import Agent
|
||||
|
||||
agent = Agent(name="TweetAgent", instructions="Create a Tweet based on the topic provided")
|
||||
agent.launch(port=8080, protocol="mcp")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("I want to book an apartment in Paris for 2 nights. 03/28 - 03/30 for 2 adults")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="anthropic/claude-3-7-sonnet-20250219",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
@@ -0,0 +1,22 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get AWS credentials from environment
|
||||
aws_access_key = os.getenv("AWS_ACCESS_KEY_ID")
|
||||
aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY")
|
||||
aws_region = os.getenv("AWS_REGION")
|
||||
|
||||
# Use a single string command with AWS KB Retrieval configuration
|
||||
aws_kb_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with AWS Knowledge Base.
|
||||
Use the available tools when relevant to retrieve and process AWS information.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-aws-kb-retrieval",
|
||||
env={
|
||||
"AWS_ACCESS_KEY_ID": aws_access_key,
|
||||
"AWS_SECRET_ACCESS_KEY": aws_secret_key,
|
||||
"AWS_REGION": aws_region
|
||||
})
|
||||
)
|
||||
|
||||
aws_kb_agent.start("Search AWS documentation about EC2 instances")
|
||||
@@ -0,0 +1,15 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use the API key from environment or set it directly
|
||||
brave_api_key = os.getenv("BRAVE_API_KEY")
|
||||
|
||||
# Use a single string command with environment variables
|
||||
search_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can search the web for information.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-brave-search", env={"BRAVE_API_KEY": brave_api_key})
|
||||
)
|
||||
|
||||
search_agent.start("Search more information about AI News")
|
||||
@@ -0,0 +1,13 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
agent = Agent(
|
||||
instructions="""You are a helpful assistant that can check stock prices and perform other tasks.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools = MCP("/Users/praison/miniconda3/envs/mcp/bin/python /Users/praison/stockprice/app.py")
|
||||
)
|
||||
|
||||
# NOTE: Python Path replace with yours: /Users/praison/miniconda3/envs/mcp/bin/python
|
||||
# NOTE: app.py file path, replace it with yours: /Users/praison/stockprice/app.py
|
||||
|
||||
agent.start("What is the stock price of Tesla?")
|
||||
@@ -0,0 +1,30 @@
|
||||
import yfinance as yf
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
mcp = FastMCP("stock_prices")
|
||||
|
||||
@mcp.tool()
|
||||
async def get_stock_price(ticker: str) -> str:
|
||||
"""Get the current stock price for a given ticker symbol.
|
||||
|
||||
Args:
|
||||
ticker: Stock ticker symbol (e.g., AAPL, MSFT, GOOG)
|
||||
|
||||
Returns:
|
||||
Current stock price as a string
|
||||
"""
|
||||
if not ticker:
|
||||
return "No ticker provided"
|
||||
try:
|
||||
stock = yf.Ticker(ticker)
|
||||
info = stock.info
|
||||
current_price = info.get('currentPrice') or info.get('regularMarketPrice')
|
||||
if not current_price:
|
||||
return f"Could not retrieve price for {ticker}"
|
||||
return f"${current_price:.2f}"
|
||||
|
||||
except Exception as e:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport='stdio')
|
||||
@@ -0,0 +1,15 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Databutton API key
|
||||
databutton_api_key = os.getenv("DATABUTTON_API_KEY")
|
||||
|
||||
# Create databutton agent
|
||||
databutton_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Databutton.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("uvx databutton-app-mcp@latest", env={"DATABUTTON_API_KEY": databutton_api_key})
|
||||
)
|
||||
|
||||
databutton_agent.start("Get the current stock price for AAPL, Tesla, and Amazon")
|
||||
@@ -0,0 +1,16 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get Everart API key from environment
|
||||
everart_api_key = os.getenv("EVERART_API_KEY")
|
||||
|
||||
# Use a single string command with Everart configuration
|
||||
everart_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Everart.
|
||||
Use the available tools when relevant to generate and manage art.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-everart",
|
||||
env={"EVERART_API_KEY": everart_api_key})
|
||||
)
|
||||
|
||||
everart_agent.start("Generate an artistic image of a sunset")
|
||||
@@ -0,0 +1,13 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# pip install mcp-server-fetch
|
||||
# Use a single string command with Fetch configuration
|
||||
fetch_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can fetch and process web content.
|
||||
Use the available tools when relevant to retrieve and convert web pages to markdown.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python -m mcp_server_fetch")
|
||||
)
|
||||
|
||||
fetch_agent.start("Fetch and convert the content from https://example.com to markdown")
|
||||
@@ -0,0 +1,18 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Define allowed directories for filesystem access
|
||||
allowed_dirs = [
|
||||
"/Users/username/Desktop",
|
||||
"/path/to/other/allowed/dir"
|
||||
]
|
||||
|
||||
# Use a single string command with allowed directories
|
||||
filesystem_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with the filesystem.
|
||||
Use the available tools when relevant to manage files and directories.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-filesystem", args=allowed_dirs)
|
||||
)
|
||||
|
||||
filesystem_agent.start("List files in the allowed directories")
|
||||
@@ -0,0 +1,16 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the credentials path from environment
|
||||
gdrive_credentials = os.getenv("GDRIVE_CREDENTIALS_PATH", "servers/gcp-oauth.keys.json")
|
||||
|
||||
# Use a single string command with Google Drive configuration
|
||||
gdrive_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Google Drive.
|
||||
Use the available tools when relevant to manage files and folders.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-gdrive",
|
||||
env={"GDRIVE_CREDENTIALS_PATH": gdrive_credentials})
|
||||
)
|
||||
|
||||
gdrive_agent.start("List files in my Google Drive")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="gemini/gemini-2.5-pro-exp-03-25",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
@@ -0,0 +1,23 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# pip install mcp-server-git
|
||||
# Get Git credentials from environment
|
||||
git_username = os.getenv("GIT_USERNAME")
|
||||
git_email = os.getenv("GIT_EMAIL")
|
||||
git_token = os.getenv("GIT_TOKEN") # For private repos
|
||||
|
||||
# Use a single string command with Git configuration
|
||||
git_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can perform Git operations.
|
||||
Use the available tools when relevant to manage repositories, commits, and branches.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python -m mcp_server_git",
|
||||
env={
|
||||
"GIT_USERNAME": git_username,
|
||||
"GIT_EMAIL": git_email,
|
||||
"GIT_TOKEN": git_token
|
||||
})
|
||||
)
|
||||
|
||||
git_agent.start("Clone and analyze the repository at https://github.com/modelcontextprotocol/servers")
|
||||
@@ -0,0 +1,15 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use the API key from environment or set it directly
|
||||
github_token = os.getenv("GITHUB_PERSONAL_ACCESS_TOKEN")
|
||||
|
||||
# Use a single string command with environment variables
|
||||
github_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with GitHub.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-github", env={"GITHUB_PERSONAL_ACCESS_TOKEN": github_token})
|
||||
)
|
||||
|
||||
github_agent.start("List my GitHub repositories")
|
||||
@@ -0,0 +1,20 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use the API token and URL from environment or set directly
|
||||
gitlab_token = os.getenv("GITLAB_PERSONAL_ACCESS_TOKEN")
|
||||
gitlab_api_url = os.getenv("GITLAB_API_URL", "https://gitlab.com/api/v4")
|
||||
|
||||
# Use a single string command with environment variables
|
||||
gitlab_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with GitLab.
|
||||
Use the available tools when relevant to answer user questions.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-gitlab",
|
||||
env={
|
||||
"GITLAB_PERSONAL_ACCESS_TOKEN": gitlab_token,
|
||||
"GITLAB_API_URL": gitlab_api_url
|
||||
})
|
||||
)
|
||||
|
||||
gitlab_agent.start("List my GitLab projects")
|
||||
@@ -0,0 +1,16 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the API key from environment
|
||||
maps_api_key = os.getenv("GOOGLE_MAPS_API_KEY")
|
||||
|
||||
# Use a single string command with Google Maps configuration
|
||||
maps_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Google Maps.
|
||||
Use the available tools when relevant to handle location-based queries.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-google-maps",
|
||||
env={"GOOGLE_MAPS_API_KEY": maps_api_key})
|
||||
)
|
||||
|
||||
maps_agent.start("Find nearby restaurants in London")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="groq/llama-3.2-90b-vision-preview",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You are a weather agent that can provide weather information for a given city.""",
|
||||
llm="openai/gpt-4o-mini",
|
||||
tools=MCP("http://localhost:8080/sse")
|
||||
)
|
||||
|
||||
search_agent.start("What is the weather in London?")
|
||||
@@ -0,0 +1,16 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Get the memory file path from environment
|
||||
memory_file_path = os.getenv("MEMORY_FILE_PATH", "/path/to/custom/memory.json")
|
||||
|
||||
# Use a single string command with Memory configuration
|
||||
memory_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can store and retrieve information.
|
||||
Use the available tools when relevant to manage memory operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-memory",
|
||||
env={"MEMORY_FILE_PATH": memory_file_path})
|
||||
)
|
||||
|
||||
memory_agent.start("Store this conversation in memory")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="mistral/mistral-large-latest",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
@@ -0,0 +1,12 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
stock_agent = Agent(
|
||||
instructions="""You are a Stock Price Assistant.""",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("/Users/praison/miniconda3/envs/mcp/bin/python /Users/praison/stockprice/app.py")
|
||||
)
|
||||
|
||||
# NOTE: Python Path replace with yours: /Users/praison/miniconda3/envs/mcp/bin/python
|
||||
# NOTE: app.py file path, replace it with yours: /Users/praison/stockprice/app.py
|
||||
|
||||
stock_agent.start("What is the Stock Price of Apple?")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="ollama/llama3.2",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("I want to book an apartment in Paris for 2 nights. 03/28 - 03/30 for 2 adults")
|
||||
@@ -0,0 +1,9 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
|
||||
search_agent = Agent(
|
||||
instructions="""You help book apartments on Airbnb.""",
|
||||
llm="openrouter/google/gemini-2.0-flash-exp:free",
|
||||
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
|
||||
)
|
||||
|
||||
search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference")
|
||||
@@ -0,0 +1,14 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
api_key = os.getenv("PERPLEXITY_API_KEY")
|
||||
|
||||
agent = Agent(
|
||||
instructions="You are a helpful assistant that can search the web for information. Use the available tools when relevant to answer user questions.",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("uvx perplexity-mcp",
|
||||
env={"PERPLEXITY_API_KEY": api_key, "PERPLEXITY_MODEL": "sonar" })
|
||||
)
|
||||
result = agent.start("What is the latest news on AI?, Pass only the query parameter to the tool")
|
||||
|
||||
print(result)
|
||||
@@ -0,0 +1,15 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# PostgreSQL connection string
|
||||
postgres_url = "postgresql://localhost/mydb"
|
||||
|
||||
# Use a single string command with PostgreSQL configuration
|
||||
postgres_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with PostgreSQL databases.
|
||||
Use the available tools when relevant to manage database operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-postgres", args=[postgres_url])
|
||||
)
|
||||
|
||||
postgres_agent.start("List all tables in the database")
|
||||
@@ -0,0 +1,12 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use a single string command with Puppeteer configuration
|
||||
puppeteer_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can automate web browser interactions.
|
||||
Use the available tools when relevant to perform web automation tasks.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-puppeteer")
|
||||
)
|
||||
|
||||
puppeteer_agent.start("Navigate to example.com and take a screenshot")
|
||||
@@ -0,0 +1,15 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Redis connection string
|
||||
redis_url = "redis://localhost:6379"
|
||||
|
||||
# Use a single string command with Redis configuration
|
||||
redis_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can interact with Redis.
|
||||
Use the available tools when relevant to manage Redis operations.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-redis", args=[redis_url])
|
||||
)
|
||||
|
||||
redis_agent.start("Set a key-value pair in Redis")
|
||||
@@ -0,0 +1,16 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# pip install mcp-server-sentry
|
||||
# Get Sentry auth token from environment
|
||||
sentry_token = os.getenv("SENTRY_AUTH_TOKEN")
|
||||
|
||||
# Use a single string command with Sentry configuration
|
||||
sentry_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can analyze Sentry error reports.
|
||||
Use the available tools when relevant to inspect and debug application issues.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("python -m mcp_server_sentry --auth-token", args=[sentry_token])
|
||||
)
|
||||
|
||||
sentry_agent.start("Analyze the most recent critical error in Sentry")
|
||||
@@ -0,0 +1,12 @@
|
||||
from praisonaiagents import Agent, MCP
|
||||
import os
|
||||
|
||||
# Use a single string command with Sequential Thinking configuration
|
||||
sequential_agent = Agent(
|
||||
instructions="""You are a helpful assistant that can break down complex problems.
|
||||
Use the available tools when relevant to perform step-by-step analysis.""",
|
||||
llm="gpt-4o-mini",
|
||||
tools=MCP("npx -y @modelcontextprotocol/server-sequential-thinking")
|
||||
)
|
||||
|
||||
sequential_agent.start("Break down the process of making a cup of tea")
|
||||
Loaded 100 of 165 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user