Skip to content

Commit

Permalink
Merge pull request #298 from MervinPraison/develop
Browse files Browse the repository at this point in the history
Update PraisonAI and praisonaiagents to versions 2.0.46 and 0.0.36 re…
  • Loading branch information
MervinPraison authored Jan 14, 2025
2 parents 383b5dc + 8270064 commit 6f6757c
Show file tree
Hide file tree
Showing 95 changed files with 2,930 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install flask praisonai==2.0.45 gunicorn markdown
RUN pip install flask praisonai==2.0.46 gunicorn markdown
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
10 changes: 10 additions & 0 deletions agents/data-analyst-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import read_csv, read_excel, write_csv, write_excel, filter_data, get_summary, group_by, pivot_table
import os

agent = Agent(instructions="You are a Data Analyst Agent", tools=[read_csv, read_excel, write_csv, write_excel, filter_data, get_summary, group_by, pivot_table])
agent.start(f"""
Read the data from the csv file {os.path.join(os.path.dirname(__file__), "tesla-stock-price.csv")}
Analyse the data and give me the insights
read_csv to read the file
""")
5 changes: 5 additions & 0 deletions agents/finance-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import get_stock_price, get_stock_info, get_historical_data

agent = Agent(instructions="You are a Research Agent", tools=[get_stock_price, get_stock_info, get_historical_data])
agent.start("Understand current stock price and historical data of Apple and Google. Tell me if I can invest in them")
47 changes: 47 additions & 0 deletions agents/image-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import duckduckgo

agent = Agent(instructions="You are a Image Analysis Agent", tools=[duckduckgo])
agent.start("I want to go London next week, find me a good hotel and flight")

from praisonaiagents import Agent, Task, PraisonAIAgents

# Create Image Analysis Agent
image_agent = Agent(
name="ImageAnalyst",
role="Image Analysis Specialist",
goal="Analyze images and videos to extract meaningful information",
backstory="""You are an expert in computer vision and image analysis.
You excel at describing images, detecting objects, and understanding visual content.""",
llm="gpt-4o-mini",
self_reflect=False
)

# 1. Task with Image URL
task1 = Task(
name="analyze_landmark",
description="Describe this famous landmark and its architectural features.",
expected_output="Detailed description of the landmark's architecture and significance",
agent=image_agent,
images=["https://upload.wikimedia.org/wikipedia/commons/b/bf/Krakow_-_Kosciol_Mariacki.jpg"]
)

# 2. Task with Local Image File
task2 = Task(
name="analyze_local_image",
description="What objects can you see in this image? Describe their arrangement.",
expected_output="Detailed description of objects and their spatial relationships",
agent=image_agent,
images=["image.jpg"]
)

# Create PraisonAIAgents instance
agents = PraisonAIAgents(
agents=[image_agent],
tasks=[task1, task2],
process="sequential",
verbose=1
)

# Run all tasks
agents.start()
47 changes: 47 additions & 0 deletions agents/image-to-text-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import duckduckgo

agent = Agent(instructions="You are a Image Analysis Agent", tools=[duckduckgo])
agent.start("I want to go London next week, find me a good hotel and flight")

from praisonaiagents import Agent, Task, PraisonAIAgents

# Create Image Analysis Agent
image_agent = Agent(
name="ImageAnalyst",
role="Image Analysis Specialist",
goal="Analyze images and videos to extract meaningful information",
backstory="""You are an expert in computer vision and image analysis.
You excel at describing images, detecting objects, and understanding visual content.""",
llm="gpt-4o-mini",
self_reflect=False
)

# 1. Task with Image URL
task1 = Task(
name="analyze_landmark",
description="Describe this famous landmark and its architectural features.",
expected_output="Detailed description of the landmark's architecture and significance",
agent=image_agent,
images=["https://upload.wikimedia.org/wikipedia/commons/b/bf/Krakow_-_Kosciol_Mariacki.jpg"]
)

# 2. Task with Local Image File
task2 = Task(
name="analyze_local_image",
description="What objects can you see in this image? Describe their arrangement.",
expected_output="Detailed description of objects and their spatial relationships",
agent=image_agent,
images=["image.jpg"]
)

# Create PraisonAIAgents instance
agents = PraisonAIAgents(
agents=[image_agent],
tasks=[task1, task2],
process="sequential",
verbose=1
)

# Run all tasks
agents.start()
4 changes: 4 additions & 0 deletions agents/markdown-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from praisonaiagents import Agent

agent = Agent(instructions="You are a Markdown Agent, output in markdown format")
agent.start("Write a blog post about AI")
5 changes: 5 additions & 0 deletions agents/planning-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import duckduckgo

agent = Agent(instructions="You are a Planning Agent", tools=[duckduckgo])
agent.start("I want to go London next week, find me a good hotel and flight")
6 changes: 5 additions & 1 deletion agents/praisonaiagents/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,4 +762,8 @@ async def _achat_completion(self, response, tools):

def run(self):
"""Alias for start() method"""
return self.start()
return self.start()

def start(self, prompt: str, **kwargs):
"""Start the agent with a prompt. This is a convenience method that wraps chat()."""
return self.chat(prompt, **kwargs)
3 changes: 3 additions & 0 deletions agents/praisonaiagents/tools/pandas_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def get_summary(self, df: pd.DataFrame) -> Dict[str, Any]:
Dict: Summary statistics and information
"""
try:
if not isinstance(df, pd.DataFrame):
raise TypeError(f"Expected pandas DataFrame, got {type(df).__name__}")

numeric_summary = df.describe().to_dict()
# Convert numpy types to native Python types
for col in numeric_summary:
Expand Down
10 changes: 9 additions & 1 deletion agents/praisonaiagents/tools/yfinance_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ def get_historical_data(
return [{"error": "yfinance package not available"}]

hist = ticker.history(period=period, interval=interval, start=start, end=end)
return hist.reset_index().to_dict('records')
data = hist.reset_index().to_dict('records')

# Convert timestamps to ISO format strings
for record in data:
if 'Date' in record and hasattr(record['Date'], 'isoformat'):
record['Date'] = record['Date'].isoformat()
if 'Datetime' in record and hasattr(record['Datetime'], 'isoformat'):
record['Datetime'] = record['Datetime'].isoformat()
return data
except Exception as e:
error_msg = f"Error fetching historical data: {str(e)}"
logging.error(error_msg)
Expand Down
19 changes: 19 additions & 0 deletions agents/programming-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import execute_code, analyze_code, format_code, lint_code, disassemble_code # Code Tools
from praisonaiagents.tools import execute_command, list_processes, kill_process, get_system_info # Shell Tools
from praisonaiagents.tools import duckduckgo # Web Search Tool

agent = Agent(
instructions="You are a Programming Agent", self_reflect=True, min_reflect=5, max_reflect=10,
tools=[execute_code, analyze_code, format_code, lint_code, disassemble_code, execute_command, list_processes, kill_process, get_system_info, duckduckgo]
)
agent.start(
"Write a python script using yfinance to find the stock price of Tesla"
"First check if required packages are installed"
"Run it using execute_code"
"execute_command if you want to run any terminal command"
"search internet using duckduckgo if you want to know update python package information"
"Analyse the output using analyze_code and fix error if required"
"if no package is installed, install it"
"then run the code"
)
2 changes: 1 addition & 1 deletion agents/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "praisonaiagents"
version = "0.0.35"
version = "0.0.36"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
authors = [
{ name="Mervin Praison" }
Expand Down
5 changes: 5 additions & 0 deletions agents/recommendation-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import duckduckgo

agent = Agent(instructions="You are a Recommendation Agent", tools=[duckduckgo])
agent.start("Recommend me a good movie to watch in 2025")
5 changes: 5 additions & 0 deletions agents/research-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import duckduckgo

agent = Agent(instructions="You are a Research Agent", tools=[duckduckgo])
agent.start("Research about AI 2024")
5 changes: 5 additions & 0 deletions agents/shopping-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from praisonaiagents import Agent, Tools
from praisonaiagents.tools import duckduckgo

agent = Agent(instructions="You are a Shopping Agent", tools=[duckduckgo])
agent.start("I want to buy iPhone 16 Pro Max, check 5 stores and give me price in table")
4 changes: 4 additions & 0 deletions agents/single-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from praisonaiagents import Agent

agent = Agent(instructions="You are a Markdown Agent, output in markdown format")
agent.start("Write a blog post about AI")
Loading

0 comments on commit 6f6757c

Please sign in to comment.