Compare commits

...
1 Commits
Author SHA1 Message Date
Mervin Praison 0b1b3d3b3e Release v2.6.7 2025-12-29 00:22:52 +00:00
8 changed files with 158 additions and 19 deletions

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.6.6" \
"praisonai>=2.6.7" \
"praisonai[chat]" \
"embedchain[github,youtube]"
+1 -1
View File
@@ -20,7 +20,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.6.6" \
"praisonai>=2.6.7" \
"praisonai[ui]" \
"praisonai[chat]" \
"praisonai[realtime]" \
+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.6.6" \
"praisonai>=2.6.7" \
"praisonai[ui]" \
"praisonai[crewai]"
+128
View File
@@ -0,0 +1,128 @@
"""
Example: Using pandas as a custom tool with PraisonAI Agent
This example shows how to wrap pandas functions as tools
that can be used with Agent().
"""
import pandas as pd
from io import StringIO
# Define pandas wrapper tools
def analyze_csv_data(csv_data: str) -> str:
"""Analyze CSV data using pandas DataFrame.
Args:
csv_data: CSV-formatted string data
Returns:
Analysis summary including shape, columns, and statistics
"""
df = pd.read_csv(StringIO(csv_data))
summary = f"""DataFrame Analysis:
- Shape: {df.shape[0]} rows, {df.shape[1]} columns
- Columns: {list(df.columns)}
- Data Types: {dict(df.dtypes)}
- Summary Statistics:
{df.describe().to_string()}"""
return summary
def filter_dataframe(csv_data: str, column: str, condition: str, value: str) -> str:
"""Filter a DataFrame based on a condition.
Args:
csv_data: CSV-formatted string data
column: Column name to filter on
condition: Condition type ('equals', 'greater', 'less', 'contains')
value: Value to compare against
Returns:
Filtered data as CSV string
"""
df = pd.read_csv(StringIO(csv_data))
if condition == 'equals':
filtered = df[df[column] == value]
elif condition == 'greater':
filtered = df[df[column] > float(value)]
elif condition == 'less':
filtered = df[df[column] < float(value)]
elif condition == 'contains':
filtered = df[df[column].str.contains(value, na=False)]
else:
return f"Unknown condition: {condition}"
return filtered.to_csv(index=False)
def calculate_statistics(csv_data: str, column: str) -> str:
"""Calculate statistics for a specific column.
Args:
csv_data: CSV-formatted string data
column: Column name to analyze
Returns:
Statistics summary for the column
"""
df = pd.read_csv(StringIO(csv_data))
if column not in df.columns:
return f"Column '{column}' not found. Available: {list(df.columns)}"
col = df[column]
if pd.api.types.is_numeric_dtype(col):
stats = f"""Statistics for '{column}':
- Count: {col.count()}
- Mean: {col.mean():.2f}
- Std: {col.std():.2f}
- Min: {col.min()}
- Max: {col.max()}
- Median: {col.median()}"""
else:
stats = f"""Statistics for '{column}':
- Count: {col.count()}
- Unique: {col.nunique()}
- Top: {col.mode().iloc[0] if len(col.mode()) > 0 else 'N/A'}
- Sample values: {list(col.head(3))}"""
return stats
if __name__ == "__main__":
# Test data
test_csv = """name,age,salary,department
Alice,30,50000,Engineering
Bob,25,45000,Marketing
Charlie,35,60000,Engineering
Diana,28,52000,Sales
Eve,32,55000,Marketing"""
print("=== Test: analyze_csv_data ===")
print(analyze_csv_data(test_csv))
print()
print("=== Test: filter_dataframe ===")
print(filter_dataframe(test_csv, "age", "greater", "28"))
print()
print("=== Test: calculate_statistics ===")
print(calculate_statistics(test_csv, "salary"))
print()
# Example with Agent (requires praisonaiagents)
print("=== Agent Usage Example ===")
print("""
from praisonaiagents import Agent
agent = Agent(
name="data_analyst",
role="Data Analyst",
goal="Analyze data using pandas tools",
tools=[analyze_csv_data, filter_dataframe, calculate_statistics]
)
result = agent.start("Analyze this data and find the average salary")
""")
+2 -2
View File
@@ -3,8 +3,8 @@ 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/v2.6.6.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.6.6.tar.gz | shasum -a 256`.split.first
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.6.7.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.6.7.tar.gz | shasum -a 256`.split.first
license "MIT"
depends_on "[email protected]"
+23 -12
View File
@@ -137,6 +137,13 @@ Built-in tools include: internet_search, calculator, file operations, etc.
for name in uncategorized[:10]: # Limit to 10
self.print_status(f" • {name}", "info")
# Show added tool sources from config
config = self._load_config()
if config.get("sources"):
self.print_status("\n Added Sources (use with Agent):", "info")
for source in config["sources"]:
self.print_status(f" • {source}", "info")
return list(tools.keys())
def action_info(self, args: List[str], **kwargs) -> Dict[str, Any]:
@@ -575,7 +582,7 @@ Built-in tools include: internet_search, calculator, file operations, etc.
self.print_status(f"Failed to download from GitHub: {e}", "error")
return result
# Assume it's a package name
# Assume it's a package name - but warn that packages need wrapper tools
else:
try:
import importlib
@@ -584,20 +591,24 @@ Built-in tools include: internet_search, calculator, file operations, etc.
# Get callable functions from the module
tools = [n for n in dir(module) if not n.startswith('_') and callable(getattr(module, n, None))]
self.print_status(f"\n✅ Package '{source}' is available", "success")
self.print_status(f" Found {len(tools)} callable items", "info")
# Add to sources config
config = self._load_config()
if "sources" not in config:
config["sources"] = []
if source not in config["sources"]:
config["sources"].append(source)
self._save_config(config)
self.print_status(" Added to tool sources config", "info")
self.print_status(f"\n⚠️ Package '{source}' is installed but NOT directly usable as tools", "warning")
self.print_status(f" Found {len(tools)} callable items in package", "info")
self.print_status("", "info")
self.print_status(" To use this package with agents, create wrapper tools:", "info")
self.print_status(" 1. Create a file: ~/.praison/tools/my_tools.py", "info")
self.print_status(" 2. Define wrapper functions with docstrings", "info")
self.print_status(" 3. Tools will be auto-discovered", "info")
self.print_status("", "info")
self.print_status(" Example wrapper:", "info")
self.print_status(f" def my_{source}_tool(data: str) -> str:", "info")
self.print_status(f' """Use {source} to process data."""', "info")
self.print_status(f" import {source}", "info")
self.print_status(" # Your logic here", "info")
self.print_status(" return result", "info")
result["success"] = True
result["tools"] = tools[:10]
result["note"] = "Package requires wrapper tools"
return result
except ImportError:
self.print_status(f"Package '{source}' not found. Install with: pip install {source}", "error")
+1 -1
View File
@@ -57,7 +57,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.6.6 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.6.7 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
+1 -1
View File
@@ -1 +1 @@
__version__ = "2.6.6"
__version__ = "2.6.7"