AI Agents¶
We've made a number of different agents for experimentation and will continue to make more and depricate others as they're obsolte or uninteresting. You can follow the progress in the Evaluations Learnings Log and watch them on the Leader Board
Currently we have the following:
Available Agents¶
ASHAI Agent¶
Main conversational agent with intelligent search routing
The primary agent for patient interactions, featuring:
- Intelligent FAQ Routing - Automatically selects best sources based on query context
- Pregnancy Context Detection - Identifies pregnancy-related queries for specialized routing
- Medical Knowledge Search - Searches structured medical databases and research literature
- LLM-Driven Search Sufficiency - Quality-based search continuation until sufficient information found
Routing Strategy: - Pregnancy queries → Googlesheet FAQ + PubMed - General medical → September Health Library + PubMed - Treatment queries → Always include PubMed for evidence - Complex conditions → PubMed + multiple sources
Strict-Referenced Agent¶
Evidence-only agent requiring full research sourcing
A specialized wrapper around ASHAI that enforces strict evidence-based requirements:
- Research-Only Responses - Cannot use AI knowledge, everything must be sourced from research tools
- Mandatory References - All claims must include complete citations
- Conservative Approach - Refuses to answer if insufficient sources are found
- Clinical Decision Support - Ideal for healthcare professionals requiring evidence-based information
Strict-Referenced-After Agent¶
Answer-first-then-verify agent with transparent validation
Uses an answer-first-then-verify approach for transparent medical guidance:
- Two-Phase Process - Initial AI answer followed by research validation
- Self-Correction - Revises responses when research contradicts initial answer
- Educational Value - Shows validation methodology in thinking process
- Balanced Approach - Combines AI speed with research accuracy
September Agent¶
Specialized agent using only the September Health Library
A focused version of ASHAI that exclusively uses the September Health Library for medical information:
- High-Quality Content - Curated medical content from authoritative sources
- Section-Based Search - Natural medical sections (symptoms, treatment, causes, etc.)
- RAG-Based Retrieval - Semantic search over structured medical articles
- Consistent Format - Standardized medical content presentation
Perplexity Agent¶
Just uses Perplexity directly to answer these questions (no openai)
Uses Perplexity's search capabilities for current medical information:
- Real-Time Sources - Accesses current web-based medical information
- Fallback Option - Useful when specialized databases lack information
- Current Research - Can find very recent medical developments and studies
Agent Architecture¶
All agents implement a common interface for consistency:
from agents.ashai.ashai import AshaiAgent
from models import AshaiRequest, Message
# Initialize agent
agent = AshaiAgent()
# Process request
request = AshaiRequest(
messages=[Message(role='user', content='What are symptoms of diabetes?')],
profile='Adult patient, no known conditions'
)
response = agent.process_request(request)
Request/Response Models¶
AshaiRequest Structure:
{
"messages": [{"role": "user", "content": "..."}],
"profile": "Patient profile information",
"model": "gpt-4o-mini",
"with_evaluation": true,
"tools": ["optional_tool_restrictions"]
}
AshaiResponse Structure:
{
"response": "AI agent's response based on search results",
"searches": [
{
"question": "reformulated search query",
"tool": "search_system_used",
"sources": [{"title": "...", "content": "...", "url": "..."}]
}
],
"evaluation": {"score": 0.95, "reasoning": "..."} # if requested
}
Intelligent Routing¶
ASHAI agents use sophisticated routing logic to select the best knowledge sources:
graph TD
A[User Query] --> B{Pregnancy Related?}
B -->|Yes| C[Googlesheet FAQ + PubMed]
B -->|No| D{Complex Medical?}
D -->|Yes| E[PubMed + Multiple Sources]
D -->|No| F{General Medical?}
F -->|Yes| G[September Health + PubMed]
F -->|No| H[PubMed Only]
C --> I[Quality Evaluation]
E --> I
G --> I
H --> I
I --> J[Evidence-Based Response]
Performance & Monitoring¶
All agents include comprehensive monitoring:
- Request Processing Times - Track response latency
- Search Iteration Counts - Monitor search efficiency
- Source Retrieval Metrics - Success rates per knowledge source
- Quality Scores - Response quality evaluation
- Error Tracking - Graceful error handling and logging
Performance logs are available in ashai_performance.log
.
Agent Guidelines¶
When developing or using agents:
- Evidence-based responses only - No hallucination allowed
- Source transparency - Always return sources used
- Error handling - Graceful degradation when sources fail
- Performance logging - Track timing and quality metrics
- Cultural sensitivity - Consider patient demographics and context
API Integration¶
Agents are automatically integrated with the main FastAPI server:
Endpoint | Agent | Description |
---|---|---|
/agent/ashai |
ASHAI Agent | Main conversational agent |
/september |
September Agent | September Health Library only |
API Documentation¶
For detailed API documentation, see:
- Live API Docs (Swagger UI) - Complete endpoint documentation
CORS Support¶
If you are integrating from a web client, use fetch requests with mode: 'cors'
and Content-Type: application/json
. No custom headers are required in most cases.
- Default allowed origins include
https://whatsapp.turn.io
,https://ashai.hackathon.noorahealth.org
, andhttp://localhost:8000
. - You can override the list with the
ALLOWED_CORS_ORIGINS
environment variable (comma-separated). Seeutils/cors.py
.
Search Systems Used¶
Agents leverage multiple search systems:
- See Voice Interfaces for voice interaction options
Evaluation Framework¶
Quality assessment is provided by:
- See Evaluation for scoring and methodology