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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/mcp/openrouter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ flowchart LR
<Step title="Install Dependencies">
Make sure you have Node.js installed, as the MCP server requires it:
```bash
pip install praisonaiagents
pip install "praisonaiagents[llm]"
```
</Step>

Expand Down
91 changes: 91 additions & 0 deletions docs/mcp/perplexity.mdx
Original file line number Diff line number Diff line change
@@ -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)
```
Comment on lines +39 to +52
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This example lacks error handling. Add a try-except block to catch potential exceptions, such as os.getenv returning None or the Perplexity API being unavailable. This will make the example more robust and user-friendly.

try:
    # Get API key from environment variable
    api_key = os.getenv("PERPLEXITY_API_KEY")
    if not api_key:
        raise ValueError("PERPLEXITY_API_KEY not set")

    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)
except Exception as e:
    print(f"An error occurred: {e}")

</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>
185 changes: 185 additions & 0 deletions docs/mcp/whatsapp.mdx
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This path is hardcoded. It would be better to use an environment variable or a relative path to make the example more portable. Consider using os.path.join for cross-platform compatibility.

tools=MCP(f"python {os.path.join(os.getcwd(), '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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Why is mcp and gradio included here, but not in the Perplexity installation instructions? Ensure that all necessary dependencies are consistently specified across all relevant documentation files.

pip install "praisonaiagents[llm]" # Installs the core package with dependencies for LLM support

```
</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>
2 changes: 1 addition & 1 deletion docs/mcp/xai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ flowchart LR
<Step title="Install Dependencies">
Make sure you have Node.js installed, as the MCP server requires it:
```bash
pip install praisonaiagents
pip install "praisonaiagents[llm]"
```
</Step>

Expand Down
2 changes: 2 additions & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@
"mcp/anthropic",
"mcp/gemini",
"mcp/mistral",
"mcp/whatsapp",
"mcp/perplexity",
"mcp/ollama-python",
"mcp/bravesearch",
"mcp/custom",
Expand Down
14 changes: 14 additions & 0 deletions examples/mcp/perplexity-mcp.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions examples/mcp/whatapp-groq-mcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from praisonaiagents import Agent, MCP

whatsapp_agent = Agent(
instructions="Whatsapp Agent",
llm="groq/llama-3.2-90b-vision-preview",
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
Comment on lines +6 to +7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This path is hardcoded. It would be better to use an environment variable or a relative path to make the example more portable. Consider using os.path.join for cross-platform compatibility.

Suggested change
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")


whatsapp_agent.start("Send Hello to Mervin Praison")
9 changes: 9 additions & 0 deletions examples/mcp/whatapp-mcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from praisonaiagents import Agent, MCP

whatsapp_agent = Agent(
instructions="Whatsapp Agent",
llm="gpt-4o-mini",
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
Comment on lines +6 to +7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This path is hardcoded. It would be better to use an environment variable or a relative path to make the example more portable. Consider using os.path.join for cross-platform compatibility.

Suggested change
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")


whatsapp_agent.start("Send Hello to Mervin Praison")
17 changes: 17 additions & 0 deletions examples/mcp/whatapp-multi-agents-mcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
Comment on lines +12 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This path is hardcoded. It would be better to use an environment variable or a relative path to make the example more portable. Consider using os.path.join for cross-platform compatibility.

Suggested change
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")


agents = Agents(agents=[airbnb_agent, whatsapp_agent])

agents.start()
9 changes: 9 additions & 0 deletions examples/mcp/whatapp-ollama-mcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from praisonaiagents import Agent, MCP

whatsapp_agent = Agent(
instructions="Whatsapp Agent",
llm="ollama/llama3.2",
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
Comment on lines +6 to +7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This path is hardcoded. It would be better to use an environment variable or a relative path to make the example more portable. Consider using os.path.join for cross-platform compatibility.

Suggested change
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
)
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.")
Loading
Loading