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 """