mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-08 01:08:39 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5b6f8b91a | ||
|
|
823e46ca84 | ||
|
|
57040333a7 | ||
|
|
8c6800f876 | ||
|
|
0d701ae43c |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip install flask praisonai==2.0.35 gunicorn markdown
|
||||
RUN pip install flask praisonai==2.0.37 gunicorn markdown
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
|
||||
@@ -0,0 +1,6 @@
|
||||
Make it minimal change as possible
|
||||
|
||||
Firstly try not to make any modification to the existing code as possible
|
||||
|
||||
Only if its highly required, without that if it can't be done, then modify the existing.
|
||||
So by default try to add new code section and not modify the existing.
|
||||
@@ -0,0 +1,11 @@
|
||||
from praisonaiagents import AutoAgents
|
||||
from praisonaiagents.tools import duckduckgo
|
||||
|
||||
agents = AutoAgents(
|
||||
instructions="Search for information about AI Agents",
|
||||
tools=[duckduckgo],
|
||||
process="sequential",
|
||||
verbose=True
|
||||
)
|
||||
|
||||
agents.start()
|
||||
@@ -1,74 +0,0 @@
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from typing import List, Dict
|
||||
from duckduckgo_search import DDGS
|
||||
|
||||
# 1. Tool
|
||||
def internet_search_tool(query: str) -> List[Dict]:
|
||||
"""
|
||||
Perform a search using DuckDuckGo.
|
||||
|
||||
Args:
|
||||
query (str): The search query.
|
||||
|
||||
Returns:
|
||||
list: A list of search result titles, URLs, and snippets.
|
||||
"""
|
||||
try:
|
||||
results = []
|
||||
ddgs = DDGS()
|
||||
for result in ddgs.text(keywords=query, max_results=10):
|
||||
results.append({
|
||||
"title": result.get("title", ""),
|
||||
"url": result.get("href", ""),
|
||||
"snippet": result.get("body", "")
|
||||
})
|
||||
return results
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error during DuckDuckGo search: {e}")
|
||||
return []
|
||||
|
||||
# 2. Agent
|
||||
data_agent = Agent(
|
||||
name="DataCollector",
|
||||
role="Search Specialist",
|
||||
goal="Perform internet searches to collect relevant information.",
|
||||
backstory="Expert in finding and organising internet data.",
|
||||
tools=[internet_search_tool],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
# 3. Tasks
|
||||
collect_task = Task(
|
||||
description="Perform an internet search using the query: 'AI job trends in 2024'. Return results as a list of title, URL, and snippet.",
|
||||
expected_output="List of search results with titles, URLs, and snippets.",
|
||||
agent=data_agent,
|
||||
name="collect_data",
|
||||
is_start=True,
|
||||
next_tasks=["validate_data"]
|
||||
)
|
||||
|
||||
validate_task = Task(
|
||||
description="""Validate the collected data. Check if:
|
||||
1. At least 5 results are returned.
|
||||
2. Each result contains a title and a URL.
|
||||
Return validation_result as 'valid' or 'invalid' only no other text.""",
|
||||
expected_output="Validation result indicating if data is valid or invalid.",
|
||||
agent=data_agent,
|
||||
name="validate_data",
|
||||
task_type="decision",
|
||||
condition={
|
||||
"valid": [], # End the workflow on valid data
|
||||
"invalid": ["collect_data"] # Retry data collection on invalid data
|
||||
},
|
||||
)
|
||||
|
||||
# 4. Workflow
|
||||
agents = PraisonAIAgents(
|
||||
agents=[data_agent],
|
||||
tasks=[collect_task, validate_task],
|
||||
verbose=1,
|
||||
process="workflow"
|
||||
)
|
||||
|
||||
agents.start()
|
||||
@@ -0,0 +1,151 @@
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from typing import List, Dict, Union
|
||||
from duckduckgo_search import DDGS
|
||||
from langchain_community.tools import YouTubeSearchTool
|
||||
from langchain_community.utilities import WikipediaAPIWrapper
|
||||
|
||||
# 1. Tool
|
||||
def internet_search_tool(query: str) -> List[Dict]:
|
||||
"""
|
||||
Perform a search using DuckDuckGo.
|
||||
|
||||
Args:
|
||||
query (str): The search query.
|
||||
|
||||
Returns:
|
||||
list: A list of search result titles, URLs, and snippets.
|
||||
"""
|
||||
try:
|
||||
results = []
|
||||
ddgs = DDGS()
|
||||
for result in ddgs.text(keywords=query, max_results=10):
|
||||
results.append({
|
||||
"title": result.get("title", ""),
|
||||
"url": result.get("href", ""),
|
||||
"snippet": result.get("body", "")
|
||||
})
|
||||
return results
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error during DuckDuckGo search: {e}")
|
||||
return []
|
||||
|
||||
def youtube_search_tool(query: str, inspect: bool = False, max_results: int = 2):
|
||||
"""
|
||||
Provide a custom wrapper around the YouTubeSearchTool.
|
||||
|
||||
Args:
|
||||
query (str): The search query for YouTube.
|
||||
inspect (bool): If True, returns tool inspection info instead of search results.
|
||||
max_results (int): Maximum number of results to return (default: 2).
|
||||
Returns:
|
||||
Union[List[str], dict]: List of YouTube video URLs or tool inspection info.
|
||||
"""
|
||||
yt = YouTubeSearchTool()
|
||||
|
||||
if inspect:
|
||||
inspection_info = {
|
||||
"type": type(yt),
|
||||
"attributes": [attr for attr in dir(yt) if not attr.startswith('_')],
|
||||
"methods": {
|
||||
"run": getattr(yt, 'run', None),
|
||||
"arun": getattr(yt, 'arun', None)
|
||||
},
|
||||
"properties": {
|
||||
"name": getattr(yt, 'name', 'youtube_search'),
|
||||
"description": getattr(yt, 'description', 'Search YouTube videos'),
|
||||
"return_direct": getattr(yt, 'return_direct', False)
|
||||
}
|
||||
}
|
||||
return inspection_info
|
||||
|
||||
# Format query with max_results
|
||||
formatted_query = f"{query}, {max_results}"
|
||||
return yt.run(formatted_query)
|
||||
|
||||
def wikipedia_search_tool(query: str, inspect: bool = False, max_chars: int = 4000, top_k: int = 3):
|
||||
"""
|
||||
Provide a custom wrapper around langchain_community's WikipediaAPIWrapper.
|
||||
|
||||
Args:
|
||||
query (str): A search query for Wikipedia.
|
||||
inspect (bool): If True, returns tool inspection info instead of search results.
|
||||
max_chars (int): Maximum characters to return (default: 4000).
|
||||
top_k (int): Number of top results to consider (default: 3).
|
||||
Returns:
|
||||
Union[str, dict]: Summary from Wikipedia or tool inspection info if inspect=True.
|
||||
"""
|
||||
w = WikipediaAPIWrapper(
|
||||
top_k_results=top_k,
|
||||
doc_content_chars_max=max_chars,
|
||||
lang='en'
|
||||
)
|
||||
|
||||
if inspect:
|
||||
inspection_info = {
|
||||
"type": type(w),
|
||||
"attributes": [attr for attr in dir(w) if not attr.startswith('_')],
|
||||
"methods": {
|
||||
"run": getattr(w, 'run', None),
|
||||
"arun": getattr(w, 'arun', None)
|
||||
},
|
||||
"properties": {
|
||||
"name": "wikipedia",
|
||||
"description": "Search and get summaries from Wikipedia",
|
||||
"top_k": w.top_k_results,
|
||||
"lang": w.lang,
|
||||
"max_chars": w.doc_content_chars_max
|
||||
}
|
||||
}
|
||||
return inspection_info
|
||||
|
||||
try:
|
||||
result = w.run(query)
|
||||
return result
|
||||
except Exception as e:
|
||||
return f"Error searching Wikipedia: {str(e)}"
|
||||
|
||||
# 2. Agent
|
||||
data_agent = Agent(
|
||||
name="DataCollector",
|
||||
role="Search Specialist",
|
||||
goal="Perform internet searches to collect relevant information.",
|
||||
backstory="Expert in finding and organizing internet data from multiple sources.",
|
||||
tools=[internet_search_tool, youtube_search_tool, wikipedia_search_tool],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
# 3. Tasks
|
||||
collect_task = Task(
|
||||
description="Perform an internet search using the query: 'AI job trends in 2024'. Return results as a list of title, URL, and snippet.",
|
||||
expected_output="List of search results with titles, URLs, and snippets.",
|
||||
agent=data_agent,
|
||||
name="collect_data",
|
||||
is_start=True,
|
||||
next_tasks=["validate_data"]
|
||||
)
|
||||
|
||||
validate_task = Task(
|
||||
description="""Validate the collected data. Check if:
|
||||
1. At least 5 results are returned.
|
||||
2. Each result contains a title and a URL.
|
||||
Return validation_result as 'valid' or 'invalid' only no other text.""",
|
||||
expected_output="Validation result indicating if data is valid or invalid.",
|
||||
agent=data_agent,
|
||||
name="validate_data",
|
||||
task_type="decision",
|
||||
condition={
|
||||
"valid": [], # End the workflow on valid data
|
||||
"invalid": ["collect_data"] # Retry data collection on invalid data
|
||||
},
|
||||
)
|
||||
|
||||
# 4. Workflow
|
||||
agents = PraisonAIAgents(
|
||||
agents=[data_agent],
|
||||
tasks=[collect_task, validate_task],
|
||||
verbose=1,
|
||||
process="workflow"
|
||||
)
|
||||
|
||||
agents.start()
|
||||
File renamed without changes.
-28535
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,30 @@
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from langchain_community.tools import YouTubeSearchTool
|
||||
from langchain_community.utilities import WikipediaAPIWrapper
|
||||
|
||||
# Create an agent with both tools
|
||||
agent = Agent(
|
||||
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=[YouTubeSearchTool, WikipediaAPIWrapper],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
# Create tasks to demonstrate both tools
|
||||
task = 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",
|
||||
agent=agent
|
||||
)
|
||||
|
||||
# Create and start the workflow
|
||||
agents = PraisonAIAgents(
|
||||
agents=[agent],
|
||||
tasks=[task],
|
||||
verbose=True
|
||||
)
|
||||
|
||||
agents.start()
|
||||
@@ -0,0 +1,73 @@
|
||||
from langchain_community.tools import YouTubeSearchTool
|
||||
from langchain_community.utilities import WikipediaAPIWrapper
|
||||
|
||||
def test_tools():
|
||||
"""Test both YouTube and Wikipedia tools"""
|
||||
|
||||
print("\n=== Testing YouTube Search ===")
|
||||
# Test YouTube
|
||||
yt = YouTubeSearchTool()
|
||||
|
||||
# Test basic search
|
||||
print("\nBasic YouTube Search:")
|
||||
query = "AI advancements 2024"
|
||||
print(f"Query: {query}")
|
||||
result = yt.run(query)
|
||||
print(f"Results: {result}")
|
||||
|
||||
# Test with max results
|
||||
print("\nYouTube Search with max results:")
|
||||
query = "AI advancements 2024, 3" # Format: query, max_results
|
||||
print(f"Query: {query}")
|
||||
result = yt.run(query)
|
||||
print(f"Results: {result}")
|
||||
|
||||
print("\n=== Testing Wikipedia Search ===")
|
||||
# Test Wikipedia
|
||||
wiki = WikipediaAPIWrapper(
|
||||
top_k_results=2,
|
||||
doc_content_chars_max=500
|
||||
)
|
||||
|
||||
# Test basic search
|
||||
print("\nBasic Wikipedia Search:")
|
||||
query = "Artificial Intelligence"
|
||||
print(f"Query: {query}")
|
||||
result = wiki.run(query)
|
||||
print(f"Results: {result[:200]}..." if result else "No result")
|
||||
|
||||
# Test with different parameters
|
||||
print("\nWikipedia Search with different language:")
|
||||
wiki_fr = WikipediaAPIWrapper(
|
||||
lang='fr',
|
||||
top_k_results=1,
|
||||
doc_content_chars_max=300
|
||||
)
|
||||
result = wiki_fr.run("Intelligence Artificielle")
|
||||
print(f"French Results: {result[:200]}..." if result else "No result")
|
||||
|
||||
def print_tool_info():
|
||||
"""Print detailed information about the tools"""
|
||||
|
||||
print("\n=== Tool Information ===")
|
||||
|
||||
# YouTube Tool Info
|
||||
print("\nYouTube Tool:")
|
||||
yt = YouTubeSearchTool()
|
||||
print("Type:", type(yt))
|
||||
print("Name:", getattr(yt, 'name', None))
|
||||
print("Description:", getattr(yt, 'description', None))
|
||||
print("Arguments:", getattr(yt, 'args', None))
|
||||
|
||||
# Wikipedia Tool Info
|
||||
print("\nWikipedia Tool:")
|
||||
wiki = WikipediaAPIWrapper()
|
||||
print("Type:", type(wiki))
|
||||
print("Available Settings:")
|
||||
print("- Language:", wiki.lang)
|
||||
print("- Top K Results:", wiki.top_k_results)
|
||||
print("- Max Characters:", wiki.doc_content_chars_max)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print_tool_info()
|
||||
test_tools()
|
||||
@@ -6,6 +6,7 @@ from .agent.agent import Agent
|
||||
from .agents.agents import PraisonAIAgents
|
||||
from .task.task import Task
|
||||
from .tools.tools import Tools
|
||||
from .agents.autoagents import AutoAgents
|
||||
from .main import (
|
||||
TaskOutput,
|
||||
ReflectionOutput,
|
||||
@@ -33,6 +34,7 @@ __all__ = [
|
||||
'Task',
|
||||
'TaskOutput',
|
||||
'ReflectionOutput',
|
||||
'AutoAgents',
|
||||
'display_interaction',
|
||||
'display_self_reflection',
|
||||
'display_instruction',
|
||||
|
||||
@@ -18,6 +18,7 @@ from ..main import (
|
||||
client,
|
||||
error_logs
|
||||
)
|
||||
import inspect
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..task.task import Task
|
||||
@@ -67,9 +68,24 @@ class Agent:
|
||||
return None
|
||||
|
||||
import inspect
|
||||
# Langchain tools
|
||||
if inspect.isclass(func) and hasattr(func, 'run'):
|
||||
original_func = func
|
||||
func = func.run
|
||||
function_name = original_func.__name__
|
||||
|
||||
sig = inspect.signature(func)
|
||||
logging.debug(f"Function signature: {sig}")
|
||||
|
||||
# Skip self, *args, **kwargs, so they don't get passed in arguments
|
||||
parameters_list = []
|
||||
for name, param in sig.parameters.items():
|
||||
if name == "self":
|
||||
continue
|
||||
if param.kind in (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD):
|
||||
continue
|
||||
parameters_list.append((name, param))
|
||||
|
||||
parameters = {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
@@ -95,7 +111,7 @@ class Agent:
|
||||
|
||||
logging.debug(f"Parameter descriptions: {param_descriptions}")
|
||||
|
||||
for name, param in sig.parameters.items():
|
||||
for name, param in parameters_list:
|
||||
param_type = "string" # Default type
|
||||
if param.annotation != inspect.Parameter.empty:
|
||||
if param.annotation == int:
|
||||
@@ -249,25 +265,31 @@ Your Goal: {self.goal}
|
||||
# Try to find the function in the agent's tools list first
|
||||
func = None
|
||||
for tool in self.tools:
|
||||
if callable(tool) and getattr(tool, '__name__', '') == function_name:
|
||||
if (callable(tool) and getattr(tool, '__name__', '') == function_name) or \
|
||||
(inspect.isclass(tool) and tool.__name__ == function_name):
|
||||
func = tool
|
||||
break
|
||||
|
||||
logging.debug(f"Looking for {function_name} in agent tools: {func is not None}")
|
||||
|
||||
# If not found in tools, try globals and main
|
||||
if not func:
|
||||
if func is None:
|
||||
# If not found in tools, try globals and main
|
||||
func = globals().get(function_name)
|
||||
logging.debug(f"Looking for {function_name} in globals: {func is not None}")
|
||||
|
||||
if not func:
|
||||
import __main__
|
||||
func = getattr(__main__, function_name, None)
|
||||
logging.debug(f"Looking for {function_name} in __main__: {func is not None}")
|
||||
|
||||
if func and callable(func):
|
||||
if func:
|
||||
try:
|
||||
return func(**arguments)
|
||||
# If it's a class with run method, instantiate and call run
|
||||
if inspect.isclass(func) and hasattr(func, 'run'):
|
||||
instance = func()
|
||||
# Extract only the parameters that run() expects
|
||||
run_params = {k: v for k, v in arguments.items()
|
||||
if k in inspect.signature(instance.run).parameters
|
||||
and k != 'self'}
|
||||
return instance.run(**run_params)
|
||||
# Otherwise treat as regular function
|
||||
elif callable(func):
|
||||
return func(**arguments)
|
||||
except Exception as e:
|
||||
error_msg = str(e)
|
||||
logging.error(f"Error executing tool {function_name}: {error_msg}")
|
||||
@@ -711,4 +733,8 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
|
||||
return None
|
||||
except Exception as e:
|
||||
display_error(f"Error in _achat_completion: {e}")
|
||||
return None
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
"""Alias for start() method"""
|
||||
return self.start()
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Agents module for managing multiple AI agents"""
|
||||
from .agents import PraisonAIAgents
|
||||
from .autoagents import AutoAgents
|
||||
|
||||
__all__ = ['PraisonAIAgents']
|
||||
__all__ = ['PraisonAIAgents', 'AutoAgents']
|
||||
@@ -0,0 +1,335 @@
|
||||
"""
|
||||
AutoAgents - A class for automatically creating and managing AI agents and tasks.
|
||||
|
||||
This class provides a simplified interface for creating and running AI agents with tasks.
|
||||
It automatically handles agent creation, task setup, and execution flow.
|
||||
"""
|
||||
|
||||
from .agents import PraisonAIAgents
|
||||
from ..agent.agent import Agent
|
||||
from ..task.task import Task
|
||||
from typing import List, Any, Optional, Dict, Union
|
||||
import logging
|
||||
import os
|
||||
from pydantic import BaseModel, Field
|
||||
from ..main import display_instruction, display_tool_call, display_interaction, client
|
||||
|
||||
# Define Pydantic models for structured output
|
||||
class TaskConfig(BaseModel):
|
||||
name: str
|
||||
description: str
|
||||
expected_output: str
|
||||
tools: List[str]
|
||||
|
||||
class AgentConfig(BaseModel):
|
||||
name: str
|
||||
role: str
|
||||
goal: str
|
||||
backstory: str
|
||||
tools: List[str]
|
||||
tasks: List[TaskConfig]
|
||||
|
||||
class AutoAgentsConfig(BaseModel):
|
||||
main_instruction: str
|
||||
process_type: str
|
||||
agents: List[AgentConfig]
|
||||
|
||||
class AutoAgents(PraisonAIAgents):
|
||||
def __init__(
|
||||
self,
|
||||
instructions: str,
|
||||
tools: Optional[List[Any]] = None,
|
||||
verbose: bool = False,
|
||||
process: str = "sequential",
|
||||
manager_llm: Optional[str] = None,
|
||||
max_retries: int = 5,
|
||||
completion_checker: Optional[Any] = None,
|
||||
allow_code_execution: bool = False,
|
||||
memory: bool = True,
|
||||
markdown: bool = True,
|
||||
self_reflect: bool = False,
|
||||
max_reflect: int = 3,
|
||||
min_reflect: int = 1,
|
||||
llm: Optional[str] = None,
|
||||
function_calling_llm: Optional[str] = None,
|
||||
respect_context_window: bool = True,
|
||||
code_execution_mode: str = "safe",
|
||||
embedder_config: Optional[Dict[str, Any]] = None,
|
||||
knowledge_sources: Optional[List[Any]] = None,
|
||||
use_system_prompt: bool = True,
|
||||
cache: bool = True,
|
||||
allow_delegation: bool = False,
|
||||
step_callback: Optional[Any] = None,
|
||||
system_template: Optional[str] = None,
|
||||
prompt_template: Optional[str] = None,
|
||||
response_template: Optional[str] = None,
|
||||
max_rpm: Optional[int] = None,
|
||||
max_execution_time: Optional[int] = None,
|
||||
max_iter: int = 20,
|
||||
reflect_llm: Optional[str] = None,
|
||||
base_url: Optional[str] = None,
|
||||
api_key: Optional[str] = None,
|
||||
max_agents: int = 3 # New parameter for maximum number of agents
|
||||
):
|
||||
"""Initialize AutoAgents with configuration for automatic agent and task creation."""
|
||||
if max_agents < 1:
|
||||
raise ValueError("max_agents must be at least 1")
|
||||
if max_agents > 10:
|
||||
raise ValueError("max_agents cannot exceed 10")
|
||||
|
||||
# Store all configuration parameters first
|
||||
self.instructions = instructions
|
||||
self.tools = tools or []
|
||||
self.verbose = verbose # Store verbose parameter
|
||||
self.max_agents = max_agents # Store max_agents parameter
|
||||
self.allow_code_execution = allow_code_execution
|
||||
self.memory = memory
|
||||
self.markdown = markdown
|
||||
self.self_reflect = self_reflect
|
||||
self.max_reflect = max_reflect
|
||||
self.min_reflect = min_reflect
|
||||
self.llm = llm or os.getenv('OPENAI_MODEL_NAME', 'gpt-4o')
|
||||
self.function_calling_llm = function_calling_llm
|
||||
self.respect_context_window = respect_context_window
|
||||
self.code_execution_mode = code_execution_mode
|
||||
self.embedder_config = embedder_config
|
||||
self.knowledge_sources = knowledge_sources
|
||||
self.use_system_prompt = use_system_prompt
|
||||
self.cache = cache
|
||||
self.allow_delegation = allow_delegation
|
||||
self.step_callback = step_callback
|
||||
self.system_template = system_template
|
||||
self.prompt_template = prompt_template
|
||||
self.response_template = response_template
|
||||
self.max_rpm = max_rpm
|
||||
self.max_execution_time = max_execution_time
|
||||
self.max_iter = max_iter
|
||||
self.reflect_llm = reflect_llm
|
||||
|
||||
# Display initial instruction
|
||||
if self.verbose:
|
||||
display_instruction(f"🎯 Main Task: {self.instructions}")
|
||||
display_instruction(f"📊 Maximum Agents: {self.max_agents}")
|
||||
if self.tools:
|
||||
tool_names = [t.__name__ if hasattr(t, '__name__') else str(t) for t in self.tools]
|
||||
display_tool_call(f"🛠️ Available Tools: {', '.join(tool_names)}")
|
||||
|
||||
# Generate agents and tasks configuration
|
||||
config = self._generate_config()
|
||||
agents, tasks = self._create_agents_and_tasks(config)
|
||||
|
||||
# Display agents and their tasks
|
||||
if self.verbose:
|
||||
self._display_agents_and_tasks(agents, tasks)
|
||||
|
||||
# Initialize parent class with generated agents and tasks
|
||||
super().__init__(
|
||||
agents=agents,
|
||||
tasks=tasks,
|
||||
verbose=verbose,
|
||||
completion_checker=completion_checker,
|
||||
max_retries=max_retries,
|
||||
process=process,
|
||||
manager_llm=manager_llm
|
||||
)
|
||||
|
||||
def _display_agents_and_tasks(self, agents: List[Agent], tasks: List[Task]):
|
||||
"""Display the created agents and their assigned tasks"""
|
||||
display_instruction("\n🤖 Generated Agents and Tasks:")
|
||||
|
||||
# Create a mapping of agents to their tasks
|
||||
agent_tasks = {}
|
||||
for task in tasks:
|
||||
if task.agent not in agent_tasks:
|
||||
agent_tasks[task.agent] = []
|
||||
agent_tasks[task.agent].append(task)
|
||||
|
||||
# Display each agent and their tasks
|
||||
for agent in agents:
|
||||
agent_tools = [t.__name__ if hasattr(t, '__name__') else str(t) for t in agent.tools]
|
||||
display_interaction(
|
||||
f"\n👤 Agent: {agent.name}",
|
||||
f"""Role: {agent.role}
|
||||
Goal: {agent.goal}
|
||||
Tools: {', '.join(agent_tools)}"""
|
||||
)
|
||||
|
||||
# Display tasks for this agent
|
||||
if agent in agent_tasks:
|
||||
for i, task in enumerate(agent_tasks[agent], 1):
|
||||
task_tools = [t.__name__ if hasattr(t, '__name__') else str(t) for t in task.tools]
|
||||
display_instruction(
|
||||
f""" 📋 Task {i}: {task.name}
|
||||
Description: {task.description}
|
||||
Expected Output: {task.expected_output}
|
||||
Tools: {', '.join(task_tools)}"""
|
||||
)
|
||||
|
||||
def _get_available_tools(self) -> List[str]:
|
||||
"""Get list of available tools"""
|
||||
if not self.tools:
|
||||
return []
|
||||
return [t.__name__ if hasattr(t, '__name__') else str(t) for t in self.tools]
|
||||
|
||||
def _get_tool_by_name(self, tool_name: str) -> Optional[Any]:
|
||||
"""Get tool object by its name"""
|
||||
for tool in self.tools:
|
||||
if (hasattr(tool, '__name__') and tool.__name__ == tool_name) or str(tool) == tool_name:
|
||||
return tool
|
||||
return None
|
||||
|
||||
def _assign_tools_to_agent(self, agent_config: AgentConfig) -> List[Any]:
|
||||
"""
|
||||
Assign appropriate tools to an agent based on its role and tasks.
|
||||
|
||||
Args:
|
||||
agent_config: The agent configuration containing role and required tools
|
||||
|
||||
Returns:
|
||||
List of tool objects assigned to this agent
|
||||
"""
|
||||
assigned_tools = []
|
||||
tool_names = set(agent_config.tools)
|
||||
|
||||
# Also look at task requirements
|
||||
for task in agent_config.tasks:
|
||||
tool_names.update(task.tools)
|
||||
|
||||
# Assign tools that match the requirements
|
||||
for tool_name in tool_names:
|
||||
tool = self._get_tool_by_name(tool_name)
|
||||
if tool:
|
||||
assigned_tools.append(tool)
|
||||
|
||||
# If no specific tools matched but we have tools available,
|
||||
# assign all tools to ensure functionality
|
||||
if not assigned_tools and self.tools:
|
||||
assigned_tools = self.tools
|
||||
|
||||
return assigned_tools
|
||||
|
||||
def _generate_config(self) -> AutoAgentsConfig:
|
||||
"""Generate the configuration for agents and tasks"""
|
||||
prompt = f"""
|
||||
Generate a configuration for AI agents to accomplish this task: "{self.instructions}"
|
||||
|
||||
The configuration should include:
|
||||
1. A main instruction that clearly states the overall goal
|
||||
2. A process type (sequential, workflow, or hierarchical)
|
||||
3. A list of maximum {self.max_agents} agents (no more, no less), each with:
|
||||
- Name, role, goal, and backstory
|
||||
- List of required tools from: {self._get_available_tools()}
|
||||
- Only add tools that are needed for the agent to perform its task
|
||||
- Only one task per agent. Add more than one task if absolutely necessary.
|
||||
- List of specific tasks they need to perform
|
||||
- Whether they should self-reflect or allow delegation
|
||||
|
||||
Requirements:
|
||||
1. Each agent should have clear, focused responsibilities
|
||||
2. Tasks should be broken down into manageable steps
|
||||
3. Tool selection should be appropriate for each task
|
||||
4. The process type should match the task requirements
|
||||
5. Generate maximum {self.max_agents} agents to handle this task efficiently
|
||||
|
||||
Return the configuration in a structured JSON format matching the AutoAgentsConfig schema.
|
||||
"""
|
||||
|
||||
try:
|
||||
response = client.beta.chat.completions.parse(
|
||||
model=self.llm,
|
||||
response_format=AutoAgentsConfig,
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant designed to generate AI agent configurations."},
|
||||
{"role": "user", "content": prompt}
|
||||
]
|
||||
)
|
||||
|
||||
# Ensure we have exactly max_agents number of agents
|
||||
if len(response.choices[0].message.parsed.agents) > self.max_agents:
|
||||
response.choices[0].message.parsed.agents = response.choices[0].message.parsed.agents[:self.max_agents]
|
||||
elif len(response.choices[0].message.parsed.agents) < self.max_agents:
|
||||
logging.warning(f"Generated {len(response.choices[0].message.parsed.agents)} agents, expected {self.max_agents}")
|
||||
|
||||
return response.choices[0].message.parsed
|
||||
except Exception as e:
|
||||
logging.error(f"Error generating configuration: {e}")
|
||||
raise
|
||||
|
||||
def _create_agents_and_tasks(self, config: AutoAgentsConfig) -> tuple[List[Agent], List[Task]]:
|
||||
"""Create agents and tasks from configuration"""
|
||||
agents = []
|
||||
tasks = []
|
||||
|
||||
for agent_config in config.agents:
|
||||
# Get appropriate tools for this agent
|
||||
agent_tools = self._assign_tools_to_agent(agent_config)
|
||||
|
||||
# Create the agent with all parameters
|
||||
agent = Agent(
|
||||
name=agent_config.name,
|
||||
role=agent_config.role,
|
||||
goal=agent_config.goal,
|
||||
backstory=agent_config.backstory,
|
||||
tools=agent_tools, # Use assigned tools
|
||||
verbose=self.verbose >= 1,
|
||||
allow_code_execution=self.allow_code_execution,
|
||||
memory=self.memory,
|
||||
markdown=self.markdown,
|
||||
self_reflect=self.self_reflect,
|
||||
max_reflect=self.max_reflect,
|
||||
min_reflect=self.min_reflect,
|
||||
llm=self.llm,
|
||||
function_calling_llm=self.function_calling_llm,
|
||||
respect_context_window=self.respect_context_window,
|
||||
code_execution_mode=self.code_execution_mode,
|
||||
embedder_config=self.embedder_config,
|
||||
knowledge_sources=self.knowledge_sources,
|
||||
use_system_prompt=self.use_system_prompt,
|
||||
cache=self.cache,
|
||||
allow_delegation=self.allow_delegation,
|
||||
step_callback=self.step_callback,
|
||||
system_template=self.system_template,
|
||||
prompt_template=self.prompt_template,
|
||||
response_template=self.response_template,
|
||||
max_rpm=self.max_rpm,
|
||||
max_execution_time=self.max_execution_time,
|
||||
max_iter=self.max_iter,
|
||||
reflect_llm=self.reflect_llm
|
||||
)
|
||||
agents.append(agent)
|
||||
|
||||
# Create tasks for this agent
|
||||
for task_config in agent_config.tasks:
|
||||
# Get task-specific tools
|
||||
task_tools = [self._get_tool_by_name(t) for t in task_config.tools]
|
||||
task_tools = [t for t in task_tools if t] # Remove None values
|
||||
|
||||
# If no specific tools matched, use agent's tools
|
||||
if not task_tools:
|
||||
task_tools = agent_tools
|
||||
|
||||
task = Task(
|
||||
name=task_config.name,
|
||||
description=task_config.description,
|
||||
expected_output=task_config.expected_output,
|
||||
agent=agent,
|
||||
tools=task_tools # Use task-specific tools
|
||||
)
|
||||
tasks.append(task)
|
||||
|
||||
return agents, tasks
|
||||
|
||||
async def astart(self):
|
||||
"""
|
||||
Async version of start() method.
|
||||
Creates tasks based on the instructions, then starts execution.
|
||||
Returns the task status and results dictionary.
|
||||
"""
|
||||
return await super().astart()
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Creates tasks based on the instructions, then starts execution.
|
||||
Returns the task status and results dictionary.
|
||||
"""
|
||||
return super().start()
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.26"
|
||||
version = "0.0.28"
|
||||
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
|
||||
authors = [
|
||||
{ name="Mervin Praison" }
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
from praisonaiagents import Agent
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional
|
||||
|
||||
# Define structured output models
|
||||
class SearchResult(BaseModel):
|
||||
title: str
|
||||
url: Optional[str]
|
||||
snippet: str
|
||||
|
||||
class AnalysisReport(BaseModel):
|
||||
topic: str
|
||||
key_findings: List[str]
|
||||
search_results: List[SearchResult]
|
||||
summary: str
|
||||
confidence_score: float
|
||||
|
||||
def get_structured_analysis(query: str, verbose: bool = True) -> AnalysisReport:
|
||||
"""
|
||||
Performs a search and returns a structured analysis using an AI agent.
|
||||
|
||||
Args:
|
||||
query (str): The search query or topic to analyze
|
||||
verbose (bool): Whether to show detailed output
|
||||
|
||||
Returns:
|
||||
AnalysisReport: A structured report containing the analysis
|
||||
"""
|
||||
# Create an agent with search capabilities
|
||||
agent = Agent(
|
||||
name="StructuredAnalyst",
|
||||
role="Research Analyst",
|
||||
goal="Analyze topics and provide structured reports",
|
||||
backstory="Expert at gathering information and providing structured analysis",
|
||||
verbose=verbose,
|
||||
self_reflect=True, # Enable self-reflection for better quality
|
||||
markdown=True
|
||||
)
|
||||
|
||||
# Create the analysis prompt
|
||||
prompt = f"""
|
||||
Analyze the following topic: "{query}"
|
||||
|
||||
Provide a structured analysis in JSON format that matches this schema:
|
||||
{{
|
||||
"topic": "string",
|
||||
"key_findings": ["string"],
|
||||
"search_results": [
|
||||
{{
|
||||
"title": "string",
|
||||
"url": "string",
|
||||
"snippet": "string"
|
||||
}}
|
||||
],
|
||||
"summary": "string",
|
||||
"confidence_score": float (0-1)
|
||||
}}
|
||||
|
||||
Requirements:
|
||||
1. Include at least 3 key findings
|
||||
2. Include at least 2 relevant search results
|
||||
3. Provide a comprehensive summary
|
||||
4. Set confidence score based on quality of sources (0-1)
|
||||
|
||||
Return ONLY the JSON object, no other text.
|
||||
"""
|
||||
|
||||
# Get structured response from agent
|
||||
response = agent.chat(
|
||||
prompt=prompt,
|
||||
output_json=AnalysisReport # This ensures response matches our model
|
||||
)
|
||||
|
||||
return AnalysisReport.parse_raw(response)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Example usage
|
||||
analysis = get_structured_analysis("Latest developments in AI agents and autonomous systems")
|
||||
print(analysis)
|
||||
# Print the structured results
|
||||
print("\n=== Structured Analysis Report ===")
|
||||
print(f"Topic: {analysis.topic}")
|
||||
print("\nKey Findings:")
|
||||
for i, finding in enumerate(analysis.key_findings, 1):
|
||||
print(f"{i}. {finding}")
|
||||
|
||||
print("\nSearch Results:")
|
||||
for result in analysis.search_results:
|
||||
print(f"\nTitle: {result.title}")
|
||||
print(f"URL: {result.url}")
|
||||
print(f"Snippet: {result.snippet}")
|
||||
|
||||
print(f"\nSummary: {analysis.summary}")
|
||||
print(f"Confidence Score: {analysis.confidence_score:.2f}")
|
||||
Generated
+1
-1
@@ -186,7 +186,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.26"
|
||||
version = "0.0.28"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "openai" },
|
||||
|
||||
@@ -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.35 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.37 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
---
|
||||
title: "AutoAgents Module"
|
||||
description: "Documentation for the praisonaiagents.agents.autoagents module"
|
||||
icon: "robot"
|
||||
---
|
||||
|
||||
# Module praisonaiagents.agents.autoagents
|
||||
|
||||
The AutoAgents module provides automatic creation and management of AI agents and tasks based on high-level instructions.
|
||||
|
||||
## Classes
|
||||
|
||||
### AutoAgents
|
||||
The main class for automatically creating and managing AI agents and tasks.
|
||||
|
||||
#### Parameters
|
||||
- `instructions: str` - High-level task description for the agents
|
||||
- `tools: Optional[List[Any]] = None` - List of tools available to the agents
|
||||
- `verbose: bool = False` - Enable detailed logging
|
||||
- `process: str = "sequential"` - Process type (sequential or hierarchical)
|
||||
- `manager_llm: Optional[str] = None` - Language model for manager agent
|
||||
- `max_retries: int = 5` - Maximum retry attempts
|
||||
- `completion_checker: Optional[Any] = None` - Custom completion checker
|
||||
- `allow_code_execution: bool = False` - Allow code execution
|
||||
- `memory: bool = True` - Enable agent memory
|
||||
- `markdown: bool = True` - Enable markdown formatting
|
||||
- `self_reflect: bool = False` - Enable agent self-reflection
|
||||
- `max_reflect: int = 3` - Maximum reflection iterations
|
||||
- `min_reflect: int = 1` - Minimum reflection iterations
|
||||
- `llm: Optional[str] = None` - Language model for agents
|
||||
- `function_calling_llm: Optional[str] = None` - Language model for tool calling
|
||||
- `respect_context_window: bool = True` - Respect model context window
|
||||
- `code_execution_mode: str = "safe"` - Code execution mode (safe/unsafe)
|
||||
- `embedder_config: Optional[Dict[str, Any]] = None` - Embedder configuration
|
||||
- `knowledge_sources: Optional[List[Any]] = None` - Knowledge sources
|
||||
- `use_system_prompt: bool = True` - Use system prompts
|
||||
- `cache: bool = True` - Enable caching
|
||||
- `allow_delegation: bool = False` - Allow task delegation
|
||||
- `step_callback: Optional[Any] = None` - Callback for each step
|
||||
- `system_template: Optional[str] = None` - Custom system template
|
||||
- `prompt_template: Optional[str] = None` - Custom prompt template
|
||||
- `response_template: Optional[str] = None` - Custom response template
|
||||
- `max_rpm: Optional[int] = None` - Maximum requests per minute
|
||||
- `max_execution_time: Optional[int] = None` - Maximum execution time
|
||||
- `max_iter: int = 20` - Maximum iterations
|
||||
- `reflect_llm: Optional[str] = None` - Language model for reflection
|
||||
- `max_agents: int = 3` - Maximum number of agents to create
|
||||
|
||||
#### Methods
|
||||
|
||||
##### start()
|
||||
Start the agents synchronously.
|
||||
|
||||
```python
|
||||
def start(self):
|
||||
"""
|
||||
Creates tasks based on the instructions, then starts execution.
|
||||
Returns the task status and results dictionary.
|
||||
"""
|
||||
return super().start()
|
||||
```
|
||||
|
||||
##### astart()
|
||||
Start the agents asynchronously.
|
||||
|
||||
```python
|
||||
async def astart(self):
|
||||
"""
|
||||
Async version of start() method.
|
||||
Creates tasks based on the instructions, then starts execution.
|
||||
Returns the task status and results dictionary.
|
||||
"""
|
||||
return await super().astart()
|
||||
```
|
||||
|
||||
#### Internal Methods
|
||||
|
||||
##### _generate_config()
|
||||
Generate the configuration for agents and tasks.
|
||||
|
||||
```python
|
||||
def _generate_config(self) -> AutoAgentsConfig:
|
||||
"""
|
||||
Generate the configuration for agents and tasks based on instructions.
|
||||
Returns AutoAgentsConfig object containing agent and task configurations.
|
||||
"""
|
||||
```
|
||||
|
||||
##### _create_agents_and_tasks()
|
||||
Create agents and tasks from configuration.
|
||||
|
||||
```python
|
||||
def _create_agents_and_tasks(self, config: AutoAgentsConfig) -> tuple[List[Agent], List[Task]]:
|
||||
"""
|
||||
Create agents and tasks based on the generated configuration.
|
||||
Returns tuple of (agents, tasks).
|
||||
"""
|
||||
```
|
||||
|
||||
##### _assign_tools_to_agent()
|
||||
Assign appropriate tools to an agent.
|
||||
|
||||
```python
|
||||
def _assign_tools_to_agent(self, agent_config: AgentConfig) -> List[Any]:
|
||||
"""
|
||||
Assign tools to an agent based on its role and tasks.
|
||||
Returns list of assigned tools.
|
||||
"""
|
||||
```
|
||||
|
||||
## Pydantic Models
|
||||
|
||||
### TaskConfig
|
||||
Configuration for a task.
|
||||
|
||||
#### Attributes
|
||||
- `name: str` - Task name
|
||||
- `description: str` - Task description
|
||||
- `expected_output: str` - Expected output description
|
||||
- `tools: List[str]` - Required tools for the task
|
||||
|
||||
### AgentConfig
|
||||
Configuration for an agent.
|
||||
|
||||
#### Attributes
|
||||
- `name: str` - Agent name
|
||||
- `role: str` - Agent role
|
||||
- `goal: str` - Agent goal
|
||||
- `backstory: str` - Agent backstory
|
||||
- `tools: List[str]` - Required tools
|
||||
- `tasks: List[TaskConfig]` - Tasks assigned to the agent
|
||||
|
||||
### AutoAgentsConfig
|
||||
Overall configuration for AutoAgents.
|
||||
|
||||
#### Attributes
|
||||
- `main_instruction: str` - Main instruction for the agents
|
||||
- `process_type: str` - Process type (sequential/hierarchical)
|
||||
- `agents: List[AgentConfig]` - List of agent configurations
|
||||
|
||||
## Example Usage
|
||||
|
||||
### Basic Usage
|
||||
```python
|
||||
from praisonaiagents import AutoAgents
|
||||
from praisonaiagents.tools import SerperDevTool
|
||||
|
||||
agents = AutoAgents(
|
||||
instructions="Research recent AI developments",
|
||||
tools=[SerperDevTool()],
|
||||
verbose=True
|
||||
)
|
||||
result = agents.start()
|
||||
```
|
||||
|
||||
### Async Usage
|
||||
```python
|
||||
async def main():
|
||||
agents = AutoAgents(
|
||||
instructions="Research recent AI developments",
|
||||
tools=[SerperDevTool()],
|
||||
process="hierarchical"
|
||||
)
|
||||
result = await agents.astart()
|
||||
|
||||
import asyncio
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
### Advanced Configuration
|
||||
```python
|
||||
agents = AutoAgents(
|
||||
instructions="Complex research task",
|
||||
tools=[SerperDevTool()],
|
||||
max_agents=5,
|
||||
process="hierarchical",
|
||||
manager_llm="gpt-4o",
|
||||
memory=True,
|
||||
allow_delegation=True,
|
||||
max_execution_time=600,
|
||||
self_reflect=True
|
||||
)
|
||||
```
|
||||
|
||||
<Note>
|
||||
For optimal results, provide clear instructions and appropriate tools for your use case.
|
||||
</Note>
|
||||
@@ -0,0 +1,281 @@
|
||||
---
|
||||
title: "AutoAgents"
|
||||
description: "AutoAgents automatically creates and manages AI agents and tasks based on high-level instructions."
|
||||
icon: "robot"
|
||||
---
|
||||
|
||||
<Note>
|
||||
**Requirements**
|
||||
|
||||
- Python 3.10 or higher
|
||||
- OpenAI API key
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Package">
|
||||
First, install the PraisonAI Agents package:
|
||||
```bash
|
||||
pip install praisonaiagents
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Set API Key">
|
||||
Set your OpenAI API key as an environment variable:
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_api_key_here
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create Project">
|
||||
Create a new file `app.py` with the basic setup:
|
||||
```python
|
||||
from praisonaiagents import AutoAgents
|
||||
from praisonaiagents.tools import duckduckgo
|
||||
|
||||
# Create AutoAgents instance
|
||||
agents = AutoAgents(
|
||||
instructions="Search for information about AI Agents",
|
||||
tools=[duckduckgo],
|
||||
process="sequential",
|
||||
verbose=True,
|
||||
max_agents=3 # Maximum number of agents to create
|
||||
)
|
||||
|
||||
# Start the agents
|
||||
result = agents.start()
|
||||
print(result)
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run the Program">
|
||||
Run your AutoAgents:
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Understanding AutoAgents
|
||||
|
||||
<Card title="What are AutoAgents?" icon="question">
|
||||
AutoAgents automatically:
|
||||
- Creates appropriate AI agents based on your instructions
|
||||
- Assigns relevant tools to each agent
|
||||
- Breaks down tasks into manageable steps
|
||||
- Manages execution flow between agents
|
||||
- Handles agent coordination and task delegation
|
||||
</Card>
|
||||
|
||||
<CodeGroup>
|
||||
```python Basic
|
||||
# Basic usage with default settings
|
||||
agents = AutoAgents(
|
||||
instructions="Your high-level task description",
|
||||
tools=[tool1, tool2]
|
||||
)
|
||||
```
|
||||
|
||||
```python Advanced
|
||||
# Advanced usage with custom settings
|
||||
agents = AutoAgents(
|
||||
instructions="Your task description",
|
||||
tools=[tool1, tool2],
|
||||
max_agents=3,
|
||||
process="hierarchical",
|
||||
verbose=True,
|
||||
memory=True,
|
||||
allow_delegation=True
|
||||
)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Features
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Automatic Agent Creation" icon="wand-magic-sparkles">
|
||||
Creates specialized agents based on task requirements.
|
||||
</Card>
|
||||
<Card title="Smart Tool Assignment" icon="toolbox">
|
||||
Automatically assigns relevant tools to each agent.
|
||||
</Card>
|
||||
<Card title="Task Management" icon="list-check">
|
||||
Breaks down complex tasks into manageable steps.
|
||||
</Card>
|
||||
<Card title="Process Optimization" icon="gauge-high">
|
||||
Chooses optimal execution process (sequential/hierarchical).
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Configuration Options
|
||||
|
||||
```python
|
||||
|
||||
# Create AutoAgents with advanced configuration
|
||||
agents = AutoAgents(
|
||||
instructions="Research and summarize recent AI developments",
|
||||
tools=[SerperDevTool, WikipediaTools],
|
||||
max_agents=3, # Maximum number of agents to create
|
||||
verbose=True, # Enable detailed logging
|
||||
process="hierarchical", # Use hierarchical process
|
||||
memory=True, # Enable memory for agents
|
||||
allow_delegation=True, # Allow task delegation
|
||||
max_rpm=60, # Maximum requests per minute
|
||||
max_execution_time=300, # Maximum execution time in seconds
|
||||
allow_code_execution=True, # Allow code execution
|
||||
code_execution_mode="safe", # Use safe mode for code execution
|
||||
self_reflect=True, # Enable agent self-reflection
|
||||
markdown=True # Enable markdown formatting
|
||||
)
|
||||
```
|
||||
|
||||
### Process Types
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Sequential Process">
|
||||
```python
|
||||
# Tasks are executed in sequence
|
||||
agents = AutoAgents(
|
||||
instructions="Your task",
|
||||
process="sequential"
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Hierarchical Process">
|
||||
```python
|
||||
# Manager agent coordinates other agents
|
||||
agents = AutoAgents(
|
||||
instructions="Your task",
|
||||
process="hierarchical",
|
||||
manager_llm="gpt-4o" # Specify LLM for manager
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
## Best Practices
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Clear Instructions">
|
||||
```python
|
||||
# Good instruction example
|
||||
agents = AutoAgents(
|
||||
instructions="""
|
||||
Research the latest developments in AI for 2024:
|
||||
1. Focus on breakthrough technologies
|
||||
2. Include real-world applications
|
||||
3. Consider future implications
|
||||
"""
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Tool Selection">
|
||||
```python
|
||||
# Provide relevant tools for the task
|
||||
|
||||
agents = AutoAgents(
|
||||
instructions="Research task",
|
||||
tools=[
|
||||
SerperDevTool, # For web search
|
||||
WikipediaTools, # For background info
|
||||
CustomTool # Your custom tool
|
||||
]
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Resource Management">
|
||||
|
||||
```python
|
||||
# Configure resource limits
|
||||
agents = AutoAgents(
|
||||
instructions="Your task",
|
||||
max_rpm=60, # Rate limiting
|
||||
max_execution_time=300, # Timeout
|
||||
max_agents=3 # Agent limit
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Tool Assignment Issues" icon="triangle-exclamation">
|
||||
If tools aren't being assigned correctly:
|
||||
- Check tool compatibility
|
||||
- Verify tool names
|
||||
- Enable verbose mode for debugging
|
||||
</Card>
|
||||
|
||||
<Card title="Performance Issues" icon="gauge">
|
||||
If execution is slow:
|
||||
- Reduce max_agents
|
||||
- Adjust max_rpm
|
||||
- Consider process type
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## API Reference
|
||||
|
||||
### Main Parameters
|
||||
|
||||
<ResponseField name="instructions" type="str" required>
|
||||
High-level task description for the agents
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tools" type="List[Any]">
|
||||
List of tools available to the agents
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="max_agents" type="int" default="3">
|
||||
Maximum number of agents to create
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="process" type="str" default="sequential">
|
||||
Process type: "sequential" or "hierarchical"
|
||||
</ResponseField>
|
||||
|
||||
### Optional Parameters
|
||||
|
||||
<ResponseField name="verbose" type="bool" default="False">
|
||||
Enable detailed logging
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="memory" type="bool" default="True">
|
||||
Enable agent memory
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="allow_delegation" type="bool" default="False">
|
||||
Allow agents to delegate tasks
|
||||
</ResponseField>
|
||||
|
||||
### Methods
|
||||
|
||||
<ResponseField name="start()" type="method">
|
||||
Start the agents synchronously
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="astart()" type="method">
|
||||
Start the agents asynchronously
|
||||
</ResponseField>
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Examples" icon="code" href="./examples">
|
||||
Explore more examples in our examples directory
|
||||
</Card>
|
||||
<Card title="Custom Tools" icon="screwdriver-wrench" href="./tools">
|
||||
Learn how to create custom tools for your agents
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Note>
|
||||
For optimal results, provide clear instructions and appropriate tools for your use case.
|
||||
</Note>
|
||||
@@ -79,6 +79,7 @@
|
||||
{
|
||||
"group": "Features",
|
||||
"pages": [
|
||||
"features/autoagents",
|
||||
"features/selfreflection",
|
||||
"features/reasoning",
|
||||
"framework/multimodalagents",
|
||||
@@ -193,6 +194,7 @@
|
||||
"api/praisonaiagents/index",
|
||||
"api/praisonaiagents/agent/agent",
|
||||
"api/praisonaiagents/agents/agents",
|
||||
"api/praisonaiagents/agents/autoagents",
|
||||
"api/praisonaiagents/task/task",
|
||||
"api/praisonaiagents/process/process"
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "arXiv Tools"
|
||||
description: "Scientific paper search and retrieval tools for AI agents."
|
||||
icon: "book"
|
||||
title: "arXiv Agent"
|
||||
description: "arXiv research paper search and analysis tools for AI agents."
|
||||
icon: "book-open"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -11,9 +11,9 @@ icon: "book"
|
||||
- `arxiv` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## arXiv Tools
|
||||
|
||||
Use arXiv Tools to search and retrieve scientific papers with AI agents.
|
||||
Use arXiv Tools to search and analyze research papers with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
|
||||
+194
-272
@@ -1,294 +1,216 @@
|
||||
---
|
||||
title: "Calculator Tools"
|
||||
description: "Tools for performing mathematical calculations, unit conversions, and financial computations."
|
||||
title: "Calculator Agent"
|
||||
description: "Mathematical calculation tools for AI agents."
|
||||
icon: "calculator"
|
||||
---
|
||||
|
||||
## Available Functions
|
||||
<Note>
|
||||
**Prerequisites**
|
||||
- Python 3.10 or higher
|
||||
- PraisonAI Agents package installed
|
||||
- `sympy` and `pint` packages installed
|
||||
</Note>
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import (
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
)
|
||||
```
|
||||
## Calculator Tools
|
||||
|
||||
## Example Code
|
||||
Use Calculator Tools to perform mathematical calculations with AI agents.
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import (
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
)
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
First, install the required packages:
|
||||
```bash
|
||||
pip install praisonaiagents sympy pint
|
||||
```
|
||||
</Step>
|
||||
|
||||
agent = Agent(
|
||||
name="MathAssistant",
|
||||
tools=[
|
||||
<Step title="Import Components">
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import (
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
]
|
||||
)
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
task = Task(
|
||||
description="Calculate the area of a circle with radius 5",
|
||||
expected_output="The area of the circle is 78.54 square units",
|
||||
agent=agent,
|
||||
name="calculate_circle_area"
|
||||
)
|
||||
<Step title="Create Agent">
|
||||
Create a calculator agent:
|
||||
```python
|
||||
calculator_agent = Agent(
|
||||
name="MathAssistant",
|
||||
role="Mathematical Computation Specialist",
|
||||
goal="Perform accurate mathematical calculations and solve equations.",
|
||||
backstory="Expert in mathematical computations and problem-solving.",
|
||||
tools=[
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Define Task">
|
||||
Define the calculation task:
|
||||
```python
|
||||
calc_task = Task(
|
||||
description="Calculate the area of a circle with radius 5",
|
||||
expected_output="The area of the circle in square units",
|
||||
agent=calculator_agent,
|
||||
name="circle_area"
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
# Run agent
|
||||
agents = PraisonAIAgents(
|
||||
agents=[agent],
|
||||
tasks=[task],
|
||||
process="sequential"
|
||||
)
|
||||
agents.start()
|
||||
```
|
||||
<Step title="Run Agent">
|
||||
Initialize and run the agent:
|
||||
```python
|
||||
agents = PraisonAIAgents(
|
||||
agents=[calculator_agent],
|
||||
tasks=[calc_task],
|
||||
process="sequential"
|
||||
)
|
||||
agents.start()
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Function Details
|
||||
## Understanding Calculator Tools
|
||||
|
||||
### evaluate(expression: str, variables: Optional[Dict[str, float]] = None, precision: int = 10)
|
||||
<Card title="What are Calculator Tools?" icon="question">
|
||||
Calculator Tools provide mathematical computation capabilities for AI agents:
|
||||
- Expression evaluation
|
||||
- Equation solving
|
||||
- Unit conversions
|
||||
- Support for mathematical functions
|
||||
- Variable substitution
|
||||
</Card>
|
||||
|
||||
Evaluate mathematical expressions:
|
||||
- Basic arithmetic
|
||||
- Mathematical functions
|
||||
- Variable substitution
|
||||
- Precision control
|
||||
- Error handling
|
||||
## Key Components
|
||||
|
||||
```python
|
||||
# Basic arithmetic
|
||||
result = evaluate("2 + 2 * 3")
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Expression Evaluation" icon="function">
|
||||
Evaluate mathematical expressions:
|
||||
```python
|
||||
result = evaluate("2 + 2 * 3")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Equation Solving" icon="equals">
|
||||
Solve mathematical equations:
|
||||
```python
|
||||
result = solve_equation("2*x + 3 = 7")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Unit Conversions" icon="exchange">
|
||||
Convert between units:
|
||||
```python
|
||||
result = convert_units(100, "meters", "kilometers")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Statistical Calculations" icon="chart-line">
|
||||
Calculate statistical metrics:
|
||||
```python
|
||||
result = calculate_statistics([1, 2, 3, 4, 5])
|
||||
```
|
||||
</Card>
|
||||
<Card title="Financial Calculations" icon="chart-pie">
|
||||
Calculate financial metrics:
|
||||
```python
|
||||
result = calculate_financial(1000, 5, 2)
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
# Complex expressions
|
||||
result = evaluate(
|
||||
"sin(pi/2) + sqrt(16)",
|
||||
precision=5
|
||||
)
|
||||
## Advanced Usage
|
||||
|
||||
# With variables
|
||||
result = evaluate(
|
||||
"x^2 + y",
|
||||
variables={"x": 3, "y": 4}
|
||||
)
|
||||
<AccordionGroup>
|
||||
<Accordion title="Expression Evaluation">
|
||||
Evaluate complex mathematical expressions with variables:
|
||||
```python
|
||||
# Basic arithmetic
|
||||
result = evaluate("2 + 2 * 3")
|
||||
|
||||
# With mathematical functions
|
||||
result = evaluate("sin(pi/2) + sqrt(16)")
|
||||
|
||||
# With variables
|
||||
result = evaluate(
|
||||
"x^2 + y",
|
||||
variables={"x": 3, "y": 4}
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Equation Solving">
|
||||
Solve different types of equations:
|
||||
```python
|
||||
# Linear equation
|
||||
result = solve_equation("2*x + 3 = 7")
|
||||
|
||||
# With custom variable
|
||||
result = solve_equation("y^2 = 4", variable="y")
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Unit Conversions">
|
||||
Convert between different units:
|
||||
```python
|
||||
# Length conversion
|
||||
result = convert_units(100, "meters", "kilometers")
|
||||
|
||||
# Temperature conversion
|
||||
result = convert_units(32, "fahrenheit", "celsius")
|
||||
|
||||
# Time conversion
|
||||
result = convert_units(2.5, "hours", "minutes")
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Statistical Calculations">
|
||||
Calculate statistical metrics:
|
||||
```python
|
||||
result = calculate_statistics([1, 2, 3, 4, 5])
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Financial Calculations">
|
||||
Calculate financial metrics:
|
||||
```python
|
||||
result = calculate_financial(1000, 5, 2)
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "result": 8.0
|
||||
# }
|
||||
# or
|
||||
# {
|
||||
# "error": "Invalid expression"
|
||||
# }
|
||||
```
|
||||
## Error Handling
|
||||
|
||||
### solve_equation(equation: str, variable: str = 'x')
|
||||
<Card title="Error Management" icon="shield-check">
|
||||
The tools include comprehensive error handling:
|
||||
```python
|
||||
# Returns success result
|
||||
{"result": 8.0}
|
||||
|
||||
# Returns error message
|
||||
{"error": "Invalid expression"}
|
||||
```
|
||||
</Card>
|
||||
|
||||
Solve mathematical equations:
|
||||
- Linear equations
|
||||
- Quadratic equations
|
||||
- Polynomial equations
|
||||
- Real solutions
|
||||
- Error handling
|
||||
## Best Practices
|
||||
|
||||
```python
|
||||
# Linear equation
|
||||
result = solve_equation("2*x + 3 = 7")
|
||||
|
||||
# Quadratic equation
|
||||
result = solve_equation(
|
||||
"x^2 - 5*x + 6 = 0"
|
||||
)
|
||||
|
||||
# Custom variable
|
||||
result = solve_equation(
|
||||
"y^2 = 4",
|
||||
variable='y'
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "solutions": [2.0, 3.0]
|
||||
# }
|
||||
# or
|
||||
# {
|
||||
# "error": "No real solutions found"
|
||||
# }
|
||||
```
|
||||
|
||||
### convert_units(value: float, from_unit: str, to_unit: str)
|
||||
|
||||
Convert between units:
|
||||
- Length units
|
||||
- Mass units
|
||||
- Temperature units
|
||||
- Time units
|
||||
- Error handling
|
||||
|
||||
```python
|
||||
# Length conversion
|
||||
result = convert_units(100, "meters", "kilometers")
|
||||
|
||||
# Temperature conversion
|
||||
result = convert_units(32, "fahrenheit", "celsius")
|
||||
|
||||
# Time conversion
|
||||
result = convert_units(
|
||||
2.5,
|
||||
"hours",
|
||||
"minutes"
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "result": 0.1 # 100 meters = 0.1 kilometers
|
||||
# }
|
||||
# or
|
||||
# {
|
||||
# "error": "Invalid units"
|
||||
# }
|
||||
```
|
||||
|
||||
### calculate_statistics(numbers: List[float])
|
||||
|
||||
Calculate statistical metrics:
|
||||
- Mean
|
||||
- Median
|
||||
- Standard deviation
|
||||
- Variance
|
||||
- Range
|
||||
- Min/Max values
|
||||
|
||||
```python
|
||||
# Basic statistics
|
||||
result = calculate_statistics([1, 2, 3, 4, 5])
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "mean": 3.0,
|
||||
# "median": 3.0,
|
||||
# "std_dev": 1.58,
|
||||
# "variance": 2.5,
|
||||
# "min": 1.0,
|
||||
# "max": 5.0,
|
||||
# "range": 4.0,
|
||||
# "count": 5
|
||||
# }
|
||||
```
|
||||
|
||||
### calculate_financial(principal: float, rate: float, time: float, frequency: str = 'yearly')
|
||||
|
||||
Calculate financial metrics:
|
||||
- Compound interest
|
||||
- Simple interest
|
||||
- Interest comparison
|
||||
- Multiple frequencies
|
||||
|
||||
```python
|
||||
# Basic compound interest
|
||||
result = calculate_financial(1000, 5, 2) # $1000, 5%, 2 years
|
||||
|
||||
# Monthly compounding
|
||||
result = calculate_financial(
|
||||
principal=1000,
|
||||
rate=5,
|
||||
time=2,
|
||||
frequency='monthly'
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "final_amount": 1102.50,
|
||||
# "compound_interest": 102.50,
|
||||
# "simple_interest": 100.00,
|
||||
# "difference": 2.50
|
||||
# }
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="MathAssistant",
|
||||
description="An agent that helps with mathematical calculations",
|
||||
tools=[
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The calculator tools require the following packages:
|
||||
- sympy: For equation solving and symbolic mathematics
|
||||
- pint: For unit conversions
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Supported Features
|
||||
|
||||
### Mathematical Functions
|
||||
- Basic: +, -, *, /, ^
|
||||
- Trigonometric: sin, cos, tan
|
||||
- Roots: sqrt
|
||||
- Logarithmic: log, exp
|
||||
- Constants: pi, e
|
||||
|
||||
### Unit Categories
|
||||
- Length: meters, kilometers, miles, etc.
|
||||
- Mass: grams, kilograms, pounds, etc.
|
||||
- Temperature: celsius, fahrenheit, kelvin
|
||||
- Time: seconds, minutes, hours, days
|
||||
- Many more via the pint library
|
||||
|
||||
### Financial Frequencies
|
||||
- yearly
|
||||
- semi-annual
|
||||
- quarterly
|
||||
- monthly
|
||||
- daily
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Scientific Calculations:
|
||||
```python
|
||||
# Complex mathematical expressions
|
||||
gravity = evaluate("9.81 * sin(pi/4)^2")
|
||||
kinetic = evaluate(
|
||||
"0.5 * m * v^2",
|
||||
variables={"m": 10, "v": 5}
|
||||
)
|
||||
```
|
||||
|
||||
2. Unit Conversions:
|
||||
```python
|
||||
# Multiple conversions
|
||||
distances = {
|
||||
"marathon": convert_units(42.195, "kilometers", "miles"),
|
||||
"height": convert_units(180, "centimeters", "feet"),
|
||||
"weight": convert_units(75, "kilograms", "pounds")
|
||||
}
|
||||
```
|
||||
|
||||
3. Investment Analysis:
|
||||
```python
|
||||
# Compare investment strategies
|
||||
investments = {
|
||||
"conservative": calculate_financial(10000, 3, 5, "yearly"),
|
||||
"moderate": calculate_financial(10000, 5, 5, "quarterly"),
|
||||
"aggressive": calculate_financial(10000, 8, 5, "monthly")
|
||||
}
|
||||
```
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Precision Control" icon="ruler">
|
||||
Control calculation precision:
|
||||
```python
|
||||
evaluate(
|
||||
"pi",
|
||||
precision=5
|
||||
)
|
||||
```
|
||||
</Card>
|
||||
<Card title="Safe Execution" icon="shield">
|
||||
Uses safe evaluation environment with:
|
||||
- Restricted builtins
|
||||
- Mathematical functions only
|
||||
- Variable validation
|
||||
</Card>
|
||||
</CardGroup>
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "CSV Tools"
|
||||
description: "Tools for working with CSV files in AI agents."
|
||||
title: "CSV Agent"
|
||||
description: "CSV file processing tools for AI agents."
|
||||
icon: "file-csv"
|
||||
---
|
||||
|
||||
@@ -8,12 +8,12 @@ icon: "file-csv"
|
||||
**Prerequisites**
|
||||
- Python 3.10 or higher
|
||||
- PraisonAI Agents package installed
|
||||
- Basic understanding of CSV files
|
||||
- `pandas` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## CSV Tools
|
||||
|
||||
Use CSV Tools to process and manipulate CSV files with AI agents.
|
||||
Use CSV Tools to read, write, and manipulate CSV files with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: "DuckDB Tools"
|
||||
description: "Tools for working with DuckDB databases in AI agents."
|
||||
title: "DuckDB Agent"
|
||||
description: "DuckDB database tools for AI agents."
|
||||
icon: "database"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -11,7 +12,7 @@ description: "Tools for working with DuckDB databases in AI agents."
|
||||
- Basic understanding of SQL and databases
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## DuckDB Tools
|
||||
|
||||
Use DuckDB Tools to manage and query databases with AI agents.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: "DuckDuckGo Tools"
|
||||
title: "DuckDuckGo Agent"
|
||||
description: "Internet search tools using DuckDuckGo for AI agents."
|
||||
icon: "magnifying-glass"
|
||||
---
|
||||
@@ -11,7 +11,7 @@ icon: "magnifying-glass"
|
||||
- `duckduckgo-search` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## DuckDuckGo Tools
|
||||
|
||||
Use DuckDuckGo Tools to perform internet searches with AI agents.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: "Excel Tools"
|
||||
description: "Tools for working with Excel files in AI agents."
|
||||
title: "Excel Agent"
|
||||
description: "Excel file processing tools for AI agents."
|
||||
icon: "file-excel"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -11,7 +12,7 @@ description: "Tools for working with Excel files in AI agents."
|
||||
- Basic understanding of Excel files
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Excel Tools
|
||||
|
||||
Use Excel Tools to process and manipulate Excel files with AI agents.
|
||||
|
||||
@@ -314,8 +315,7 @@ agents.start()
|
||||
Define specific Excel operations:
|
||||
```python
|
||||
Task(
|
||||
description="Process sales data and generate reports",
|
||||
expected_output="Sales analysis report"
|
||||
description="Process sales data and generate reports"
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
@@ -438,3 +438,5 @@ processed = {
|
||||
|
||||
# Write back to new file
|
||||
write_excel("processed_data.xlsx", processed)
|
||||
|
||||
```
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: "File Tools"
|
||||
description: "Basic file operation tools for AI agents."
|
||||
title: "File Agent"
|
||||
description: "File system operation tools for AI agents."
|
||||
icon: "folder"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -10,9 +11,9 @@ description: "Basic file operation tools for AI agents."
|
||||
- Basic understanding of file operations
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## File Tools
|
||||
|
||||
Use File Tools to manage files and directories with AI agents.
|
||||
Use File Tools to perform file system operations with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: "JSON Tools"
|
||||
description: "Tools for working with JSON files in AI agents."
|
||||
title: "JSON Agent"
|
||||
description: "JSON data processing tools for AI agents."
|
||||
icon: "braces"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -10,7 +11,7 @@ description: "Tools for working with JSON files in AI agents."
|
||||
- Basic understanding of JSON format
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## JSON Tools
|
||||
|
||||
Use JSON Tools to process and manipulate JSON files with AI agents.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "Newspaper Tools"
|
||||
description: "News article scraping and analysis tools for AI agents."
|
||||
title: "Newspaper Agent"
|
||||
description: "News article extraction tools for AI agents."
|
||||
icon: "newspaper"
|
||||
---
|
||||
|
||||
@@ -11,9 +11,9 @@ icon: "newspaper"
|
||||
- `newspaper3k` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Newspaper Tools
|
||||
|
||||
Use Newspaper Tools to scrape and analyze news articles with AI agents.
|
||||
Use Newspaper Tools to extract and analyze news articles with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "Pandas Tools"
|
||||
description: "Data manipulation and analysis tools for AI agents using pandas."
|
||||
title: "Pandas Agent"
|
||||
description: "Pandas data manipulation tools for AI agents."
|
||||
icon: "table"
|
||||
---
|
||||
|
||||
@@ -11,7 +11,7 @@ icon: "table"
|
||||
- `pandas` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Pandas Tools
|
||||
|
||||
Use Pandas Tools to manipulate and analyze data with AI agents.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: "Python Tools"
|
||||
description: "Tools for Python code execution, analysis, and formatting in AI agents."
|
||||
title: "Python Agent"
|
||||
description: "Python code execution tools for AI agents."
|
||||
icon: "code"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -10,7 +11,7 @@ description: "Tools for Python code execution, analysis, and formatting in AI ag
|
||||
- Basic understanding of Python programming
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Python Tools
|
||||
|
||||
Use Python Tools to execute and manage Python code with AI agents.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
title: "Shell Tools"
|
||||
description: "Tools for executing shell commands and managing system processes in AI agents."
|
||||
title: "Shell Agent"
|
||||
description: "Shell command execution tools for AI agents."
|
||||
icon: "terminal"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -10,9 +11,9 @@ description: "Tools for executing shell commands and managing system processes i
|
||||
- Basic understanding of shell commands
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Shell Tools
|
||||
|
||||
Use Shell Tools to execute and manage shell commands with AI agents.
|
||||
Use Shell Tools to execute shell commands with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "Spider Tools"
|
||||
description: "Web scraping and crawling tools for AI agents."
|
||||
title: "Spider Agent"
|
||||
description: "Web scraping tools for AI agents."
|
||||
icon: "spider"
|
||||
---
|
||||
|
||||
@@ -8,19 +8,18 @@ icon: "spider"
|
||||
**Prerequisites**
|
||||
- Python 3.10 or higher
|
||||
- PraisonAI Agents package installed
|
||||
- `beautifulsoup4` package installed
|
||||
- `requests` package installed
|
||||
- `scrapy` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Spider Tools
|
||||
|
||||
Use Spider Tools to scrape and crawl web content with AI agents.
|
||||
Use Spider Tools to crawl and scrape web content with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
First, install the required packages:
|
||||
```bash
|
||||
pip install praisonaiagents beautifulsoup4 requests
|
||||
pip install praisonaiagents scrapy
|
||||
```
|
||||
</Step>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: "Wikipedia Tools"
|
||||
title: "Wikipedia Agent"
|
||||
description: "Wikipedia data retrieval tools for AI agents."
|
||||
icon: "book"
|
||||
---
|
||||
@@ -12,7 +12,7 @@ icon: "book"
|
||||
- Basic understanding of Wikipedia APIs
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## Wikipedia Tools
|
||||
|
||||
Use Wikipedia Tools to retrieve and analyze Wikipedia content with AI agents.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "XML Tools"
|
||||
description: "XML file processing tools for AI agents."
|
||||
title: "XML Agent"
|
||||
description: "XML data processing tools for AI agents."
|
||||
icon: "code"
|
||||
---
|
||||
|
||||
@@ -8,12 +8,12 @@ icon: "code"
|
||||
**Prerequisites**
|
||||
- Python 3.10 or higher
|
||||
- PraisonAI Agents package installed
|
||||
- Basic understanding of XML format
|
||||
- `lxml` package installed
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## XML Tools
|
||||
|
||||
Use XML Tools to process and manipulate XML files with AI agents.
|
||||
Use XML Tools to read, write, and manipulate XML data with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "YAML Tools"
|
||||
description: "YAML file processing tools for AI agents."
|
||||
icon: "file-code"
|
||||
title: "YAML Agent"
|
||||
description: "YAML data processing tools for AI agents."
|
||||
icon: "code"
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -12,7 +12,7 @@ icon: "file-code"
|
||||
- Basic understanding of YAML format
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## YAML Tools
|
||||
|
||||
Use YAML Tools to process and manipulate YAML files with AI agents.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: "YFinance Tools"
|
||||
title: "YFinance Agent"
|
||||
description: "Yahoo Finance data retrieval tools for AI agents."
|
||||
icon: "chart-line"
|
||||
---
|
||||
@@ -12,7 +12,7 @@ icon: "chart-line"
|
||||
- Basic understanding of financial data
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
## YFinance Tools
|
||||
|
||||
Use YFinance Tools to retrieve and analyze financial data with AI agents.
|
||||
|
||||
|
||||
Generated
-8837
File diff suppressed because it is too large.
Load diff
+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.35.tar.gz"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.37.tar.gz"
|
||||
sha256 "1828fb9227d10f991522c3f24f061943a254b667196b40b1a3e4a54a8d30ce32" # Replace with actual SHA256 checksum
|
||||
license "MIT"
|
||||
|
||||
|
||||
+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.35 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.37 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "PraisonAI"
|
||||
version = "2.0.35"
|
||||
version = "2.0.37"
|
||||
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 = ""
|
||||
@@ -12,7 +12,7 @@ dependencies = [
|
||||
"rich>=13.7",
|
||||
"markdown>=3.5",
|
||||
"pyparsing>=3.0.0",
|
||||
"praisonaiagents>=0.0.26",
|
||||
"praisonaiagents>=0.0.28",
|
||||
"python-dotenv>=0.19.0",
|
||||
"instructor>=1.3.3",
|
||||
"PyYAML>=6.0",
|
||||
@@ -84,7 +84,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.7", "crewai"]
|
||||
|
||||
[tool.poetry]
|
||||
name = "PraisonAI"
|
||||
version = "2.0.35"
|
||||
version = "2.0.37"
|
||||
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 = ""
|
||||
@@ -102,7 +102,7 @@ python = ">=3.10,<3.13"
|
||||
rich = ">=13.7"
|
||||
markdown = ">=3.5"
|
||||
pyparsing = ">=3.0.0"
|
||||
praisonaiagents = ">=0.0.26"
|
||||
praisonaiagents = ">=0.0.28"
|
||||
python-dotenv = ">=0.19.0"
|
||||
instructor = ">=1.3.3"
|
||||
PyYAML = ">=6.0"
|
||||
|
||||
@@ -3061,7 +3061,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonai"
|
||||
version = "2.0.34"
|
||||
version = "2.0.37"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "instructor" },
|
||||
@@ -3198,7 +3198,7 @@ requires-dist = [
|
||||
{ name = "plotly", marker = "extra == 'realtime'", specifier = ">=5.24.0" },
|
||||
{ name = "praisonai-tools", marker = "extra == 'autogen'", specifier = ">=0.0.7" },
|
||||
{ name = "praisonai-tools", marker = "extra == 'crewai'", specifier = ">=0.0.7" },
|
||||
{ name = "praisonaiagents", specifier = ">=0.0.25" },
|
||||
{ name = "praisonaiagents", specifier = ">=0.0.28" },
|
||||
{ name = "pyautogen", marker = "extra == 'autogen'", specifier = ">=0.2.19" },
|
||||
{ name = "pydantic", marker = "extra == 'chat'", specifier = "<=2.10.1" },
|
||||
{ name = "pydantic", marker = "extra == 'code'", specifier = "<=2.10.1" },
|
||||
@@ -3251,16 +3251,16 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.25"
|
||||
version = "0.0.28"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "openai" },
|
||||
{ name = "pydantic" },
|
||||
{ name = "rich" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/6c/9c/07a6fd1d939eb98ae6399fb16aad870f16dba7ab5d64825af2420a46c09b/praisonaiagents-0.0.25.tar.gz", hash = "sha256:2ef1292fa5e0a5dc5d1b982670f3d0c6bb1cd9c59febbcbe6c2b8af5fa21ca43", size = 61241 }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/18/8d/f65e7df81b2f14a14cce47164dc4e7431f56f84a3a14ac4cd8adde97b86a/praisonaiagents-0.0.28.tar.gz", hash = "sha256:e736c970023d5e92a9080f5f9e8a6a6c30d00bc0d5e94d9feb6c903240068d45", size = 64693 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/50/78/1ab28fe9e32f2d765052b3870532238f6c4a72a98168b73b443d76c0235f/praisonaiagents-0.0.25-py3-none-any.whl", hash = "sha256:5b0cf04f294d81dbee8be855fc7026cc190a05b1d169e286eb7e387b8f8bd7de", size = 80127 },
|
||||
{ url = "https://files.pythonhosted.org/packages/e4/db/35663967eb53be8c60ceb3f128bd45be33321f31dff7ba29757c3870bf35/praisonaiagents-0.0.28-py3-none-any.whl", hash = "sha256:4274cfbe1cb20cc8d541e00bb2d9cebc310f86f03a68a6e02090f54b2c29e508", size = 84483 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in new issue
Block a user