File size: 3,373 Bytes
dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 dd27c49 578d730 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | PRAISONAI_DOCS = """
# PraisonAI Agent Framework — Full Documentation
## What is PraisonAI?
PraisonAI is a multi-agent orchestration framework. You (the orchestrator) can create specialized
sub-agents, each with custom tools written in Python, to complete complex tasks collaboratively.
---
## Creating an Agent
```python
from praisonaiagents import Agent, Task, PraisonAIAgents
agent = Agent(
name="ResearchAgent",
role="Research Specialist",
goal="Find and summarize info",
backstory="Expert researcher",
llm="LongCat-Flash-Lite",
tools=[my_tool_fn],
verbose=True,
)
```
---
## Creating a Task
```python
task = Task(
name="research_task",
description="Research the latest developments in quantum computing",
expected_output="A detailed summary with key findings",
agent=agent,
context=[previous_task],
)
```
---
## Creating Custom Tools
Tools are plain Python functions. Use inline comments (# not triple quotes) inside tools.
Example tools:
```python
def search_web(query: str) -> str:
# Search the internet for information.
import requests
return results
def execute_python(code: str) -> str:
# Execute Python code and return output.
import subprocess
result = subprocess.run(['python3', '-c', code], capture_output=True, text=True)
return result.stdout + result.stderr
def calculate(expression: str) -> str:
# Evaluate a mathematical expression.
return str(eval(expression))
def read_file(filepath: str) -> str:
# Read content from a file.
with open(filepath) as f:
return f.read()
```
---
## Running Multiple Agents (Sequential)
```python
system = PraisonAIAgents(
agents=[researcher, analyst, writer],
tasks=[research_task, analysis_task, write_task],
process="sequential",
verbose=True
)
result = system.start()
```
---
## Running Multiple Agents (Hierarchical)
```python
system = PraisonAIAgents(
agents=[manager_agent, worker1, worker2],
tasks=[main_task, sub_task1, sub_task2],
process="hierarchical",
manager_llm="LongCat-Flash-Lite",
verbose=True
)
result = system.start()
```
---
## Task Context (Chaining)
```python
task1 = Task(name="t1", description="...", agent=agent1, expected_output="...")
task2 = Task(name="t2", description="...", agent=agent2, expected_output="...", context=[task1])
```
---
## Best Practices for Dynamic Tool Creation
1. Use snake_case names (e.g., fetch_github_repo, parse_csv_data)
2. Always include type hints on parameters and return value
3. Use inline # comments, NOT triple-quoted docstrings inside tool code
4. Wrap risky operations in try/except
5. Always return strings
---
## Sub-Agent Design Patterns
Pattern 1 - Research + Synthesis:
Agent 1 (Researcher): Gathers raw information
Agent 2 (Analyst): Processes and analyzes data
Agent 3 (Writer): Produces final output
Pattern 2 - Divide and Conquer:
Split large tasks, each agent handles one domain, orchestrator merges results
Pattern 3 - Validation Pipeline:
Agent 1: Main task, Agent 2: Validates, Agent 3: Applies corrections
---
## LongCat-Flash-Lite Configuration
- Model ID: LongCat-Flash-Lite
- Max tokens: 327,680 (320K context)
- Speed: Very fast (~500-700 tokens/sec)
- Free quota: 50M tokens/day
- API Base: https://api.longcat.chat/openai/v1
- Compatible with OpenAI SDK format
""" |