Skip to main content
Multi-agent workflow: web search → gap analysis → experiment design → validation → impact prediction. Includes SQLite persistence, vector retrieval, observability, and API deployment.

Setup

# Create environment
python3 -m venv venv && source venv/bin/activate

# Install packages
pip install praisonaiagents praisonai

# Set API keys
export OPENAI_API_KEY="your-key"
export TAVILY_API_KEY="your-key"  # For web search

Run: Python Code

from praisonaiagents import Agent, Agents, Task, tool
import json

# Database persistence is configured via memory={} parameter

# Web search tool
@tool
def search_papers(query: str) -> str:
    """Search for research papers on a topic."""
    from tavily import TavilyClient
    import os
    client = TavilyClient(api_key=os.getenv("TAVILY_API_KEY"))
    results = client.search(query, max_results=5)
    return json.dumps([{"title": r["title"], "url": r["url"], "content": r["content"][:200]} for r in results["results"]])

# Agents
researcher = Agent(
    name="Researcher",
    instructions="Search and analyze research papers on the given topic.",
    tools=[search_papers],
    memory={
        "db": "sqlite:///research.db",
        "session_id": "research-session"
    }
)

analyst = Agent(
    name="GapAnalyst", 
    instructions="Identify knowledge gaps from research findings."
)

designer = Agent(
    name="ExperimentDesigner",
    instructions="Design experiments to address identified gaps."
)

# Tasks
search_task = Task(
    description="Search for recent papers on: {topic}",
    agent=researcher,
    expected_output="List of relevant papers with summaries"
)

gap_task = Task(
    description="Analyze papers and identify 3 key research gaps",
    agent=analyst,
    expected_output="JSON with gaps: [{area, significance, potential}]"
)

design_task = Task(
    description="Design experiment for the highest-priority gap",
    agent=designer,
    expected_output="Experiment plan with methodology, resources, timeline"
)

# Run workflow
agents = Agents(agents=[researcher, analyst, designer], tasks=[search_task, gap_task, design_task])
result = agents.start(topic="quantum error correction")
print(result)

Run: CLI

# Single prompt
praisonai "Research quantum error correction and identify gaps" --tools --web-search

# With persistence
praisonai "Research AI safety" --memory --user-id researcher1

# With telemetry
praisonai "Research climate models" --telemetry --verbose

Run: agents.yaml

Create agents.yaml:
framework: praisonai
topic: "quantum error correction research"
roles:
  researcher:
    role: Research Analyst
    goal: Find and analyze recent research papers
    backstory: Expert at literature review and synthesis
    tools:
      - tavily_search
    tasks:
      search_papers:
        description: Search for papers on {topic}
        expected_output: List of 5 relevant papers with summaries
        
  analyst:
    role: Gap Analyst
    goal: Identify research gaps
    backstory: Expert at finding unexplored research areas
    tasks:
      find_gaps:
        description: Identify 3 key gaps from the research
        expected_output: JSON array of gaps with significance scores
        
  designer:
    role: Experiment Designer
    goal: Design experiments
    backstory: Expert at experimental methodology
    tasks:
      design_experiment:
        description: Design experiment for highest priority gap
        expected_output: Detailed experiment plan
Run:
praisonai agents.yaml --verbose

Monitor & Verify

# View session history
praisonai --history 10 --user-id researcher1

# Check telemetry
praisonai --metrics

# Export results
praisonai --save research_results

Serve API

# Start API server
praisonai --serve --port 8000
Test endpoint:
curl -X POST http://localhost:8000/api/v1/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Research quantum computing advances", "session_id": "api-session"}'
Or use Python SDK to serve:
from praisonaiagents import Agent

agent = Agent(
    name="ResearchAPI",
    instructions="Research assistant for scientific topics"
)
agent.launch(path="/research", port=8000)
curl -X POST http://localhost:8000/research \
  -H "Content-Type: application/json" \
  -d '{"message": "What are the latest advances in fusion energy?"}'

Cleanup

rm -f research.db
deactivate

Features Demonstrated

FeatureImplementation
Multi-agent3 agents in sequential workflow
Web SearchTavily integration via @tool
DB PersistenceSQLite via db()
Session Resumesession_id parameter
CLIpraisonai with flags
YAML Configagents.yaml format
API Endpointagent.launch()
Telemetry--telemetry flag