mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-08 01:08:39 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c03f4813 | ||
|
|
03856b74bf |
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.33 gunicorn markdown
|
||||
RUN pip install flask praisonai==2.0.34 gunicorn markdown
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Tools module for PraisonAI Agents"""
|
||||
from .internet_search import internet_search
|
||||
from .duckduckgo_tools import internet_search
|
||||
|
||||
class Tools:
|
||||
"""Tools class for backward compatibility"""
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.24"
|
||||
version = "0.0.25"
|
||||
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
|
||||
authors = [
|
||||
{ name="Mervin Praison" }
|
||||
|
||||
Generated
+1
-1
@@ -186,7 +186,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonaiagents"
|
||||
version = "0.0.24"
|
||||
version = "0.0.25"
|
||||
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.33 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.34 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ Create multiple AI agents that can work together in just a few lines of code!
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
<div className="relative w-full aspect-video">
|
||||
<iframe
|
||||
className="absolute top-0 left-0 w-full h-full"
|
||||
src="https://www.youtube.com/embed/OkvYp5aAGSg"
|
||||
title="YouTube video player"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowFullScreen
|
||||
></iframe>
|
||||
</div>
|
||||
|
||||
## Understanding Mini AI Agents
|
||||
|
||||
<Card title="What are Mini AI Agents?" icon="question">
|
||||
|
||||
+20
-15
@@ -76,17 +76,6 @@
|
||||
"concepts/tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Getting Started (No Code)",
|
||||
"pages": [
|
||||
"introduction",
|
||||
"tldr",
|
||||
"installation",
|
||||
"initialise",
|
||||
"run",
|
||||
"auto"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Features",
|
||||
"pages": [
|
||||
@@ -97,11 +86,27 @@
|
||||
"features/mini",
|
||||
"features/codeagent",
|
||||
"features/structured",
|
||||
"features/callbacks",
|
||||
"features/callbacks"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Other Features",
|
||||
"pages": [
|
||||
"train",
|
||||
"framework/praisonaiagents",
|
||||
"framework/crewai",
|
||||
"framework/autogen"
|
||||
"framework/autogen",
|
||||
"framework/praisonaiagents"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Getting Started (No Code)",
|
||||
"pages": [
|
||||
"introduction",
|
||||
"tldr",
|
||||
"installation",
|
||||
"initialise",
|
||||
"run",
|
||||
"auto"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -129,7 +134,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Tools (No Code)",
|
||||
"group": "Tools",
|
||||
"pages": [
|
||||
"tools/duckduckgo_tools",
|
||||
"tools/arxiv_tools",
|
||||
|
||||
+214
-34
@@ -27,7 +27,7 @@ Use arXiv Tools to search and retrieve scientific papers with AI agents.
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import arxiv
|
||||
from praisonaiagents.tools import search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -39,7 +39,7 @@ Use arXiv Tools to search and retrieve scientific papers with AI agents.
|
||||
role="Scientific Literature Specialist",
|
||||
goal="Find and analyze relevant scientific papers.",
|
||||
backstory="Expert in academic research and literature review.",
|
||||
tools=[arxiv],
|
||||
tools=[search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
@@ -81,34 +81,214 @@ Use arXiv Tools to search and retrieve scientific papers with AI agents.
|
||||
- PDF download options
|
||||
</Card>
|
||||
|
||||
## Key Components
|
||||
## Available Functions
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Research Agent" icon="user-robot">
|
||||
Create specialized research agents:
|
||||
```python
|
||||
Agent(tools=[arxiv])
|
||||
```
|
||||
</Card>
|
||||
<Card title="Research Task" icon="list-check">
|
||||
Define research tasks:
|
||||
```python
|
||||
Task(description="research_query")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Process Types" icon="arrows-split-up-and-left">
|
||||
Sequential or parallel processing:
|
||||
```python
|
||||
process="sequential"
|
||||
```
|
||||
</Card>
|
||||
<Card title="Search Options" icon="sliders">
|
||||
Customize search parameters:
|
||||
```python
|
||||
max_results=10, sort_by="relevance"
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
```python
|
||||
from praisonaiagents.tools import search_arxiv
|
||||
from praisonaiagents.tools import get_arxiv_paper
|
||||
from praisonaiagents.tools import get_papers_by_author
|
||||
from praisonaiagents.tools import get_papers_by_category
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### search_arxiv(query: str, max_results: int = 10, sort_by: str = "relevance", sort_order: str = "descending", include_fields: Optional[List[str]] = None)
|
||||
|
||||
Search arXiv for papers:
|
||||
- Flexible query support
|
||||
- Customizable results
|
||||
- Multiple sorting options
|
||||
- Field selection
|
||||
- Error handling
|
||||
|
||||
```python
|
||||
# Basic search
|
||||
papers = search_arxiv("quantum computing")
|
||||
|
||||
# Advanced search
|
||||
papers = search_arxiv(
|
||||
query="quantum computing",
|
||||
max_results=5,
|
||||
sort_by="submittedDate",
|
||||
sort_order="descending",
|
||||
include_fields=["title", "authors", "summary"]
|
||||
)
|
||||
|
||||
# Returns: List[Dict[str, Any]]
|
||||
# Example output:
|
||||
# [
|
||||
# {
|
||||
# "arxiv_id": "2401.00123",
|
||||
# "title": "Quantum Computing: A Survey",
|
||||
# "authors": ["John Doe", "Jane Smith"],
|
||||
# "summary": "This paper reviews...",
|
||||
# "published": "2024-01-01T00:00:00",
|
||||
# "updated": "2024-01-02T00:00:00"
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
```
|
||||
|
||||
### get_arxiv_paper(paper_id: str, include_fields: Optional[List[str]] = None)
|
||||
|
||||
Get specific paper details:
|
||||
- Direct ID lookup
|
||||
- Full paper metadata
|
||||
- Customizable fields
|
||||
- PDF/Abstract links
|
||||
|
||||
```python
|
||||
# Get paper by ID
|
||||
paper = get_arxiv_paper("2401.00123")
|
||||
|
||||
# Get specific fields
|
||||
paper = get_arxiv_paper(
|
||||
paper_id="2401.00123",
|
||||
include_fields=["title", "authors", "pdf_url"]
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "arxiv_id": "2401.00123",
|
||||
# "title": "Quantum Computing: A Survey",
|
||||
# "authors": ["John Doe", "Jane Smith"],
|
||||
# "pdf_url": "https://arxiv.org/pdf/2401.00123",
|
||||
# "abstract_url": "https://arxiv.org/abs/2401.00123",
|
||||
# "published": "2024-01-01T00:00:00",
|
||||
# "updated": "2024-01-02T00:00:00"
|
||||
# }
|
||||
```
|
||||
|
||||
### get_papers_by_author(author: str, max_results: int = 10, sort_by: str = "submittedDate", sort_order: str = "descending", include_fields: Optional[List[str]] = None)
|
||||
|
||||
Search papers by author:
|
||||
- Author-specific search
|
||||
- Publication timeline
|
||||
- Sort options
|
||||
- Field selection
|
||||
|
||||
```python
|
||||
# Get author's papers
|
||||
papers = get_papers_by_author("Yoshua Bengio")
|
||||
|
||||
# Recent papers first
|
||||
papers = get_papers_by_author(
|
||||
author="Yoshua Bengio",
|
||||
max_results=5,
|
||||
sort_by="submittedDate",
|
||||
sort_order="descending"
|
||||
)
|
||||
|
||||
# Returns: List[Dict[str, Any]]
|
||||
# Example output:
|
||||
# [
|
||||
# {
|
||||
# "arxiv_id": "2401.00124",
|
||||
# "title": "Deep Learning Advances",
|
||||
# "authors": ["Yoshua Bengio", "Other Author"],
|
||||
# "published": "2024-01-01T00:00:00"
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
```
|
||||
|
||||
### get_papers_by_category(category: str, max_results: int = 10, sort_by: str = "submittedDate", sort_order: str = "descending", include_fields: Optional[List[str]] = None)
|
||||
|
||||
Search papers by category:
|
||||
- Category-specific search
|
||||
- Latest publications
|
||||
- Sort options
|
||||
- Field selection
|
||||
|
||||
```python
|
||||
# Get papers in category
|
||||
papers = get_papers_by_category("cs.AI")
|
||||
|
||||
# Recent machine learning papers
|
||||
papers = get_papers_by_category(
|
||||
category="cs.LG",
|
||||
max_results=5,
|
||||
sort_by="submittedDate",
|
||||
sort_order="descending"
|
||||
)
|
||||
|
||||
# Returns: List[Dict[str, Any]]
|
||||
# Example output:
|
||||
# [
|
||||
# {
|
||||
# "arxiv_id": "2401.00125",
|
||||
# "title": "New ML Algorithm",
|
||||
# "categories": ["cs.LG", "cs.AI"],
|
||||
# "published": "2024-01-01T00:00:00"
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The arXiv tools require the following package:
|
||||
- arxiv: For accessing the arXiv API
|
||||
|
||||
This will be automatically installed when needed.
|
||||
|
||||
## Available Fields
|
||||
|
||||
When using `include_fields`, you can select from:
|
||||
- title: Paper title
|
||||
- authors: List of authors
|
||||
- summary: Abstract text
|
||||
- comment: Author comments
|
||||
- journal_ref: Journal reference
|
||||
- doi: Digital Object Identifier
|
||||
- primary_category: Main arXiv category
|
||||
- categories: All arXiv categories
|
||||
- links: PDF and abstract URLs
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Literature Review:
|
||||
```python
|
||||
# Search multiple related topics
|
||||
topics = ["machine learning", "neural networks", "deep learning"]
|
||||
all_papers = []
|
||||
for topic in topics:
|
||||
papers = search_arxiv(
|
||||
topic,
|
||||
max_results=5,
|
||||
sort_by="relevance"
|
||||
)
|
||||
all_papers.extend(papers)
|
||||
```
|
||||
|
||||
2. Author Research:
|
||||
```python
|
||||
# Get recent papers by multiple authors
|
||||
authors = ["Yoshua Bengio", "Geoffrey Hinton", "Yann LeCun"]
|
||||
author_papers = {}
|
||||
for author in authors:
|
||||
papers = get_papers_by_author(
|
||||
author,
|
||||
max_results=3,
|
||||
sort_by="submittedDate"
|
||||
)
|
||||
author_papers[author] = papers
|
||||
```
|
||||
|
||||
3. Category Monitoring:
|
||||
```python
|
||||
# Monitor new papers in AI categories
|
||||
categories = ["cs.AI", "cs.LG", "cs.CL"]
|
||||
new_papers = {}
|
||||
for category in categories:
|
||||
papers = get_papers_by_category(
|
||||
category,
|
||||
max_results=5,
|
||||
sort_by="submittedDate"
|
||||
)
|
||||
new_papers[category] = papers
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -116,7 +296,7 @@ Use arXiv Tools to search and retrieve scientific papers with AI agents.
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import arxiv
|
||||
from praisonaiagents.tools import search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category
|
||||
|
||||
# Create research agent
|
||||
research_agent = Agent(
|
||||
@@ -124,7 +304,7 @@ research_agent = Agent(
|
||||
role="Scientific Literature Specialist",
|
||||
goal="Find relevant scientific papers on specified topics.",
|
||||
backstory="Expert in academic research and literature analysis.",
|
||||
tools=[arxiv],
|
||||
tools=[search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -153,7 +333,7 @@ research_agent = Agent(
|
||||
name="Researcher",
|
||||
role="Literature Specialist",
|
||||
goal="Gather comprehensive scientific literature.",
|
||||
tools=[arxiv],
|
||||
tools=[search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -198,7 +378,7 @@ agents.start()
|
||||
name="Researcher",
|
||||
role="Literature Specialist",
|
||||
goal="Find relevant scientific papers",
|
||||
tools=[arxiv]
|
||||
tools=[search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category]
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
@@ -222,7 +402,7 @@ agents.start()
|
||||
searcher = Agent(
|
||||
name="Searcher",
|
||||
role="Literature Specialist",
|
||||
tools=[arxiv]
|
||||
tools=[search_arxiv, get_arxiv_paper, get_papers_by_author, get_papers_by_category]
|
||||
)
|
||||
|
||||
# Review agent
|
||||
|
||||
+230
-220
@@ -1,250 +1,260 @@
|
||||
---
|
||||
title: "Calculator Tools"
|
||||
description: "Mathematical computation tools for AI agents."
|
||||
icon: "calculator"
|
||||
description: "Tools for performing mathematical calculations, unit conversions, and financial computations."
|
||||
---
|
||||
|
||||
<Note>
|
||||
**Prerequisites**
|
||||
- Python 3.10 or higher
|
||||
- PraisonAI Agents package installed
|
||||
- Basic understanding of mathematical operations
|
||||
</Note>
|
||||
|
||||
## Quick Start
|
||||
|
||||
Use Calculator Tools to perform mathematical computations with AI agents.
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Dependencies">
|
||||
First, install the required package:
|
||||
```bash
|
||||
pip install praisonaiagents
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Import Components">
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import calculator
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create Agent">
|
||||
Create a calculator agent:
|
||||
```python
|
||||
calc_agent = Agent(
|
||||
name="Calculator",
|
||||
role="Mathematical Specialist",
|
||||
goal="Perform mathematical computations accurately.",
|
||||
backstory="Expert in mathematical calculations and analysis.",
|
||||
tools=[calculator],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Define Task">
|
||||
Define the calculation task:
|
||||
```python
|
||||
calc_task = Task(
|
||||
description="Calculate financial metrics for quarterly report.",
|
||||
expected_output="Computed financial metrics with analysis.",
|
||||
agent=calc_agent,
|
||||
name="financial_calculations"
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run Agent">
|
||||
Initialize and run the agent:
|
||||
```python
|
||||
agents = PraisonAIAgents(
|
||||
agents=[calc_agent],
|
||||
tasks=[calc_task],
|
||||
process="sequential"
|
||||
)
|
||||
agents.start()
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Understanding Calculator Tools
|
||||
|
||||
<Card title="What are Calculator Tools?" icon="question">
|
||||
Calculator Tools provide mathematical capabilities for AI agents:
|
||||
- Basic arithmetic
|
||||
- Advanced mathematics
|
||||
- Statistical calculations
|
||||
- Financial computations
|
||||
- Unit conversions
|
||||
</Card>
|
||||
|
||||
## Key Components
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Calculator Agent" icon="user-robot">
|
||||
Create specialized calculator agents:
|
||||
```python
|
||||
Agent(tools=[calculator])
|
||||
```
|
||||
</Card>
|
||||
<Card title="Calculator Task" icon="list-check">
|
||||
Define calculation tasks:
|
||||
```python
|
||||
Task(description="calculation_query")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Process Types" icon="arrows-split-up-and-left">
|
||||
Sequential or parallel processing:
|
||||
```python
|
||||
process="sequential"
|
||||
```
|
||||
</Card>
|
||||
<Card title="Calculation Options" icon="sliders">
|
||||
Customize calculation parameters:
|
||||
```python
|
||||
precision=2, format="decimal"
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Calculator Agent
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import calculator
|
||||
|
||||
# Create calculator agent
|
||||
calc_agent = Agent(
|
||||
name="MathExpert",
|
||||
role="Mathematical Specialist",
|
||||
goal="Perform calculations accurately and efficiently.",
|
||||
backstory="Expert in mathematical computations and analysis.",
|
||||
tools=[calculator],
|
||||
self_reflect=False
|
||||
from praisonaiagents.tools import (
|
||||
evaluate, solve_equation, convert_units,
|
||||
calculate_statistics, calculate_financial
|
||||
)
|
||||
|
||||
# Define calculation task
|
||||
calc_task = Task(
|
||||
description="Calculate investment returns and compound interest.",
|
||||
expected_output="Detailed investment calculations with analysis.",
|
||||
agent=calc_agent,
|
||||
name="investment_analysis"
|
||||
)
|
||||
|
||||
# Run agent
|
||||
agents = PraisonAIAgents(
|
||||
agents=[calc_agent],
|
||||
tasks=[calc_task],
|
||||
process="sequential"
|
||||
)
|
||||
agents.start()
|
||||
```
|
||||
|
||||
### Advanced Calculations with Multiple Agents
|
||||
## Function Details
|
||||
|
||||
### evaluate(expression: str, variables: Optional[Dict[str, float]] = None, precision: int = 10)
|
||||
|
||||
Evaluate mathematical expressions:
|
||||
- Basic arithmetic
|
||||
- Mathematical functions
|
||||
- Variable substitution
|
||||
- Precision control
|
||||
- Error handling
|
||||
|
||||
```python
|
||||
# Create calculation agent
|
||||
calculator_agent = Agent(
|
||||
name="Calculator",
|
||||
role="Math Calculator",
|
||||
goal="Perform complex calculations systematically.",
|
||||
tools=[calculator],
|
||||
self_reflect=False
|
||||
# Basic arithmetic
|
||||
result = evaluate("2 + 2 * 3")
|
||||
|
||||
# Complex expressions
|
||||
result = evaluate(
|
||||
"sin(pi/2) + sqrt(16)",
|
||||
precision=5
|
||||
)
|
||||
|
||||
# Create analysis agent
|
||||
analysis_agent = Agent(
|
||||
name="Analyzer",
|
||||
role="Data Analyst",
|
||||
goal="Analyze and interpret calculation results.",
|
||||
backstory="Expert in data analysis and interpretation.",
|
||||
self_reflect=False
|
||||
# With variables
|
||||
result = evaluate(
|
||||
"x^2 + y",
|
||||
variables={"x": 3, "y": 4}
|
||||
)
|
||||
|
||||
# Define tasks
|
||||
calculation_task = Task(
|
||||
description="Calculate statistical metrics for dataset.",
|
||||
agent=calculator_agent,
|
||||
name="statistical_analysis"
|
||||
)
|
||||
|
||||
analysis_task = Task(
|
||||
description="Analyze and interpret the statistical results.",
|
||||
agent=analysis_agent,
|
||||
name="result_analysis"
|
||||
)
|
||||
|
||||
# Run agents
|
||||
agents = PraisonAIAgents(
|
||||
agents=[calculator_agent, analysis_agent],
|
||||
tasks=[calculation_task, analysis_task],
|
||||
process="sequential"
|
||||
)
|
||||
agents.start()
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "result": 8.0
|
||||
# }
|
||||
# or
|
||||
# {
|
||||
# "error": "Invalid expression"
|
||||
# }
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
### solve_equation(equation: str, variable: str = 'x')
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Agent Configuration">
|
||||
Configure agents with clear calculation focus:
|
||||
```python
|
||||
Agent(
|
||||
name="Calculator",
|
||||
role="Mathematical Specialist",
|
||||
goal="Perform calculations accurately and efficiently",
|
||||
tools=[calculator]
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
Solve mathematical equations:
|
||||
- Linear equations
|
||||
- Quadratic equations
|
||||
- Polynomial equations
|
||||
- Real solutions
|
||||
- Error handling
|
||||
|
||||
<Accordion title="Task Definition">
|
||||
Define specific calculation objectives:
|
||||
```python
|
||||
Task(
|
||||
description="Calculate financial metrics and growth rates",
|
||||
expected_output="Detailed financial analysis"
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### Calculation Pipeline
|
||||
```python
|
||||
# Calculator agent
|
||||
calculator = Agent(
|
||||
name="Calculator",
|
||||
role="Math Calculator",
|
||||
tools=[calculator]
|
||||
# Linear equation
|
||||
result = solve_equation("2*x + 3 = 7")
|
||||
|
||||
# Quadratic equation
|
||||
result = solve_equation(
|
||||
"x^2 - 5*x + 6 = 0"
|
||||
)
|
||||
|
||||
# Analysis agent
|
||||
analyzer = Agent(
|
||||
name="Analyzer",
|
||||
role="Result Analyzer"
|
||||
# Custom variable
|
||||
result = solve_equation(
|
||||
"y^2 = 4",
|
||||
variable='y'
|
||||
)
|
||||
|
||||
# Define tasks
|
||||
calc_task = Task(
|
||||
description="Perform calculations",
|
||||
agent=calculator
|
||||
# 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"
|
||||
)
|
||||
|
||||
analysis_task = Task(
|
||||
description="Analyze results",
|
||||
agent=analyzer
|
||||
# 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'
|
||||
)
|
||||
|
||||
# Run workflow
|
||||
agents = PraisonAIAgents(
|
||||
agents=[calculator, analyzer],
|
||||
tasks=[calc_task, analysis_task]
|
||||
# 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")
|
||||
}
|
||||
```
|
||||
+144
-9
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: "CSV Tools"
|
||||
description: "CSV file processing tools for AI agents."
|
||||
description: "Tools for working with CSV files in AI agents."
|
||||
icon: "file-csv"
|
||||
---
|
||||
|
||||
@@ -27,7 +27,7 @@ Use CSV Tools to process and manipulate CSV files with AI agents.
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import csv
|
||||
from praisonaiagents.tools import csv, read_csv, write_csv, merge_csv
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -39,7 +39,7 @@ Use CSV Tools to process and manipulate CSV files with AI agents.
|
||||
role="CSV Processing Specialist",
|
||||
goal="Process CSV files efficiently and accurately.",
|
||||
backstory="Expert in CSV file manipulation and analysis.",
|
||||
tools=[csv],
|
||||
tools=[csv, read_csv, write_csv, merge_csv],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
@@ -87,7 +87,7 @@ Use CSV Tools to process and manipulate CSV files with AI agents.
|
||||
<Card title="CSV Agent" icon="user-robot">
|
||||
Create specialized CSV agents:
|
||||
```python
|
||||
Agent(tools=[csv])
|
||||
Agent(tools=[csv, read_csv, write_csv, merge_csv])
|
||||
```
|
||||
</Card>
|
||||
<Card title="CSV Task" icon="list-check">
|
||||
@@ -110,13 +110,148 @@ Use CSV Tools to process and manipulate CSV files with AI agents.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import read_csv
|
||||
from praisonaiagents.tools import write_csv
|
||||
from praisonaiagents.tools import merge_csv
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### read_csv(filepath: str, encoding: str = 'utf-8', delimiter: str = ',', header: Union[int, List[int], None] = 0, usecols: Optional[List[str]] = None, dtype: Optional[Dict[str, str]] = None, parse_dates: Optional[List[str]] = None, na_values: Optional[List[str]] = None, nrows: Optional[int] = None)
|
||||
|
||||
Reads a CSV file with advanced options:
|
||||
- Supports multiple encodings (utf-8, ascii, etc.)
|
||||
- Configurable column delimiter
|
||||
- Flexible header row handling
|
||||
- Column selection and data type specification
|
||||
- Date parsing
|
||||
- Custom NA/NaN value handling
|
||||
- Row limit option
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
data = read_csv("data.csv")
|
||||
|
||||
# Advanced usage with options
|
||||
data = read_csv(
|
||||
"data.csv",
|
||||
encoding='utf-8',
|
||||
delimiter=',',
|
||||
header=0,
|
||||
usecols=['name', 'age', 'city'],
|
||||
dtype={'age': 'int32'},
|
||||
parse_dates=['birth_date'],
|
||||
na_values=['N/A', 'missing'],
|
||||
nrows=1000
|
||||
)
|
||||
# Returns: List[Dict[str, Any]]
|
||||
# Example: [{"name": "Alice", "age": 25, "city": "New York"}, ...]
|
||||
```
|
||||
|
||||
### write_csv(filepath: str, data: List[Dict[str, Any]], encoding: str = 'utf-8', delimiter: str = ',', index: bool = False, header: bool = True, float_format: Optional[str] = None, date_format: Optional[str] = None, mode: str = 'w')
|
||||
|
||||
Writes data to a CSV file with formatting options:
|
||||
- Supports different encodings
|
||||
- Configurable delimiter
|
||||
- Optional row indices
|
||||
- Optional headers
|
||||
- Custom float and date formatting
|
||||
- Append mode support
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
data = [
|
||||
{"name": "Alice", "age": 25, "city": "New York"},
|
||||
{"name": "Bob", "age": 30, "city": "San Francisco"}
|
||||
]
|
||||
success = write_csv("output.csv", data)
|
||||
|
||||
# Advanced usage with formatting
|
||||
success = write_csv(
|
||||
"output.csv",
|
||||
data,
|
||||
encoding='utf-8',
|
||||
delimiter=',',
|
||||
index=False,
|
||||
header=True,
|
||||
float_format='%.2f',
|
||||
date_format='%Y-%m-%d',
|
||||
mode='w'
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### merge_csv(files: List[str], output_file: str, how: str = 'inner', on: Optional[Union[str, List[str]]] = None, suffixes: Optional[tuple] = None)
|
||||
|
||||
Merges multiple CSV files with flexible join options:
|
||||
- Supports different join types (inner, outer, left, right)
|
||||
- Merge on single or multiple columns
|
||||
- Custom suffixes for overlapping columns
|
||||
- Automatic handling of column name conflicts
|
||||
|
||||
```python
|
||||
# Merge two files on a common column
|
||||
success = merge_csv(
|
||||
files=["employees.csv", "salaries.csv"],
|
||||
output_file="merged.csv",
|
||||
how='inner',
|
||||
on='employee_id'
|
||||
)
|
||||
|
||||
# Advanced merge with multiple columns and custom suffixes
|
||||
success = merge_csv(
|
||||
files=["data1.csv", "data2.csv", "data3.csv"],
|
||||
output_file="merged.csv",
|
||||
how='outer',
|
||||
on=['id', 'department'],
|
||||
suffixes=('_2022', '_2023')
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The CSV tools require the following Python packages:
|
||||
- pandas: For advanced CSV operations and data manipulation
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import read_csv, write_csv, merge_csv
|
||||
|
||||
agent = Agent(
|
||||
name="CSVProcessor",
|
||||
description="An agent that processes CSV files",
|
||||
tools=[read_csv, write_csv, merge_csv]
|
||||
)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- File not found errors
|
||||
- Permission errors
|
||||
- Encoding errors
|
||||
- Data format errors
|
||||
- Missing dependency errors
|
||||
|
||||
Errors are logged and returned in a consistent format:
|
||||
- Success cases return the expected data type
|
||||
- Error cases return a dict with an "error" key containing the error message
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic CSV Processing Agent
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import csv
|
||||
from praisonaiagents.tools import read_csv, write_csv, merge_csv
|
||||
|
||||
# Create CSV agent
|
||||
csv_agent = Agent(
|
||||
@@ -124,7 +259,7 @@ csv_agent = Agent(
|
||||
role="CSV Processing Specialist",
|
||||
goal="Process CSV files efficiently and accurately.",
|
||||
backstory="Expert in data processing and analysis.",
|
||||
tools=[csv],
|
||||
tools=[read_csv, write_csv, merge_csv],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -153,7 +288,7 @@ processor_agent = Agent(
|
||||
name="Processor",
|
||||
role="Data Processor",
|
||||
goal="Process CSV data systematically.",
|
||||
tools=[csv],
|
||||
tools=[read_csv, write_csv, merge_csv],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -198,7 +333,7 @@ agents.start()
|
||||
name="CSVProcessor",
|
||||
role="CSV Processing Specialist",
|
||||
goal="Process CSV files accurately and efficiently",
|
||||
tools=[csv]
|
||||
tools=[read_csv, write_csv, merge_csv]
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
@@ -222,7 +357,7 @@ agents.start()
|
||||
processor = Agent(
|
||||
name="Processor",
|
||||
role="CSV Processor",
|
||||
tools=[csv]
|
||||
tools=[read_csv, write_csv, merge_csv]
|
||||
)
|
||||
|
||||
# Analysis agent
|
||||
|
||||
+173
-2
@@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "DuckDB Tools"
|
||||
description: "DuckDB database tools for AI agents."
|
||||
icon: "database"
|
||||
description: "Tools for working with DuckDB databases in AI agents."
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -71,6 +70,95 @@ Use DuckDB Tools to manage and query databases with AI agents.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import execute_query
|
||||
from praisonaiagents.tools import load_csv
|
||||
from praisonaiagents.tools import export_csv
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### execute_query(query: str, params: Optional[Union[tuple, dict]] = None, return_df: bool = True)
|
||||
|
||||
Executes SQL queries with advanced features:
|
||||
- Supports parameterized queries
|
||||
- Returns results as DataFrame records or raw tuples
|
||||
- Full SQL query support (SELECT, INSERT, UPDATE, DELETE, etc.)
|
||||
- Automatic connection management
|
||||
|
||||
```python
|
||||
# Basic SELECT query
|
||||
results = execute_query("SELECT * FROM employees")
|
||||
|
||||
# Parameterized query
|
||||
results = execute_query(
|
||||
"SELECT * FROM employees WHERE department = ? AND salary > ?",
|
||||
params=('Engineering', 75000)
|
||||
)
|
||||
|
||||
# Named parameters
|
||||
results = execute_query(
|
||||
"SELECT * FROM employees WHERE department = :dept",
|
||||
params={'dept': 'Engineering'}
|
||||
)
|
||||
# Returns: List[Dict[str, Any]]
|
||||
# Example: [{"id": 1, "name": "Alice", "department": "Engineering"}, ...]
|
||||
```
|
||||
|
||||
### load_csv(table_name: str, filepath: str, schema: Optional[Dict[str, str]] = None, if_exists: str = 'replace')
|
||||
|
||||
Loads CSV files into DuckDB tables:
|
||||
- Optional schema definition
|
||||
- Flexible table existence handling
|
||||
- Automatic type inference
|
||||
- Support for large files
|
||||
|
||||
```python
|
||||
# Basic usage - auto schema inference
|
||||
success = load_csv("employees", "employees.csv")
|
||||
|
||||
# With custom schema
|
||||
schema = {
|
||||
"id": "INTEGER PRIMARY KEY",
|
||||
"name": "VARCHAR",
|
||||
"salary": "DECIMAL(10,2)",
|
||||
"hire_date": "DATE"
|
||||
}
|
||||
success = load_csv(
|
||||
"employees",
|
||||
"employees.csv",
|
||||
schema=schema,
|
||||
if_exists='replace'
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### export_csv(query: str, filepath: str, params: Optional[Union[tuple, dict]] = None)
|
||||
|
||||
Exports query results to CSV files:
|
||||
- Supports parameterized queries
|
||||
- Automatic header generation
|
||||
- Configurable output formatting
|
||||
- Large result set handling
|
||||
|
||||
```python
|
||||
# Export simple query results
|
||||
success = export_csv(
|
||||
"SELECT * FROM employees",
|
||||
"exported_employees.csv"
|
||||
)
|
||||
|
||||
# Export filtered data with parameters
|
||||
success = export_csv(
|
||||
"SELECT * FROM employees WHERE department = ? AND year = ?",
|
||||
"eng_2023.csv",
|
||||
params=('Engineering', 2023)
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
## Understanding DuckDB Tools
|
||||
|
||||
<Card title="What are DuckDB Tools?" icon="question">
|
||||
@@ -189,6 +277,89 @@ agents = PraisonAIAgents(
|
||||
agents.start()
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The DuckDB tools require the following Python packages:
|
||||
- duckdb: For database operations
|
||||
- pandas: For data manipulation and CSV handling
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import execute_query, load_csv, export_csv
|
||||
|
||||
agent = Agent(
|
||||
name="DBProcessor",
|
||||
description="An agent that works with DuckDB databases",
|
||||
tools=[execute_query, load_csv, export_csv]
|
||||
)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- Database connection errors
|
||||
- Query syntax errors
|
||||
- File I/O errors
|
||||
- Schema validation errors
|
||||
- Missing dependency errors
|
||||
|
||||
Errors are logged and returned in a consistent format:
|
||||
- Success cases return the expected data type
|
||||
- Error cases return a dict with an "error" key containing the error message
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Data Analysis:
|
||||
```python
|
||||
# Load data
|
||||
load_csv("sales", "sales_data.csv")
|
||||
|
||||
# Analyze with SQL
|
||||
results = execute_query("""
|
||||
SELECT
|
||||
department,
|
||||
COUNT(*) as count,
|
||||
AVG(salary) as avg_salary
|
||||
FROM employees
|
||||
GROUP BY department
|
||||
HAVING count > 5
|
||||
ORDER BY avg_salary DESC
|
||||
""")
|
||||
```
|
||||
|
||||
2. Data Export:
|
||||
```python
|
||||
# Export filtered and aggregated data
|
||||
export_csv("""
|
||||
SELECT
|
||||
date_trunc('month', date) as month,
|
||||
SUM(amount) as total_sales
|
||||
FROM sales
|
||||
GROUP BY 1
|
||||
ORDER BY 1
|
||||
""", "monthly_sales.csv")
|
||||
```
|
||||
|
||||
3. Data Transformation:
|
||||
```python
|
||||
# Load and transform data
|
||||
load_csv("raw_data", "input.csv")
|
||||
execute_query("""
|
||||
CREATE TABLE transformed AS
|
||||
SELECT
|
||||
id,
|
||||
UPPER(name) as name,
|
||||
ROUND(amount, 2) as amount,
|
||||
DATE_TRUNC('day', timestamp) as date
|
||||
FROM raw_data
|
||||
""")
|
||||
export_csv("SELECT * FROM transformed", "transformed.csv")
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
<AccordionGroup>
|
||||
|
||||
+200
-10
@@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "Excel Tools"
|
||||
description: "Excel file processing tools for AI agents."
|
||||
icon: "file-excel"
|
||||
description: "Tools for working with Excel files in AI agents."
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -28,7 +27,7 @@ Use Excel Tools to process and manipulate Excel files with AI agents.
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import excel
|
||||
from praisonaiagents.tools import read_excel, write_excel, merge_excel
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -40,7 +39,7 @@ Use Excel Tools to process and manipulate Excel files with AI agents.
|
||||
role="Excel Processing Specialist",
|
||||
goal="Process Excel files efficiently and accurately.",
|
||||
backstory="Expert in Excel file manipulation and analysis.",
|
||||
tools=[excel],
|
||||
tools=[read_excel, write_excel, merge_excel],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
@@ -71,6 +70,113 @@ Use Excel Tools to process and manipulate Excel files with AI agents.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import read_excel
|
||||
from praisonaiagents.tools import write_excel
|
||||
from praisonaiagents.tools import merge_excel
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### read_excel(filepath: str, sheet_name: Optional[Union[str, int, List[Union[str, int]]]] = 0, header: Optional[int] = 0, usecols: Optional[List[str]] = None, skiprows: Optional[Union[int, List[int]]] = None, na_values: Optional[List[str]] = None, dtype: Optional[Dict[str, str]] = None)
|
||||
|
||||
Reads Excel files with advanced options:
|
||||
- Support for multiple sheets
|
||||
- Flexible header handling
|
||||
- Column selection
|
||||
- Row skipping
|
||||
- Custom NA values
|
||||
- Data type specification
|
||||
|
||||
```python
|
||||
# Basic usage - read first sheet
|
||||
data = read_excel("data.xlsx")
|
||||
|
||||
# Read specific sheets
|
||||
data = read_excel(
|
||||
"data.xlsx",
|
||||
sheet_name=['Sheet1', 'Sheet2'],
|
||||
header=0,
|
||||
usecols=['A', 'B', 'C'],
|
||||
skiprows=[0, 1],
|
||||
na_values=['NA', 'missing'],
|
||||
dtype={'age': 'int32', 'salary': 'float64'}
|
||||
)
|
||||
# Returns: Dict[str, List[Dict[str, Any]]] for multiple sheets
|
||||
# Example: {
|
||||
# 'Sheet1': [{"name": "Alice", "age": 25}, ...],
|
||||
# 'Sheet2': [{"dept": "Engineering", "count": 10}, ...]
|
||||
# }
|
||||
```
|
||||
|
||||
### write_excel(filepath: str, data: Union[Dict[str, List[Dict[str, Any]]], List[Dict[str, Any]]], sheet_name: Optional[str] = None, index: bool = False, header: bool = True, mode: str = 'w')
|
||||
|
||||
Writes data to Excel files with formatting:
|
||||
- Multiple sheet support
|
||||
- Append mode for existing files
|
||||
- Optional row indices
|
||||
- Optional headers
|
||||
- Flexible data structure handling
|
||||
|
||||
```python
|
||||
# Write single sheet
|
||||
data = [
|
||||
{"name": "Alice", "age": 25, "city": "New York"},
|
||||
{"name": "Bob", "age": 30, "city": "San Francisco"}
|
||||
]
|
||||
success = write_excel("output.xlsx", data, sheet_name="Employees")
|
||||
|
||||
# Write multiple sheets
|
||||
data = {
|
||||
"Employees": [
|
||||
{"name": "Alice", "age": 25},
|
||||
{"name": "Bob", "age": 30}
|
||||
],
|
||||
"Departments": [
|
||||
{"name": "Engineering", "count": 50},
|
||||
{"name": "Sales", "count": 30}
|
||||
]
|
||||
}
|
||||
success = write_excel(
|
||||
"company.xlsx",
|
||||
data,
|
||||
index=False,
|
||||
header=True,
|
||||
mode='w'
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### merge_excel(files: List[str], output_file: str, how: str = 'inner', on: Optional[Union[str, List[str]]] = None, suffixes: Optional[Tuple[str, str]] = None)
|
||||
|
||||
Merges multiple Excel files:
|
||||
- Flexible join operations
|
||||
- Multiple key columns support
|
||||
- Custom column suffix handling
|
||||
- Preserves data types
|
||||
|
||||
```python
|
||||
# Merge two files on a common column
|
||||
success = merge_excel(
|
||||
files=["employees.xlsx", "salaries.xlsx"],
|
||||
output_file="merged.xlsx",
|
||||
how='inner',
|
||||
on='employee_id'
|
||||
)
|
||||
|
||||
# Advanced merge with multiple keys and custom suffixes
|
||||
success = merge_excel(
|
||||
files=["data2022.xlsx", "data2023.xlsx"],
|
||||
output_file="combined.xlsx",
|
||||
how='outer',
|
||||
on=['id', 'department'],
|
||||
suffixes=('_2022', '_2023')
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
## Understanding Excel Tools
|
||||
|
||||
<Card title="What are Excel Tools?" icon="question">
|
||||
@@ -88,7 +194,7 @@ Use Excel Tools to process and manipulate Excel files with AI agents.
|
||||
<Card title="Excel Agent" icon="user-robot">
|
||||
Create specialized Excel agents:
|
||||
```python
|
||||
Agent(tools=[excel])
|
||||
Agent(tools=[excel, read_excel, write_excel, merge_excel])
|
||||
```
|
||||
</Card>
|
||||
<Card title="Excel Task" icon="list-check">
|
||||
@@ -117,7 +223,7 @@ Use Excel Tools to process and manipulate Excel files with AI agents.
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import excel
|
||||
from praisonaiagents.tools import excel, read_excel, write_excel, merge_excel
|
||||
|
||||
# Create Excel agent
|
||||
excel_agent = Agent(
|
||||
@@ -125,7 +231,7 @@ excel_agent = Agent(
|
||||
role="Excel Processing Specialist",
|
||||
goal="Process Excel files efficiently and accurately.",
|
||||
backstory="Expert in spreadsheet manipulation and analysis.",
|
||||
tools=[excel],
|
||||
tools=[excel, read_excel, write_excel, merge_excel],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -154,7 +260,7 @@ processor_agent = Agent(
|
||||
name="Processor",
|
||||
role="Data Processor",
|
||||
goal="Process Excel data systematically.",
|
||||
tools=[excel],
|
||||
tools=[excel, read_excel, write_excel, merge_excel],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -199,7 +305,7 @@ agents.start()
|
||||
name="ExcelProcessor",
|
||||
role="Excel Processing Specialist",
|
||||
goal="Process Excel files accurately and efficiently",
|
||||
tools=[excel]
|
||||
tools=[excel, read_excel, write_excel, merge_excel]
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
@@ -223,7 +329,7 @@ agents.start()
|
||||
processor = Agent(
|
||||
name="Processor",
|
||||
role="Excel Processor",
|
||||
tools=[excel]
|
||||
tools=[excel, read_excel, write_excel, merge_excel]
|
||||
)
|
||||
|
||||
# Analysis agent
|
||||
@@ -248,3 +354,87 @@ agents = PraisonAIAgents(
|
||||
agents=[processor, analyzer],
|
||||
tasks=[process_task, analyze_task]
|
||||
)
|
||||
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The Excel tools require the following Python packages:
|
||||
- pandas: For data manipulation
|
||||
- openpyxl: For Excel file operations
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import read_excel, write_excel, merge_excel
|
||||
|
||||
agent = Agent(
|
||||
name="ExcelProcessor",
|
||||
description="An agent that processes Excel files",
|
||||
tools=[read_excel, write_excel, merge_excel]
|
||||
)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- File not found errors
|
||||
- Permission errors
|
||||
- Invalid sheet names
|
||||
- Data format errors
|
||||
- Missing dependency errors
|
||||
|
||||
Errors are logged and returned in a consistent format:
|
||||
- Success cases return the expected data type
|
||||
- Error cases return a dict with an "error" key containing the error message
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Data Analysis:
|
||||
```python
|
||||
# Read and analyze employee data
|
||||
data = read_excel(
|
||||
"employees.xlsx",
|
||||
sheet_name="Salaries",
|
||||
usecols=["department", "salary"]
|
||||
)
|
||||
|
||||
# Write summary to new sheet
|
||||
summary = [
|
||||
{"department": dept, "avg_salary": sum(d["salary"] for d in dept_data) / len(dept_data)}
|
||||
for dept, dept_data in groupby(data, key=lambda x: x["department"])
|
||||
]
|
||||
write_excel("summary.xlsx", summary, sheet_name="Salary Summary")
|
||||
```
|
||||
|
||||
2. Data Consolidation:
|
||||
```python
|
||||
# Merge monthly reports
|
||||
monthly_files = ["jan.xlsx", "feb.xlsx", "mar.xlsx"]
|
||||
merge_excel(
|
||||
files=monthly_files,
|
||||
output_file="q1_report.xlsx",
|
||||
how='outer',
|
||||
on='transaction_id'
|
||||
)
|
||||
```
|
||||
|
||||
3. Multi-sheet Processing:
|
||||
```python
|
||||
# Read multiple sheets
|
||||
data = read_excel(
|
||||
"company_data.xlsx",
|
||||
sheet_name=None # Read all sheets
|
||||
)
|
||||
|
||||
# Process each sheet
|
||||
processed = {
|
||||
sheet: [process_record(record) for record in records]
|
||||
for sheet, records in data.items()
|
||||
}
|
||||
|
||||
# Write back to new file
|
||||
write_excel("processed_data.xlsx", processed)
|
||||
+222
-2
@@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "File Tools"
|
||||
description: "File system operations and management tools for AI agents."
|
||||
icon: "folder"
|
||||
description: "Basic file operation tools for AI agents."
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -110,6 +109,227 @@ Use File Tools to manage files and directories with AI agents.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import read_file
|
||||
from praisonaiagents.tools import write_file
|
||||
from praisonaiagents.tools import list_files
|
||||
from praisonaiagents.tools import get_file_info
|
||||
from praisonaiagents.tools import copy_file
|
||||
from praisonaiagents.tools import move_file
|
||||
from praisonaiagents.tools import delete_file
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### read_file(filepath: str, encoding: str = 'utf-8')
|
||||
|
||||
Reads content from a file:
|
||||
- Supports different encodings
|
||||
- Error handling for missing files
|
||||
- Automatic encoding detection
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
content = read_file("example.txt")
|
||||
|
||||
# With specific encoding
|
||||
content = read_file("data.txt", encoding="latin-1")
|
||||
|
||||
# Returns: str (file content)
|
||||
# Error case: Returns error message as string
|
||||
```
|
||||
|
||||
### write_file(filepath: str, content: str, encoding: str = 'utf-8')
|
||||
|
||||
Writes content to a file:
|
||||
- Creates directories if they don't exist
|
||||
- Supports different encodings
|
||||
- Overwrites existing files
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
success = write_file("output.txt", "Hello World")
|
||||
|
||||
# With specific encoding and nested path
|
||||
success = write_file(
|
||||
"path/to/data/output.txt",
|
||||
"Content with special chars: áéíóú",
|
||||
encoding="utf-8"
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### list_files(directory: str, pattern: Optional[str] = None)
|
||||
|
||||
Lists files in a directory:
|
||||
- Optional pattern matching
|
||||
- Detailed file information
|
||||
- Recursive directory support
|
||||
|
||||
```python
|
||||
# List all files
|
||||
files = list_files("/path/to/directory")
|
||||
|
||||
# With pattern matching
|
||||
files = list_files("/path/to/directory", pattern="*.txt")
|
||||
|
||||
# Returns: List[Dict[str, Union[str, int]]]
|
||||
# Example: [
|
||||
# {
|
||||
# 'name': 'example.txt',
|
||||
# 'path': '/path/to/directory/example.txt',
|
||||
# 'size': 1024,
|
||||
# 'modified': 1609459200.0,
|
||||
# 'created': 1609459100.0
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
```
|
||||
|
||||
### get_file_info(filepath: str)
|
||||
|
||||
Gets detailed information about a file:
|
||||
- File metadata
|
||||
- Size and timestamps
|
||||
- Type information
|
||||
- Path details
|
||||
|
||||
```python
|
||||
# Get file information
|
||||
info = get_file_info("example.txt")
|
||||
|
||||
# Returns: Dict[str, Union[str, int]]
|
||||
# Example: {
|
||||
# 'name': 'example.txt',
|
||||
# 'path': '/absolute/path/to/example.txt',
|
||||
# 'size': 1024,
|
||||
# 'modified': 1609459200.0,
|
||||
# 'created': 1609459100.0,
|
||||
# 'is_file': True,
|
||||
# 'is_dir': False,
|
||||
# 'extension': '.txt',
|
||||
# 'parent': '/absolute/path/to'
|
||||
# }
|
||||
```
|
||||
|
||||
### copy_file(src: str, dst: str)
|
||||
|
||||
Copies a file with metadata:
|
||||
- Preserves timestamps
|
||||
- Creates destination directories
|
||||
- Handles existing files
|
||||
|
||||
```python
|
||||
# Basic copy
|
||||
success = copy_file("source.txt", "destination.txt")
|
||||
|
||||
# Copy to new directory
|
||||
success = copy_file(
|
||||
"data.txt",
|
||||
"backup/2023/data_backup.txt"
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### move_file(src: str, dst: str)
|
||||
|
||||
Moves or renames a file:
|
||||
- Creates destination directories
|
||||
- Handles existing files
|
||||
- Cross-device moves
|
||||
|
||||
```python
|
||||
# Move file
|
||||
success = move_file("old/path/file.txt", "new/path/file.txt")
|
||||
|
||||
# Rename file
|
||||
success = move_file(
|
||||
"document.txt",
|
||||
"document_v2.txt"
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### delete_file(filepath: str)
|
||||
|
||||
Deletes a file:
|
||||
- Safe deletion
|
||||
- Error handling
|
||||
- Non-recursive (files only)
|
||||
|
||||
```python
|
||||
# Delete file
|
||||
success = delete_file("unwanted.txt")
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
read_file, write_file, list_files,
|
||||
get_file_info, copy_file, move_file, delete_file
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="FileManager",
|
||||
description="An agent that manages files",
|
||||
tools=[
|
||||
read_file, write_file, list_files,
|
||||
get_file_info, copy_file, move_file, delete_file
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- File not found errors
|
||||
- Permission errors
|
||||
- Path errors
|
||||
- I/O errors
|
||||
- Encoding errors
|
||||
|
||||
Errors are handled consistently:
|
||||
- File operations return bool for success/failure
|
||||
- Information functions return error details in result
|
||||
- All errors are logged for debugging
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. File Organization:
|
||||
```python
|
||||
# List and organize files by extension
|
||||
files = list_files("downloads", pattern="*.*")
|
||||
for file in files:
|
||||
ext = file['extension']
|
||||
if ext:
|
||||
dst = f"organized/{ext[1:]}/{file['name']}"
|
||||
move_file(file['path'], dst)
|
||||
```
|
||||
|
||||
2. File Backup:
|
||||
```python
|
||||
# Create timestamped backups
|
||||
import time
|
||||
files = list_files("important_data")
|
||||
backup_time = time.strftime("%Y%m%d_%H%M%S")
|
||||
for file in files:
|
||||
dst = f"backup/{backup_time}/{file['name']}"
|
||||
copy_file(file['path'], dst)
|
||||
```
|
||||
|
||||
3. File Processing:
|
||||
```python
|
||||
# Read, process, and write files
|
||||
content = read_file("input.txt")
|
||||
processed = process_content(content) # Your processing function
|
||||
write_file("output.txt", processed)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic File Management Agent
|
||||
|
||||
+301
-5
@@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "JSON Tools"
|
||||
description: "JSON file processing tools for AI agents."
|
||||
icon: "brackets-curly"
|
||||
description: "Tools for working with JSON files in AI agents."
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -27,7 +26,10 @@ Use JSON Tools to process and manipulate JSON files with AI agents.
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import json
|
||||
from praisonaiagents.tools import (
|
||||
read_json, write_json, merge_json,
|
||||
validate_json, analyze_json, transform_json
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -39,7 +41,10 @@ Use JSON Tools to process and manipulate JSON files with AI agents.
|
||||
role="JSON Processing Specialist",
|
||||
goal="Process JSON files efficiently and accurately.",
|
||||
backstory="Expert in JSON file manipulation and validation.",
|
||||
tools=[json],
|
||||
tools=[
|
||||
read_json, write_json, merge_json,
|
||||
validate_json, analyze_json, transform_json
|
||||
],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
@@ -70,6 +75,298 @@ Use JSON Tools to process and manipulate JSON files with AI agents.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import read_json
|
||||
from praisonaiagents.tools import write_json
|
||||
from praisonaiagents.tools import merge_json
|
||||
from praisonaiagents.tools import validate_json
|
||||
from praisonaiagents.tools import analyze_json
|
||||
from praisonaiagents.tools import transform_json
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### read_json(filepath: str, encoding: str = 'utf-8', validate_schema: Optional[Dict[str, Any]] = None)
|
||||
|
||||
Reads JSON files with schema validation:
|
||||
- Optional schema validation
|
||||
- Custom encoding support
|
||||
- Error handling
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
data = read_json("config.json")
|
||||
|
||||
# With schema validation
|
||||
schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"age": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
data = read_json(
|
||||
"user.json",
|
||||
encoding="utf-8",
|
||||
validate_schema=schema
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any] (JSON data)
|
||||
# Error case: Returns dict with 'error' key
|
||||
```
|
||||
|
||||
### write_json(data: Union[Dict[str, Any], List[Any]], filepath: str, encoding: str = 'utf-8', indent: int = 2, sort_keys: bool = False, ensure_ascii: bool = False)
|
||||
|
||||
Writes data to JSON files:
|
||||
- Pretty printing with indentation
|
||||
- Optional key sorting
|
||||
- Unicode support
|
||||
- Directory creation
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
data = {"name": "Alice", "age": 30}
|
||||
success = write_json(data, "output.json")
|
||||
|
||||
# With formatting options
|
||||
data = {
|
||||
"users": [
|
||||
{"name": "Alice", "age": 30},
|
||||
{"name": "Bob", "age": 25}
|
||||
]
|
||||
}
|
||||
success = write_json(
|
||||
data,
|
||||
"users.json",
|
||||
indent=4,
|
||||
sort_keys=True,
|
||||
ensure_ascii=False
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### merge_json(files: List[str], output_file: str, merge_arrays: bool = True, overwrite_duplicates: bool = True)
|
||||
|
||||
Merges multiple JSON files:
|
||||
- Deep merging of objects
|
||||
- Array handling options
|
||||
- Duplicate key handling
|
||||
- Nested structure support
|
||||
|
||||
```python
|
||||
# Merge configuration files
|
||||
success = merge_json(
|
||||
files=["config1.json", "config2.json"],
|
||||
output_file="merged_config.json"
|
||||
)
|
||||
|
||||
# Advanced merge with options
|
||||
success = merge_json(
|
||||
files=["base.json", "override.json"],
|
||||
output_file="final.json",
|
||||
merge_arrays=True,
|
||||
overwrite_duplicates=False
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### validate_json(data: Union[Dict[str, Any], str], schema: Dict[str, Any])
|
||||
|
||||
Validates JSON against a schema:
|
||||
- JSON Schema support
|
||||
- Detailed error messages
|
||||
- File or data validation
|
||||
|
||||
```python
|
||||
# Validate data
|
||||
schema = {
|
||||
"type": "object",
|
||||
"required": ["name", "email"],
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"email": {"type": "string", "format": "email"},
|
||||
"age": {"type": "integer", "minimum": 0}
|
||||
}
|
||||
}
|
||||
|
||||
# Validate data directly
|
||||
data = {"name": "Alice", "email": "[email protected]", "age": 25}
|
||||
is_valid, error = validate_json(data, schema)
|
||||
|
||||
# Validate file
|
||||
is_valid, error = validate_json("user.json", schema)
|
||||
# Returns: Tuple[bool, Optional[str]]
|
||||
```
|
||||
|
||||
### analyze_json(data: Union[Dict[str, Any], str], max_depth: int = 10)
|
||||
|
||||
Analyzes JSON structure:
|
||||
- Type information
|
||||
- Size metrics
|
||||
- Nested structure analysis
|
||||
- Sample data
|
||||
|
||||
```python
|
||||
# Analyze file
|
||||
analysis = analyze_json("data.json", max_depth=5)
|
||||
|
||||
# Analyze data structure
|
||||
data = {
|
||||
"users": [
|
||||
{"name": "Alice", "scores": [95, 87, 92]},
|
||||
{"name": "Bob", "scores": [88, 85, 90]}
|
||||
]
|
||||
}
|
||||
analysis = analyze_json(data)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# 'analysis_time': '2023-01-01T12:00:00',
|
||||
# 'structure': {
|
||||
# 'type': 'dict',
|
||||
# 'size': 1,
|
||||
# 'keys': ['users'],
|
||||
# 'children': {
|
||||
# 'users': {
|
||||
# 'type': 'list',
|
||||
# 'length': 2,
|
||||
# 'element_types': ['dict'],
|
||||
# 'sample_elements': [...]
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
### transform_json(data: Union[Dict[str, Any], str], transformations: List[Dict[str, Any]])
|
||||
|
||||
Transforms JSON data:
|
||||
- Multiple operations
|
||||
- Path-based modifications
|
||||
- Nested transformations
|
||||
- Operation types: set, delete, rename, move
|
||||
|
||||
```python
|
||||
# Transform data
|
||||
transformations = [
|
||||
{
|
||||
"operation": "set",
|
||||
"path": "user.settings.theme",
|
||||
"value": "dark"
|
||||
},
|
||||
{
|
||||
"operation": "move",
|
||||
"path": "old.config",
|
||||
"value": "new.config"
|
||||
},
|
||||
{
|
||||
"operation": "delete",
|
||||
"path": "temporary.data"
|
||||
}
|
||||
]
|
||||
|
||||
# Transform file
|
||||
result = transform_json("config.json", transformations)
|
||||
|
||||
# Transform data directly
|
||||
data = {"user": {"name": "Alice"}}
|
||||
result = transform_json(data, transformations)
|
||||
# Returns: Dict[str, Any] (transformed data)
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
read_json, write_json, merge_json,
|
||||
validate_json, analyze_json, transform_json
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="JSONProcessor",
|
||||
description="An agent that processes JSON data",
|
||||
tools=[
|
||||
read_json, write_json, merge_json,
|
||||
validate_json, analyze_json, transform_json
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The JSON tools require the following Python packages:
|
||||
- jsonschema: For JSON schema validation
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- File I/O errors
|
||||
- JSON parsing errors
|
||||
- Schema validation errors
|
||||
- Transformation errors
|
||||
|
||||
Errors are handled consistently:
|
||||
- File operations return bool for success/failure
|
||||
- Data operations return error details in result
|
||||
- All errors are logged for debugging
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Configuration Management:
|
||||
```python
|
||||
# Merge multiple config files
|
||||
success = merge_json(
|
||||
["base_config.json", "env_config.json", "user_config.json"],
|
||||
"final_config.json",
|
||||
merge_arrays=True,
|
||||
overwrite_duplicates=True
|
||||
)
|
||||
|
||||
# Validate configuration
|
||||
schema = {
|
||||
"type": "object",
|
||||
"required": ["database", "api"],
|
||||
"properties": {
|
||||
"database": {
|
||||
"type": "object",
|
||||
"required": ["host", "port"]
|
||||
},
|
||||
"api": {
|
||||
"type": "object",
|
||||
"required": ["key"]
|
||||
}
|
||||
}
|
||||
}
|
||||
is_valid, error = validate_json("final_config.json", schema)
|
||||
```
|
||||
|
||||
2. Data Analysis:
|
||||
```python
|
||||
# Analyze data structure
|
||||
analysis = analyze_json("large_dataset.json", max_depth=3)
|
||||
print(f"Dataset size: {analysis['structure']['size']} entries")
|
||||
print(f"Available fields: {analysis['structure']['keys']}")
|
||||
```
|
||||
|
||||
3. Data Transformation:
|
||||
```python
|
||||
# Transform data format
|
||||
transformations = [
|
||||
{"operation": "rename", "path": "firstName", "value": "first_name"},
|
||||
{"operation": "rename", "path": "lastName", "value": "last_name"},
|
||||
{"operation": "move", "path": "address.zip", "value": "address.postal_code"},
|
||||
{"operation": "delete", "path": "temporary_data"}
|
||||
]
|
||||
result = transform_json("user_data.json", transformations)
|
||||
write_json(result, "transformed_data.json")
|
||||
```
|
||||
|
||||
## Understanding JSON Tools
|
||||
|
||||
<Card title="What are JSON Tools?" icon="question">
|
||||
@@ -247,4 +544,3 @@ agents = PraisonAIAgents(
|
||||
agents=[processor, validator],
|
||||
tasks=[process_task, validate_task]
|
||||
)
|
||||
```
|
||||
@@ -110,6 +110,137 @@ Use Newspaper Tools to scrape and analyze news articles with AI agents.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import get_article
|
||||
from praisonaiagents.tools import get_news_sources
|
||||
from praisonaiagents.tools import get_articles_from_source
|
||||
from praisonaiagents.tools import get_trending_topics
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### get_article(url: str, language: str = 'en')
|
||||
|
||||
Extracts and parses news articles:
|
||||
- Full text extraction
|
||||
- Author detection
|
||||
- Date parsing
|
||||
- Image extraction
|
||||
- NLP processing
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
article = get_article("https://example.com/article")
|
||||
|
||||
# With language specification
|
||||
article = get_article(
|
||||
"https://lemonde.fr/article",
|
||||
language="fr"
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "url": "https://example.com/article",
|
||||
# "title": "Breaking News Story",
|
||||
# "text": "Full article text...",
|
||||
# "authors": ["John Doe", "Jane Smith"],
|
||||
# "publish_date": "2025-01-07T05:31:38",
|
||||
# "top_image": "https://example.com/image.jpg",
|
||||
# "images": ["https://example.com/image1.jpg", ...],
|
||||
# "movies": ["https://example.com/video1.mp4", ...],
|
||||
# "source_domain": "example.com",
|
||||
# "keywords": ["technology", "ai", ...],
|
||||
# "summary": "Article summary..."
|
||||
# }
|
||||
```
|
||||
|
||||
### get_news_sources(category: Optional[str] = None, language: str = 'en', country: Optional[str] = None)
|
||||
|
||||
Gets news sources by category:
|
||||
- Category filtering
|
||||
- Language support
|
||||
- Country filtering
|
||||
- Domain information
|
||||
|
||||
```python
|
||||
# Get all sources
|
||||
sources = get_news_sources()
|
||||
|
||||
# Get technology news sources
|
||||
tech_sources = get_news_sources(
|
||||
category="technology",
|
||||
language="en",
|
||||
country="us"
|
||||
)
|
||||
|
||||
# Returns: List[Dict[str, str]]
|
||||
# Example output:
|
||||
# [
|
||||
# {
|
||||
# "url": "https://techcrunch.com",
|
||||
# "domain": "techcrunch.com",
|
||||
# "name": "TechCrunch",
|
||||
# "category": "technology"
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
```
|
||||
|
||||
### get_articles_from_source(source_url: str, limit: int = 10, language: str = 'en')
|
||||
|
||||
Gets recent articles from a source:
|
||||
- Configurable limit
|
||||
- Language support
|
||||
- Full article parsing
|
||||
- Error handling
|
||||
|
||||
```python
|
||||
# Get latest articles
|
||||
articles = get_articles_from_source(
|
||||
"https://techcrunch.com",
|
||||
limit=5
|
||||
)
|
||||
|
||||
# Get articles in specific language
|
||||
articles = get_articles_from_source(
|
||||
"https://lemonde.fr",
|
||||
limit=10,
|
||||
language="fr"
|
||||
)
|
||||
|
||||
# Returns: List[Dict[str, Any]]
|
||||
# Each article has the same structure as get_article()
|
||||
```
|
||||
|
||||
### get_trending_topics(sources: Optional[List[str]] = None, limit: int = 10, language: str = 'en')
|
||||
|
||||
Analyzes trending topics:
|
||||
- Cross-source analysis
|
||||
- Keyword extraction
|
||||
- Customizable sources
|
||||
- Topic ranking
|
||||
|
||||
```python
|
||||
# Get trending topics from default sources
|
||||
topics = get_trending_topics(limit=5)
|
||||
|
||||
# Get topics from specific sources
|
||||
topics = get_trending_topics(
|
||||
sources=[
|
||||
"https://techcrunch.com",
|
||||
"https://wired.com"
|
||||
],
|
||||
limit=10,
|
||||
language="en"
|
||||
)
|
||||
|
||||
# Returns: List[str]
|
||||
# Example: ["artificial intelligence", "climate change", ...]
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic News Agent
|
||||
@@ -247,3 +378,87 @@ agents = PraisonAIAgents(
|
||||
agents=[monitor, analyst],
|
||||
tasks=[monitor_task, analysis_task]
|
||||
)
|
||||
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
get_article, get_news_sources,
|
||||
get_articles_from_source, get_trending_topics
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="NewsAnalyzer",
|
||||
description="An agent that analyzes news articles",
|
||||
tools=[
|
||||
get_article, get_news_sources,
|
||||
get_articles_from_source, get_trending_topics
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The newspaper tools require the following Python packages:
|
||||
- newspaper3k: For article extraction and parsing
|
||||
- nltk: For NLP processing (automatically installed with newspaper3k)
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- Network errors
|
||||
- Parsing errors
|
||||
- Language errors
|
||||
- Source availability errors
|
||||
|
||||
Errors are handled consistently:
|
||||
- Success cases return the expected data type
|
||||
- Error cases return a dict with an "error" key
|
||||
- All errors are logged for debugging
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. News Monitoring:
|
||||
```python
|
||||
# Monitor tech news
|
||||
sources = get_news_sources(category="technology")
|
||||
for source in sources:
|
||||
articles = get_articles_from_source(
|
||||
source["url"],
|
||||
limit=5
|
||||
)
|
||||
for article in articles:
|
||||
if "ai" in article.get("keywords", []):
|
||||
print(f"AI article found: {article['title']}")
|
||||
```
|
||||
|
||||
2. Trend Analysis:
|
||||
```python
|
||||
# Analyze trending topics
|
||||
topics = get_trending_topics(limit=10)
|
||||
print("Current hot topics:")
|
||||
for i, topic in enumerate(topics, 1):
|
||||
print(f"{i}. {topic}")
|
||||
```
|
||||
|
||||
3. Content Aggregation:
|
||||
```python
|
||||
# Aggregate news from multiple sources
|
||||
def aggregate_news(categories):
|
||||
all_articles = []
|
||||
for category in categories:
|
||||
sources = get_news_sources(category=category)
|
||||
for source in sources[:3]: # Top 3 sources per category
|
||||
articles = get_articles_from_source(
|
||||
source["url"],
|
||||
limit=3
|
||||
)
|
||||
all_articles.extend(articles)
|
||||
return all_articles
|
||||
|
||||
news = aggregate_news(["technology", "business", "science"])
|
||||
+335
-1
@@ -110,6 +110,341 @@ Use Pandas Tools to manipulate and analyze data with AI agents.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import read_csv
|
||||
from praisonaiagents.tools import read_excel
|
||||
from praisonaiagents.tools import write_csv
|
||||
from praisonaiagents.tools import write_excel
|
||||
from praisonaiagents.tools import filter_data
|
||||
from praisonaiagents.tools import get_summary
|
||||
from praisonaiagents.tools import group_by
|
||||
from praisonaiagents.tools import pivot_table
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### read_csv(filepath: str, **kwargs)
|
||||
|
||||
Reads CSV files into pandas DataFrames:
|
||||
- Flexible data import
|
||||
- Error handling
|
||||
- Additional pandas options
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
df = read_csv("data.csv")
|
||||
|
||||
# With additional options
|
||||
df = read_csv(
|
||||
"data.csv",
|
||||
encoding="utf-8",
|
||||
sep=",",
|
||||
header=0,
|
||||
usecols=["name", "age", "salary"]
|
||||
)
|
||||
|
||||
# Returns: pd.DataFrame
|
||||
# Error case: Returns dict with 'error' key
|
||||
```
|
||||
|
||||
### read_excel(filepath: str, **kwargs)
|
||||
|
||||
Reads Excel files into pandas DataFrames:
|
||||
- Multiple sheet support
|
||||
- Error handling
|
||||
- Additional pandas options
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
df = read_excel("data.xlsx")
|
||||
|
||||
# With sheet specification
|
||||
df = read_excel(
|
||||
"data.xlsx",
|
||||
sheet_name="Sheet1",
|
||||
header=0,
|
||||
usecols="A:D"
|
||||
)
|
||||
|
||||
# Returns: pd.DataFrame
|
||||
# Error case: Returns dict with 'error' key
|
||||
```
|
||||
|
||||
### write_csv(df: pd.DataFrame, filepath: str, **kwargs)
|
||||
|
||||
Writes DataFrames to CSV files:
|
||||
- Directory creation
|
||||
- Error handling
|
||||
- Formatting options
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
success = write_csv(df, "output.csv")
|
||||
|
||||
# With formatting options
|
||||
success = write_csv(
|
||||
df,
|
||||
"output.csv",
|
||||
index=False,
|
||||
encoding="utf-8",
|
||||
sep=",",
|
||||
date_format="%Y-%m-%d"
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### write_excel(df: pd.DataFrame, filepath: str, **kwargs)
|
||||
|
||||
Writes DataFrames to Excel files:
|
||||
- Directory creation
|
||||
- Error handling
|
||||
- Excel-specific options
|
||||
|
||||
```python
|
||||
# Basic usage
|
||||
success = write_excel(df, "output.xlsx")
|
||||
|
||||
# With formatting options
|
||||
success = write_excel(
|
||||
df,
|
||||
"output.xlsx",
|
||||
sheet_name="Data",
|
||||
index=False,
|
||||
freeze_panes=(1,0)
|
||||
)
|
||||
# Returns: bool (True if successful)
|
||||
```
|
||||
|
||||
### filter_data(df: pd.DataFrame, query: str)
|
||||
|
||||
Filters DataFrames using query strings:
|
||||
- SQL-like syntax
|
||||
- Complex conditions
|
||||
- Efficient filtering
|
||||
|
||||
```python
|
||||
# Basic filtering
|
||||
filtered_df = filter_data(df, "age > 25")
|
||||
|
||||
# Complex conditions
|
||||
filtered_df = filter_data(
|
||||
df,
|
||||
"age > 25 and salary >= 50000 and city == 'New York'"
|
||||
)
|
||||
|
||||
# Returns: pd.DataFrame
|
||||
# Error case: Returns dict with 'error' key
|
||||
```
|
||||
|
||||
### get_summary(df: pd.DataFrame)
|
||||
|
||||
Generates comprehensive data summaries:
|
||||
- Basic statistics
|
||||
- Data types
|
||||
- Memory usage
|
||||
- Null counts
|
||||
|
||||
```python
|
||||
# Get data summary
|
||||
summary = get_summary(df)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# "shape": [1000, 5],
|
||||
# "columns": ["name", "age", "salary", "city"],
|
||||
# "dtypes": {
|
||||
# "name": "object",
|
||||
# "age": "int64",
|
||||
# "salary": "float64",
|
||||
# "city": "object"
|
||||
# },
|
||||
# "null_counts": {
|
||||
# "name": 0,
|
||||
# "age": 2,
|
||||
# "salary": 1,
|
||||
# "city": 0
|
||||
# },
|
||||
# "numeric_summary": {
|
||||
# "age": {
|
||||
# "count": 998,
|
||||
# "mean": 35.5,
|
||||
# "std": 12.3,
|
||||
# "min": 18,
|
||||
# "25%": 28,
|
||||
# "50%": 35,
|
||||
# "75%": 45,
|
||||
# "max": 65
|
||||
# },
|
||||
# ...
|
||||
# },
|
||||
# "memory_usage": 40960
|
||||
# }
|
||||
```
|
||||
|
||||
### group_by(df: pd.DataFrame, columns: Union[str, List[str]], agg_dict: Dict[str, Union[str, List[str]]])
|
||||
|
||||
Groups and aggregates data:
|
||||
- Multiple grouping columns
|
||||
- Multiple aggregations
|
||||
- Custom functions
|
||||
|
||||
```python
|
||||
# Basic grouping
|
||||
grouped_df = group_by(
|
||||
df,
|
||||
columns="city",
|
||||
agg_dict={"salary": "mean"}
|
||||
)
|
||||
|
||||
# Complex grouping
|
||||
grouped_df = group_by(
|
||||
df,
|
||||
columns=["city", "department"],
|
||||
agg_dict={
|
||||
"salary": ["mean", "sum", "count"],
|
||||
"age": ["min", "max", "mean"]
|
||||
}
|
||||
)
|
||||
|
||||
# Returns: pd.DataFrame
|
||||
# Error case: Returns dict with 'error' key
|
||||
```
|
||||
|
||||
### pivot_table(df: pd.DataFrame, index: Union[str, List[str]], columns: Optional[Union[str, List[str]]] = None, values: Optional[Union[str, List[str]]] = None, aggfunc: str = "mean")
|
||||
|
||||
Creates pivot tables:
|
||||
- Multiple index levels
|
||||
- Column pivoting
|
||||
- Custom aggregations
|
||||
- Flexible reshaping
|
||||
|
||||
```python
|
||||
# Basic pivot
|
||||
pivot_df = pivot_table(
|
||||
df,
|
||||
index="city",
|
||||
columns="department",
|
||||
values="salary"
|
||||
)
|
||||
|
||||
# Complex pivot
|
||||
pivot_df = pivot_table(
|
||||
df,
|
||||
index=["city", "department"],
|
||||
columns="year",
|
||||
values=["salary", "headcount"],
|
||||
aggfunc={
|
||||
"salary": "mean",
|
||||
"headcount": "sum"
|
||||
}
|
||||
)
|
||||
|
||||
# Returns: pd.DataFrame
|
||||
# Error case: Returns dict with 'error' key
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
read_csv, read_excel, write_csv, write_excel,
|
||||
filter_data, get_summary, group_by, pivot_table
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="DataAnalyzer",
|
||||
description="An agent that analyzes data using pandas",
|
||||
tools=[
|
||||
read_csv, read_excel, write_csv, write_excel,
|
||||
filter_data, get_summary, group_by, pivot_table
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The pandas tools require the following Python packages:
|
||||
- pandas: For data manipulation and analysis
|
||||
- numpy: For numerical operations (automatically installed with pandas)
|
||||
- openpyxl: For Excel file support (optional)
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- File I/O errors
|
||||
- Data format errors
|
||||
- Query syntax errors
|
||||
- Memory errors
|
||||
|
||||
Errors are handled consistently:
|
||||
- File operations return bool for success/failure
|
||||
- Data operations return error details in result
|
||||
- All errors are logged for debugging
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Data Analysis:
|
||||
```python
|
||||
# Load and analyze sales data
|
||||
df = read_csv("sales_data.csv")
|
||||
summary = get_summary(df)
|
||||
print(f"Total records: {summary['shape'][0]}")
|
||||
print(f"Missing values: {summary['null_counts']}")
|
||||
|
||||
# Filter high-value transactions
|
||||
high_value = filter_data(df, "amount > 10000")
|
||||
write_excel(high_value, "high_value_sales.xlsx")
|
||||
```
|
||||
|
||||
2. Sales Reporting:
|
||||
```python
|
||||
# Create sales summary by region and product
|
||||
sales_summary = group_by(
|
||||
df,
|
||||
columns=["region", "product"],
|
||||
agg_dict={
|
||||
"amount": ["sum", "mean", "count"],
|
||||
"profit": ["sum", "mean"]
|
||||
}
|
||||
)
|
||||
|
||||
# Create pivot table for quarterly analysis
|
||||
quarterly_sales = pivot_table(
|
||||
df,
|
||||
index="product",
|
||||
columns="quarter",
|
||||
values="amount",
|
||||
aggfunc="sum"
|
||||
)
|
||||
```
|
||||
|
||||
3. Data Transformation:
|
||||
```python
|
||||
# Load and clean customer data
|
||||
customers = read_excel("customers.xlsx")
|
||||
filtered = filter_data(
|
||||
customers,
|
||||
"age >= 18 and status == 'active'"
|
||||
)
|
||||
|
||||
# Group by demographics
|
||||
demographics = group_by(
|
||||
filtered,
|
||||
columns=["age_group", "region"],
|
||||
agg_dict={
|
||||
"spending": ["mean", "sum"],
|
||||
"visits": "count"
|
||||
}
|
||||
)
|
||||
write_csv(demographics, "demographic_analysis.csv")
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Data Analysis Agent
|
||||
@@ -247,4 +582,3 @@ agents = PraisonAIAgents(
|
||||
agents=[prep_agent, analyst],
|
||||
tasks=[prep_task, analysis_task]
|
||||
)
|
||||
```
|
||||
+316
-38
@@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "Python Tools"
|
||||
description: "Python code execution tools for AI agents."
|
||||
icon: "python"
|
||||
description: "Tools for Python code execution, analysis, and formatting in AI agents."
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -27,7 +26,10 @@ Use Python Tools to execute and manage Python code with AI agents.
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import python
|
||||
from praisonaiagents.tools import (
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
)
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -39,7 +41,10 @@ Use Python Tools to execute and manage Python code with AI agents.
|
||||
role="Python Code Specialist",
|
||||
goal="Execute Python code efficiently and safely.",
|
||||
backstory="Expert in Python programming and code execution.",
|
||||
tools=[python],
|
||||
tools=[
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
],
|
||||
self_reflect=False
|
||||
)
|
||||
```
|
||||
@@ -70,6 +75,293 @@ Use Python Tools to execute and manage Python code with AI agents.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import execute_code
|
||||
from praisonaiagents.tools import analyze_code
|
||||
from praisonaiagents.tools import format_code
|
||||
from praisonaiagents.tools import lint_code
|
||||
from praisonaiagents.tools import disassemble_code
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### execute_code(code: str, globals_dict: Optional[Dict[str, Any]] = None, locals_dict: Optional[Dict[str, Any]] = None, timeout: int = 30, max_output_size: int = 10000)
|
||||
|
||||
Safely executes Python code:
|
||||
- Isolated execution environment
|
||||
- Output capture
|
||||
- Error handling
|
||||
- Timeout protection
|
||||
- Output size limits
|
||||
|
||||
```python
|
||||
# Basic execution
|
||||
result = execute_code("print('Hello, World!')")
|
||||
|
||||
# With custom environment
|
||||
result = execute_code(
|
||||
"""
|
||||
x = 10
|
||||
y = 20
|
||||
print(f'Sum: {x + y}')
|
||||
""",
|
||||
globals_dict={'__builtins__': __builtins__},
|
||||
timeout=5
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# 'result': None,
|
||||
# 'stdout': 'Hello, World!\n',
|
||||
# 'stderr': '',
|
||||
# 'success': True
|
||||
# }
|
||||
```
|
||||
|
||||
### analyze_code(code: str)
|
||||
|
||||
Analyzes Python code structure:
|
||||
- Import statements
|
||||
- Function definitions
|
||||
- Class definitions
|
||||
- Variable usage
|
||||
- Code complexity
|
||||
|
||||
```python
|
||||
# Analyze code structure
|
||||
analysis = analyze_code("""
|
||||
def greet(name):
|
||||
return f"Hello, {name}!"
|
||||
|
||||
class Person:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
""")
|
||||
|
||||
# Returns: Dict[str, Any]
|
||||
# Example output:
|
||||
# {
|
||||
# 'imports': [],
|
||||
# 'functions': [
|
||||
# {
|
||||
# 'name': 'greet',
|
||||
# 'args': ['name'],
|
||||
# 'decorators': []
|
||||
# }
|
||||
# ],
|
||||
# 'classes': [
|
||||
# {
|
||||
# 'name': 'Person',
|
||||
# 'bases': [],
|
||||
# 'decorators': []
|
||||
# }
|
||||
# ],
|
||||
# 'variables': ['name'],
|
||||
# 'complexity': {
|
||||
# 'lines': 6,
|
||||
# 'functions': 2,
|
||||
# 'classes': 1,
|
||||
# 'branches': 0
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
### format_code(code: str, style: str = 'black', line_length: int = 88)
|
||||
|
||||
Formats Python code:
|
||||
- Multiple style options
|
||||
- Line length control
|
||||
- PEP 8 compliance
|
||||
- Consistent formatting
|
||||
|
||||
```python
|
||||
# Format with black
|
||||
formatted = format_code("""
|
||||
def messy_function(x,y, z):
|
||||
if x>0:
|
||||
return y+z
|
||||
else:
|
||||
return y-z
|
||||
""")
|
||||
|
||||
# Format with PEP 8
|
||||
formatted = format_code(
|
||||
"""
|
||||
def messy_function(x,y, z):
|
||||
if x>0:
|
||||
return y+z
|
||||
else:
|
||||
return y-z
|
||||
""",
|
||||
style='pep8',
|
||||
line_length=79
|
||||
)
|
||||
|
||||
# Returns: str
|
||||
# Example output:
|
||||
# def messy_function(x, y, z):
|
||||
# if x > 0:
|
||||
# return y + z
|
||||
# else:
|
||||
# return y - z
|
||||
```
|
||||
|
||||
### lint_code(code: str)
|
||||
|
||||
Lints Python code for issues:
|
||||
- Code quality checks
|
||||
- Style violations
|
||||
- Potential bugs
|
||||
- Best practices
|
||||
|
||||
```python
|
||||
# Lint code for issues
|
||||
results = lint_code("""
|
||||
def bad_function():
|
||||
unused_var = 42
|
||||
return 'result'
|
||||
""")
|
||||
|
||||
# Returns: Dict[str, List[Dict[str, Any]]]
|
||||
# Example output:
|
||||
# {
|
||||
# 'errors': [],
|
||||
# 'warnings': [
|
||||
# {
|
||||
# 'type': 'warning',
|
||||
# 'module': 'bad_function',
|
||||
# 'obj': 'unused_var',
|
||||
# 'line': 2,
|
||||
# 'column': 4,
|
||||
# 'path': '<string>',
|
||||
# 'symbol': 'unused-variable',
|
||||
# 'message': 'Unused variable "unused_var"',
|
||||
# 'message-id': 'W0612'
|
||||
# }
|
||||
# ],
|
||||
# 'conventions': []
|
||||
# }
|
||||
```
|
||||
|
||||
### disassemble_code(code: str)
|
||||
|
||||
Disassembles Python code to bytecode:
|
||||
- Bytecode inspection
|
||||
- Performance analysis
|
||||
- Code optimization
|
||||
- Debugging support
|
||||
|
||||
```python
|
||||
# Disassemble code to bytecode
|
||||
bytecode = disassemble_code("""
|
||||
def add(a, b):
|
||||
return a + b
|
||||
""")
|
||||
|
||||
# Returns: str
|
||||
# Example output:
|
||||
# 1 0 LOAD_CONST 0 (<code object add at ...>)
|
||||
# 2 LOAD_CONST 1 ('add')
|
||||
# 4 MAKE_FUNCTION 0
|
||||
# 6 STORE_NAME 0 (add)
|
||||
# 8 LOAD_CONST 2 (None)
|
||||
# 10 RETURN_VALUE
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="PythonDeveloper",
|
||||
description="An agent that helps with Python development",
|
||||
tools=[
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The Python tools require the following packages:
|
||||
- black: For code formatting (black style)
|
||||
- autopep8: For code formatting (PEP 8 style)
|
||||
- pylint: For code linting
|
||||
|
||||
These will be automatically installed when needed.
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- Code execution errors
|
||||
- Syntax errors
|
||||
- Import errors
|
||||
- Timeout errors
|
||||
- Memory errors
|
||||
|
||||
Errors are handled consistently:
|
||||
- Success cases return expected data type
|
||||
- Error cases return None or error details
|
||||
- All errors are logged for debugging
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. Code Testing:
|
||||
```python
|
||||
# Test code execution
|
||||
test_code = """
|
||||
def factorial(n):
|
||||
return 1 if n <= 1 else n * factorial(n - 1)
|
||||
|
||||
result = factorial(5)
|
||||
print(f"Factorial: {result}")
|
||||
"""
|
||||
result = execute_code(test_code)
|
||||
print(f"Output: {result['stdout']}")
|
||||
```
|
||||
|
||||
2. Code Quality:
|
||||
```python
|
||||
# Check code quality
|
||||
code = """
|
||||
def process_data(data):
|
||||
processed = []
|
||||
for item in data:
|
||||
if item > 0:
|
||||
processed.append(item * 2)
|
||||
return processed
|
||||
"""
|
||||
analysis = analyze_code(code)
|
||||
lint_results = lint_code(code)
|
||||
formatted = format_code(code)
|
||||
```
|
||||
|
||||
3. Code Analysis:
|
||||
```python
|
||||
# Analyze code structure
|
||||
code = """
|
||||
class DataProcessor:
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
def process(self):
|
||||
return [x * 2 for x in self.data]
|
||||
"""
|
||||
structure = analyze_code(code)
|
||||
bytecode = disassemble_code(code)
|
||||
print(f"Classes: {structure['classes']}")
|
||||
print(f"Functions: {structure['functions']}")
|
||||
```
|
||||
|
||||
## Understanding Python Tools
|
||||
|
||||
<Card title="What are Python Tools?" icon="question">
|
||||
@@ -81,42 +373,16 @@ Use Python Tools to execute and manage Python code with AI agents.
|
||||
- Environment control
|
||||
</Card>
|
||||
|
||||
## Key Components
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Python Agent" icon="user-robot">
|
||||
Create specialized Python agents:
|
||||
```python
|
||||
Agent(tools=[python])
|
||||
```
|
||||
</Card>
|
||||
<Card title="Python Task" icon="list-check">
|
||||
Define Python tasks:
|
||||
```python
|
||||
Task(description="python_operation")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Process Types" icon="arrows-split-up-and-left">
|
||||
Sequential or parallel processing:
|
||||
```python
|
||||
process="sequential"
|
||||
```
|
||||
</Card>
|
||||
<Card title="Python Options" icon="sliders">
|
||||
Customize execution parameters:
|
||||
```python
|
||||
timeout=30, capture_output=True
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Python Execution Agent
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import python
|
||||
from praisonaiagents.tools import (
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
)
|
||||
|
||||
# Create Python agent
|
||||
python_agent = Agent(
|
||||
@@ -124,7 +390,10 @@ python_agent = Agent(
|
||||
role="Code Execution Specialist",
|
||||
goal="Execute Python code efficiently and safely.",
|
||||
backstory="Expert in Python programming and execution.",
|
||||
tools=[python],
|
||||
tools=[
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -153,7 +422,10 @@ executor_agent = Agent(
|
||||
name="CodeExecutor",
|
||||
role="Code Execution Specialist",
|
||||
goal="Execute Python code efficiently.",
|
||||
tools=[python],
|
||||
tools=[
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
],
|
||||
self_reflect=False
|
||||
)
|
||||
|
||||
@@ -198,7 +470,10 @@ agents.start()
|
||||
name="PythonExecutor",
|
||||
role="Code Execution Specialist",
|
||||
goal="Execute code safely and efficiently",
|
||||
tools=[python]
|
||||
tools=[
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
]
|
||||
)
|
||||
```
|
||||
</Accordion>
|
||||
@@ -222,7 +497,10 @@ agents.start()
|
||||
executor = Agent(
|
||||
name="Executor",
|
||||
role="Code Executor",
|
||||
tools=[python]
|
||||
tools=[
|
||||
execute_code, analyze_code, format_code,
|
||||
lint_code, disassemble_code
|
||||
]
|
||||
)
|
||||
|
||||
# Monitor agent
|
||||
|
||||
+246
-33
@@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "Shell Tools"
|
||||
description: "Command-line interface tools for AI agents."
|
||||
icon: "terminal"
|
||||
description: "Tools for executing shell commands and managing system processes in AI agents."
|
||||
---
|
||||
|
||||
<Note>
|
||||
@@ -27,7 +26,7 @@ Use Shell Tools to execute and manage shell commands with AI agents.
|
||||
Import the necessary components:
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import shell
|
||||
from praisonaiagents.tools import shell, execute_command, list_processes, kill_process, get_system_info
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -81,42 +80,13 @@ Use Shell Tools to execute and manage shell commands with AI agents.
|
||||
- Environment management
|
||||
</Card>
|
||||
|
||||
## Key Components
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Shell Agent" icon="user-robot">
|
||||
Create specialized shell agents:
|
||||
```python
|
||||
Agent(tools=[shell])
|
||||
```
|
||||
</Card>
|
||||
<Card title="Shell Task" icon="list-check">
|
||||
Define shell tasks:
|
||||
```python
|
||||
Task(description="shell_command")
|
||||
```
|
||||
</Card>
|
||||
<Card title="Process Types" icon="arrows-split-up-and-left">
|
||||
Sequential or parallel processing:
|
||||
```python
|
||||
process="sequential"
|
||||
```
|
||||
</Card>
|
||||
<Card title="Shell Options" icon="sliders">
|
||||
Customize shell parameters:
|
||||
```python
|
||||
timeout=30, shell=True
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Shell Command Agent
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent, Task, PraisonAIAgents
|
||||
from praisonaiagents.tools import shell
|
||||
from praisonaiagents.tools import shell, execute_command, list_processes, kill_process, get_system_info
|
||||
|
||||
# Create shell agent
|
||||
shell_agent = Agent(
|
||||
@@ -188,6 +158,249 @@ agents = PraisonAIAgents(
|
||||
agents.start()
|
||||
```
|
||||
|
||||
## Available Functions
|
||||
|
||||
```python
|
||||
from praisonaiagents.tools import execute_command
|
||||
from praisonaiagents.tools import list_processes
|
||||
from praisonaiagents.tools import kill_process
|
||||
from praisonaiagents.tools import get_system_info
|
||||
```
|
||||
|
||||
## Function Details
|
||||
|
||||
### execute_command(command: str, cwd: Optional[str] = None, timeout: int = 30, shell: bool = False, env: Optional[Dict[str, str]] = None, max_output_size: int = 10000)
|
||||
|
||||
Safely executes shell commands:
|
||||
- Timeout protection
|
||||
- Output capture
|
||||
- Error handling
|
||||
- Environment control
|
||||
- Working directory control
|
||||
|
||||
```python
|
||||
# Basic command execution
|
||||
result = execute_command("ls -la")
|
||||
|
||||
# Advanced execution
|
||||
result = execute_command(
|
||||
"python script.py",
|
||||
cwd="/path/to/scripts",
|
||||
timeout=60,
|
||||
env={"PYTHONPATH": "/custom/path"},
|
||||
shell=True
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Union[str, int, bool]]
|
||||
# Example output:
|
||||
# {
|
||||
# 'stdout': 'command output...',
|
||||
# 'stderr': 'error output if any',
|
||||
# 'exit_code': 0,
|
||||
# 'success': True,
|
||||
# 'execution_time': 0.123
|
||||
# }
|
||||
```
|
||||
|
||||
### list_processes()
|
||||
|
||||
Lists running system processes:
|
||||
- Process details
|
||||
- Resource usage
|
||||
- User information
|
||||
- Performance metrics
|
||||
|
||||
```python
|
||||
# Get list of running processes
|
||||
processes = list_processes()
|
||||
|
||||
# Sort by CPU usage
|
||||
cpu_intensive = sorted(
|
||||
processes,
|
||||
key=lambda x: x['cpu_percent'],
|
||||
reverse=True
|
||||
)[:5]
|
||||
|
||||
# Returns: List[Dict[str, Union[int, str, float]]]
|
||||
# Example output:
|
||||
# [
|
||||
# {
|
||||
# 'pid': 1234,
|
||||
# 'name': 'python',
|
||||
# 'username': 'user',
|
||||
# 'memory_percent': 2.5,
|
||||
# 'cpu_percent': 15.3
|
||||
# },
|
||||
# ...
|
||||
# ]
|
||||
```
|
||||
|
||||
### kill_process(pid: int, force: bool = False)
|
||||
|
||||
Terminates system processes:
|
||||
- Graceful termination
|
||||
- Force kill option
|
||||
- Error handling
|
||||
- Access control
|
||||
|
||||
```python
|
||||
# Graceful termination
|
||||
result = kill_process(1234)
|
||||
|
||||
# Force kill
|
||||
result = kill_process(
|
||||
pid=1234,
|
||||
force=True # Use SIGKILL
|
||||
)
|
||||
|
||||
# Returns: Dict[str, Union[bool, str]]
|
||||
# Example output:
|
||||
# {
|
||||
# 'success': True,
|
||||
# 'message': 'Process 1234 killed successfully'
|
||||
# }
|
||||
# or
|
||||
# {
|
||||
# 'success': False,
|
||||
# 'message': 'Access denied to kill process 1234'
|
||||
# }
|
||||
```
|
||||
|
||||
### get_system_info()
|
||||
|
||||
Retrieves system information:
|
||||
- CPU statistics
|
||||
- Memory usage
|
||||
- Disk space
|
||||
- Platform details
|
||||
- Boot time
|
||||
|
||||
```python
|
||||
# Get system information
|
||||
info = get_system_info()
|
||||
|
||||
# Access specific metrics
|
||||
print(f"CPU Usage: {info['cpu']['percent']}%")
|
||||
print(f"Memory Free: {info['memory']['free']} bytes")
|
||||
|
||||
# Returns: Dict[str, Union[float, int, str, Dict]]
|
||||
# Example output:
|
||||
# {
|
||||
# 'cpu': {
|
||||
# 'percent': 45.2,
|
||||
# 'cores': 8,
|
||||
# 'physical_cores': 4
|
||||
# },
|
||||
# 'memory': {
|
||||
# 'total': 16000000000,
|
||||
# 'available': 8000000000,
|
||||
# 'percent': 50.0,
|
||||
# 'used': 8000000000,
|
||||
# 'free': 4000000000
|
||||
# },
|
||||
# 'disk': {
|
||||
# 'total': 500000000000,
|
||||
# 'used': 250000000000,
|
||||
# 'free': 250000000000,
|
||||
# 'percent': 50.0
|
||||
# },
|
||||
# 'boot_time': 1641544800,
|
||||
# 'platform': 'Darwin'
|
||||
# }
|
||||
```
|
||||
|
||||
## Example Agent Configuration
|
||||
|
||||
```python
|
||||
from praisonaiagents import Agent
|
||||
from praisonaiagents.tools import (
|
||||
execute_command, list_processes,
|
||||
kill_process, get_system_info
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
name="SystemManager",
|
||||
description="An agent that manages system processes and executes commands",
|
||||
tools=[
|
||||
execute_command, list_processes,
|
||||
kill_process, get_system_info
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The shell tools require the following package:
|
||||
- psutil: For system and process information
|
||||
|
||||
This will be automatically installed when needed.
|
||||
|
||||
## Error Handling
|
||||
|
||||
All functions include comprehensive error handling:
|
||||
- Command execution errors
|
||||
- Process access errors
|
||||
- Permission errors
|
||||
- Timeout errors
|
||||
- Resource errors
|
||||
|
||||
Errors are handled consistently:
|
||||
- Success cases return expected data type
|
||||
- Error cases return error details in result
|
||||
- All errors are logged for debugging
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. System Monitoring:
|
||||
```python
|
||||
# Monitor system resources
|
||||
info = get_system_info()
|
||||
if info['cpu']['percent'] > 90:
|
||||
print("High CPU usage detected!")
|
||||
if info['memory']['percent'] > 80:
|
||||
print("Low memory warning!")
|
||||
|
||||
# List resource-intensive processes
|
||||
processes = sorted(
|
||||
list_processes(),
|
||||
key=lambda x: x['memory_percent'],
|
||||
reverse=True
|
||||
)[:5]
|
||||
print("Top memory users:", processes)
|
||||
```
|
||||
|
||||
2. Process Management:
|
||||
```python
|
||||
# Find and kill zombie processes
|
||||
for process in list_processes():
|
||||
if process['name'] == 'zombie_process':
|
||||
result = kill_process(
|
||||
process['pid'],
|
||||
force=True
|
||||
)
|
||||
print(f"Kill result: {result['message']}")
|
||||
```
|
||||
|
||||
3. Command Execution:
|
||||
```python
|
||||
# Run a series of maintenance commands
|
||||
commands = [
|
||||
"apt-get update",
|
||||
"apt-get upgrade -y",
|
||||
"apt-get autoremove -y"
|
||||
]
|
||||
for cmd in commands:
|
||||
result = execute_command(
|
||||
cmd,
|
||||
timeout=300,
|
||||
shell=True
|
||||
)
|
||||
if result['success']:
|
||||
print(f"Command succeeded: {cmd}")
|
||||
else:
|
||||
print(f"Command failed: {result['stderr']}")
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
<AccordionGroup>
|
||||
|
||||
+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.33.tar.gz"
|
||||
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/2.0.34.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.33 gunicorn markdown\n")
|
||||
file.write("RUN pip install flask praisonai==2.0.34 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.33"
|
||||
version = "2.0.34"
|
||||
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.24",
|
||||
"praisonaiagents>=0.0.25",
|
||||
"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.33"
|
||||
version = "2.0.34"
|
||||
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.24"
|
||||
praisonaiagents = ">=0.0.25"
|
||||
python-dotenv = ">=0.19.0"
|
||||
instructor = ">=1.3.3"
|
||||
PyYAML = ">=6.0"
|
||||
|
||||
@@ -3061,7 +3061,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "praisonai"
|
||||
version = "2.0.33"
|
||||
version = "2.0.34"
|
||||
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.23" },
|
||||
{ name = "praisonaiagents", specifier = ">=0.0.25" },
|
||||
{ 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.23"
|
||||
version = "0.0.25"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "openai" },
|
||||
{ name = "pydantic" },
|
||||
{ name = "rich" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a8/87/08ff2ac7c365251fa07973fded3e68c2edc1173d8514e6fd90fc8ee7b131/praisonaiagents-0.0.23.tar.gz", hash = "sha256:1814d537b2625a5c7d4b61d07f5d5bd043f0ad8afc31fe9d4eb99a5ca54101bf", size = 25375 }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/6c/9c/07a6fd1d939eb98ae6399fb16aad870f16dba7ab5d64825af2420a46c09b/praisonaiagents-0.0.25.tar.gz", hash = "sha256:2ef1292fa5e0a5dc5d1b982670f3d0c6bb1cd9c59febbcbe6c2b8af5fa21ca43", size = 61241 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/56/75/c3a1cf2adaf0811ab538029054fa993e82caffba2853546f41766b7e0aab/praisonaiagents-0.0.23-py3-none-any.whl", hash = "sha256:d6aaa406fc993ccd0a763aa426b7139c955e1cd99e6b204b06817ebc1a5855e3", size = 31734 },
|
||||
{ url = "https://files.pythonhosted.org/packages/50/78/1ab28fe9e32f2d765052b3870532238f6c4a72a98168b73b443d76c0235f/praisonaiagents-0.0.25-py3-none-any.whl", hash = "sha256:5b0cf04f294d81dbee8be855fc7026cc190a05b1d169e286eb7e387b8f8bd7de", size = 80127 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in new issue
Block a user