mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-08 17:31:00 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad9828d3bb | ||
|
|
85ddf04b47 | ||
|
|
1c1a1b719b | ||
|
|
a8e0914e05 | ||
|
|
ec6d883f4f | ||
|
|
d094cbfac5 |
No files matched your search
+2
-1
@@ -65,4 +65,5 @@ outputs
|
||||
agents/praisonaiagents/build
|
||||
agents/praisonaiagents/dist
|
||||
agents/praisonaiagents/praisonaiagents.egg-info
|
||||
.codegpt
|
||||
.codegpt
|
||||
.praison
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip install flask praisonai==2.0.39 gunicorn markdown
|
||||
RUN pip install flask praisonai==2.0.41 gunicorn markdown
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
|
||||
@@ -1,6 +1,7 @@
|
||||
framework: praisonai
|
||||
process: sequential
|
||||
topic: create movie script about cat in mars
|
||||
memory: false
|
||||
roles:
|
||||
researcher:
|
||||
backstory: Skilled in research, with a focus on gathering accurate and relevant
|
||||
|
||||
@@ -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.39 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.41 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
---
|
||||
title: "LangChain Agents"
|
||||
sidebarTitle: "LangChain Agents"
|
||||
description: "Learn how to use LangChain tools and utilities with PraisonAI agents."
|
||||
icon: "link-simple"
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Code">
|
||||
<Steps>
|
||||
<Step title="Install Package">
|
||||
First, install the required packages:
|
||||
```bash
|
||||
pip install praisonaiagents langchain-community wikipedia
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create a file">
|
||||
Create a new file `app.py` with the basic setup:
|
||||
<CodeGroup>
|
||||
```python Single Tool
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from langchain_community.utilities import WikipediaAPIWrapper
|
||||
|
||||
# Create an agent with Wikipedia tool
|
||||
agent = Agent(
|
||||
name="WikiAgent",
|
||||
role="Research Assistant",
|
||||
goal="Search Wikipedia for accurate information",
|
||||
backstory="I am an AI assistant specialized in Wikipedia research",
|
||||
tools=[WikipediaAPIWrapper],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
# Create a research task
|
||||
task = Task(
|
||||
name="wiki_search",
|
||||
description="Research 'Artificial Intelligence' on Wikipedia",
|
||||
expected_output="Comprehensive information from Wikipedia articles",
|
||||
agent=agent
|
||||
)
|
||||
|
||||
# Create and start the workflow
|
||||
agents = PraisonAIAgents(
|
||||
agents=[agent],
|
||||
tasks=[task],
|
||||
verbose=True
|
||||
)
|
||||
|
||||
agents.start()
|
||||
```
|
||||
|
||||
```python Multiple Tools
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from langchain_community.tools import YouTubeSearchTool
|
||||
from langchain_community.utilities import WikipediaAPIWrapper
|
||||
|
||||
# Create YouTube search agent
|
||||
agent = Agent(
|
||||
name="SearchAgent",
|
||||
role="Research Assistant",
|
||||
goal="Search for information from YouTube",
|
||||
backstory="I am an AI assistant that can search YouTube for relevant videos.",
|
||||
tools=[YouTubeSearchTool],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
# Create Wikipedia research agent
|
||||
agent2 = Agent(
|
||||
name="WikiAgent",
|
||||
role="Research Assistant",
|
||||
goal="Search for information from Wikipedia",
|
||||
backstory="I am an AI assistant that can search Wikipedia for accurate information.",
|
||||
tools=[WikipediaAPIWrapper],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
# Create YouTube search task
|
||||
task = Task(
|
||||
name="search_task",
|
||||
description="Search for information about 'AI advancements' on YouTube",
|
||||
expected_output="Relevant information from YouTube videos",
|
||||
agent=agent
|
||||
)
|
||||
|
||||
# Create Wikipedia research task
|
||||
task2 = Task(
|
||||
name="wiki_task",
|
||||
description="Search for information about 'AI advancements' on Wikipedia",
|
||||
expected_output="Comprehensive information from Wikipedia articles",
|
||||
agent=agent2
|
||||
)
|
||||
|
||||
# Create and start the workflow
|
||||
agents = PraisonAIAgents(
|
||||
agents=[agent, agent2],
|
||||
tasks=[task, task2],
|
||||
verbose=True
|
||||
)
|
||||
|
||||
agents.start()
|
||||
```
|
||||
</CodeGroup>
|
||||
</Step>
|
||||
|
||||
<Step title="Start Agents">
|
||||
Type this in your terminal to run your agents:
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
</Tab>
|
||||
<Tab title="No Code">
|
||||
<Steps>
|
||||
<Step title="Install Package">
|
||||
(Upcoming Feature)
|
||||
Install the PraisonAI package:
|
||||
```bash
|
||||
pip install "praisonai"
|
||||
```
|
||||
</Step>
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable in your terminal:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_api_key_here
|
||||
```
|
||||
</Step>
|
||||
<Step title="Create a file">
|
||||
Create a new file `agents.yaml` with the basic setup:
|
||||
```yaml
|
||||
framework: praisonai
|
||||
process: sequential
|
||||
roles:
|
||||
researcher:
|
||||
name: SearchAgent
|
||||
role: Research Assistant
|
||||
goal: Search for information from multiple sources
|
||||
backstory: I am an AI assistant that can search YouTube and Wikipedia.
|
||||
tools:
|
||||
- youtube_search
|
||||
- wikipedia
|
||||
tasks:
|
||||
search_task:
|
||||
name: search_task
|
||||
description: Search for information about 'AI advancements' on both YouTube and Wikipedia
|
||||
expected_output: Combined information from YouTube videos and Wikipedia articles
|
||||
```
|
||||
</Step>
|
||||
<Step title="Start Agents">
|
||||
Type this in your terminal to run your agents:
|
||||
```bash
|
||||
praisonai agents.yaml
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
- Python 3.10 or higher
|
||||
- OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys)
|
||||
- LangChain compatible tools and utilities
|
||||
</Note>
|
||||
|
||||
## Understanding LangChain Integration
|
||||
|
||||
<Card title="What is LangChain Integration?" icon="question">
|
||||
LangChain integration enables agents to:
|
||||
- Use LangChain's extensive tool ecosystem
|
||||
- Access various data sources and APIs
|
||||
- Leverage pre-built utilities and wrappers
|
||||
- Combine multiple tools in a single agent
|
||||
- Extend agent capabilities with community tools
|
||||
</Card>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Tool Integration" icon="plug">
|
||||
Seamlessly use LangChain tools with PraisonAI agents.
|
||||
</Card>
|
||||
<Card title="Multiple Sources" icon="database">
|
||||
Access various data sources through LangChain utilities.
|
||||
</Card>
|
||||
<Card title="Community Tools" icon="users">
|
||||
Leverage the extensive LangChain community ecosystem.
|
||||
</Card>
|
||||
<Card title="Custom Tools" icon="wrench">
|
||||
Create and integrate custom LangChain tools.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Memory Integration" icon="brain" href="../concepts/memory">
|
||||
Learn how to combine LangChain tools with agent memory
|
||||
</Card>
|
||||
<Card title="Custom Tools" icon="wrench" href="./tools">
|
||||
Create your own custom tools for agents
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Note>
|
||||
For optimal results, ensure all required dependencies are installed and API keys are properly configured for each tool.
|
||||
</Note>
|
||||
@@ -84,6 +84,7 @@
|
||||
"features/selfreflection",
|
||||
"features/reasoning",
|
||||
"features/multimodal",
|
||||
"features/langchain",
|
||||
"features/async",
|
||||
"features/mini",
|
||||
"features/codeagent",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ class Praisonai < Formula
|
||||
|
||||
desc "AI tools for various AI applications"
|
||||
homepage "https://github.com/MervinPraison/PraisonAI"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.39.tar.gz"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.41.tar.gz"
|
||||
sha256 "1828fb9227d10f991522c3f24f061943a254b667196b40b1a3e4a54a8d30ce32" # Replace with actual SHA256 checksum
|
||||
license "MIT"
|
||||
|
||||
|
||||
@@ -212,9 +212,9 @@ class AgentsGenerator:
|
||||
try:
|
||||
# Try to import tools.py from current directory
|
||||
spec = importlib.util.spec_from_file_location("tools", "tools.py")
|
||||
self.logger.info(f"Spec: {spec}")
|
||||
self.logger.debug(f"Spec: {spec}")
|
||||
if spec is None:
|
||||
self.logger.info("tools.py not found in current directory")
|
||||
self.logger.debug("tools.py not found in current directory")
|
||||
return tools_list
|
||||
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
@@ -229,11 +229,13 @@ class AgentsGenerator:
|
||||
globals()[name] = obj
|
||||
# Add to tools list
|
||||
tools_list.append(obj)
|
||||
self.logger.info(f"Loaded and globalized tool function: {name}")
|
||||
self.logger.debug(f"Loaded and globalized tool function: {name}")
|
||||
|
||||
self.logger.info(f"Loaded {len(tools_list)} tool functions from tools.py")
|
||||
self.logger.info(f"Tools list: {tools_list}")
|
||||
self.logger.debug(f"Loaded {len(tools_list)} tool functions from tools.py")
|
||||
self.logger.debug(f"Tools list: {tools_list}")
|
||||
|
||||
except FileNotFoundError:
|
||||
self.logger.debug("tools.py not found in current directory")
|
||||
except Exception as e:
|
||||
self.logger.warning(f"Error loading tools from tools.py: {e}")
|
||||
|
||||
@@ -539,7 +541,7 @@ class AgentsGenerator:
|
||||
|
||||
# Load tools once at the beginning
|
||||
tools_list = self.load_tools_from_tools_py()
|
||||
self.logger.info(f"Loaded tools: {tools_list}")
|
||||
self.logger.debug(f"Loaded tools: {tools_list}")
|
||||
|
||||
# Create agents from config
|
||||
for role, details in config['roles'].items():
|
||||
@@ -574,7 +576,7 @@ class AgentsGenerator:
|
||||
agent.step_callback = self.agent_callback
|
||||
|
||||
agents[role] = agent
|
||||
self.logger.info(f"Created agent {role_filled} with tools: {agent.tools}")
|
||||
self.logger.debug(f"Created agent {role_filled} with tools: {agent.tools}")
|
||||
|
||||
# Create tasks for the agent
|
||||
for task_name, task_details in details.get('tasks', {}).items():
|
||||
@@ -596,7 +598,7 @@ class AgentsGenerator:
|
||||
create_directory=task_details.get('create_directory', False)
|
||||
)
|
||||
|
||||
self.logger.info(f"Created task {task_name} with tools: {task.tools}")
|
||||
self.logger.debug(f"Created task {task_name} with tools: {task.tools}")
|
||||
|
||||
if self.task_callback:
|
||||
task.callback = self.task_callback
|
||||
@@ -613,6 +615,8 @@ class AgentsGenerator:
|
||||
task.context = context_tasks
|
||||
|
||||
# Create and run the PraisonAI agents
|
||||
memory = config.get('memory', False)
|
||||
self.logger.debug(f"Memory: {memory}")
|
||||
if config.get('process') == 'hierarchical':
|
||||
agents = PraisonAIAgents(
|
||||
agents=list(agents.values()),
|
||||
@@ -620,12 +624,14 @@ class AgentsGenerator:
|
||||
verbose=True,
|
||||
process="hierarchical",
|
||||
manager_llm=config.get('manager_llm', 'gpt-4o'),
|
||||
memory=memory
|
||||
)
|
||||
else:
|
||||
agents = PraisonAIAgents(
|
||||
agents=list(agents.values()),
|
||||
tasks=tasks,
|
||||
verbose=2
|
||||
verbose=2,
|
||||
memory=memory
|
||||
)
|
||||
|
||||
self.logger.debug("Final Configuration:")
|
||||
|
||||
@@ -50,7 +50,7 @@ logger.handlers = []
|
||||
# Try to import tools from the root directory
|
||||
tools = []
|
||||
tools_path = os.path.join(os.getcwd(), 'tools.py')
|
||||
logger.info(f"Tools path: {tools_path}")
|
||||
logger.debug(f"Tools path: {tools_path}")
|
||||
|
||||
def import_tools_from_file(file_path):
|
||||
spec = importlib.util.spec_from_file_location("custom_tools", file_path)
|
||||
@@ -63,9 +63,9 @@ try:
|
||||
if os.path.exists(tools_path):
|
||||
# tools.py exists in the root directory, import from file
|
||||
custom_tools_module = import_tools_from_file(tools_path)
|
||||
logger.info("Successfully imported custom tools from root tools.py")
|
||||
logger.debug("Successfully imported custom tools from root tools.py")
|
||||
else:
|
||||
logger.info("No custom tools.py file found in the root directory")
|
||||
logger.debug("No custom tools.py file found in the root directory")
|
||||
custom_tools_module = None
|
||||
|
||||
if custom_tools_module:
|
||||
|
||||
@@ -73,6 +73,12 @@ except ImportError:
|
||||
pass
|
||||
|
||||
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO'), format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
logging.getLogger('alembic').setLevel(logging.ERROR)
|
||||
logging.getLogger('gradio').setLevel(logging.ERROR)
|
||||
logging.getLogger('gradio').setLevel(os.environ.get('GRADIO_LOGLEVEL', 'WARNING'))
|
||||
logging.getLogger('rust_logger').setLevel(logging.WARNING)
|
||||
logging.getLogger('duckduckgo').setLevel(logging.ERROR)
|
||||
logging.getLogger('_client').setLevel(logging.ERROR)
|
||||
|
||||
def stream_subprocess(command, env=None):
|
||||
"""
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class CloudDeployer:
|
||||
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.39 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.41 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "PraisonAI"
|
||||
version = "2.0.39"
|
||||
version = "2.0.41"
|
||||
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human–agent collaboration."
|
||||
readme = "README.md"
|
||||
license = ""
|
||||
@@ -84,7 +84,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.7", "crewai"]
|
||||
|
||||
[tool.poetry]
|
||||
name = "PraisonAI"
|
||||
version = "2.0.39"
|
||||
version = "2.0.41"
|
||||
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human–agent collaboration."
|
||||
authors = ["Mervin Praison"]
|
||||
license = ""
|
||||
|
||||
Reference in new issue
Block a user