File size: 4,963 Bytes
026ee5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Features

DeepCritical provides a comprehensive set of features for AI-assisted research:

## Core Features

### Multi-Source Search

- **PubMed**: Search peer-reviewed biomedical literature via NCBI E-utilities
- **ClinicalTrials.gov**: Search interventional clinical trials
- **Europe PMC**: Search preprints and peer-reviewed articles (includes bioRxiv/medRxiv)
- **RAG**: Semantic search within collected evidence using LlamaIndex

### MCP Integration

- **Model Context Protocol**: Expose search tools via MCP server
- **Claude Desktop**: Use DeepCritical tools directly from Claude Desktop
- **MCP Clients**: Compatible with any MCP-compatible client

### Authentication

- **HuggingFace OAuth**: Sign in with HuggingFace account for automatic API token usage
- **Manual API Keys**: Support for OpenAI, Anthropic, and HuggingFace API keys
- **Free Tier Support**: Automatic fallback to HuggingFace Inference API

### Secure Code Execution

- **Modal Sandbox**: Secure execution of AI-generated statistical code
- **Isolated Environment**: Network isolation and package version pinning
- **Safe Execution**: Prevents malicious code execution

### Semantic Search & RAG

- **LlamaIndex Integration**: Advanced RAG capabilities
- **Vector Storage**: ChromaDB for embedding storage
- **Semantic Deduplication**: Automatic detection of similar evidence
- **Embedding Service**: Local sentence-transformers (no API key required)

### Orchestration Patterns

- **Graph-Based Execution**: Flexible graph orchestration with conditional routing
- **Parallel Research Loops**: Run multiple research tasks concurrently
- **Iterative Research**: Single-loop research with search-judge-synthesize cycles
- **Deep Research**: Multi-section parallel research with planning and synthesis
- **Magentic Orchestration**: Multi-agent coordination using Microsoft Agent Framework

### Real-Time Streaming

- **Event Streaming**: Real-time updates via `AsyncGenerator[AgentEvent]`
- **Progress Tracking**: Monitor research progress with detailed event metadata
- **UI Integration**: Seamless integration with Gradio chat interface

### Budget Management

- **Token Budget**: Track and limit LLM token usage
- **Time Budget**: Enforce time limits per research loop
- **Iteration Budget**: Limit maximum iterations
- **Per-Loop Budgets**: Independent budgets for parallel research loops

### State Management

- **Thread-Safe Isolation**: ContextVar-based state management
- **Evidence Deduplication**: Automatic URL-based deduplication
- **Conversation History**: Track iteration history and agent interactions
- **State Synchronization**: Share evidence across parallel loops

## Advanced Features

### Agent System

- **Pydantic AI Agents**: Type-safe agent implementation
- **Structured Output**: Pydantic models for agent responses
- **Agent Factory**: Centralized agent creation with fallback support
- **Specialized Agents**: Knowledge gap, tool selector, writer, proofreader, and more

### Search Tools

- **Rate Limiting**: Built-in rate limiting for external APIs
- **Retry Logic**: Automatic retry with exponential backoff
- **Query Preprocessing**: Automatic query enhancement and synonym expansion
- **Evidence Conversion**: Automatic conversion to structured Evidence objects

### Error Handling

- **Custom Exceptions**: Hierarchical exception system
- **Error Chaining**: Preserve exception context
- **Structured Logging**: Comprehensive logging with structlog
- **Graceful Degradation**: Fallback handlers for missing dependencies

### Configuration

- **Pydantic Settings**: Type-safe configuration management
- **Environment Variables**: Support for `.env` files
- **Validation**: Automatic configuration validation
- **Flexible Providers**: Support for multiple LLM and embedding providers

### Testing

- **Unit Tests**: Comprehensive unit test coverage
- **Integration Tests**: Real API integration tests
- **Mock Support**: Extensive mocking utilities
- **Coverage Reports**: Code coverage tracking

## UI Features

### Gradio Interface

- **Real-Time Chat**: Interactive chat interface
- **Streaming Updates**: Live progress updates
- **Accordion UI**: Organized display of pending/done operations
- **OAuth Integration**: Seamless HuggingFace authentication

### MCP Server

- **RESTful API**: HTTP-based MCP server
- **Tool Discovery**: Automatic tool registration
- **Request Handling**: Async request processing
- **Error Responses**: Structured error responses

## Development Features

### Code Quality

- **Type Safety**: Full type hints with mypy strict mode
- **Linting**: Ruff for code quality
- **Formatting**: Automatic code formatting
- **Pre-commit Hooks**: Automated quality checks

### Documentation

- **Comprehensive Docs**: Detailed documentation for all components
- **Code Examples**: Extensive code examples
- **Architecture Diagrams**: Visual architecture documentation
- **API Reference**: Complete API documentation