Spaces:
Sleeping
Sleeping
File size: 6,605 Bytes
34a0b9c 64acd41 34a0b9c f2200ab |
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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
---
title: MetaSearch API
emoji: π¬
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "5.9.1"
app_file: app.py
pinned: false
license: mit
---
# π¬ Automated Consensus Analysis API
A comprehensive HuggingFace Spaces API for automated peer review consensus analysis using LLMs and search-augmented verification.
## π Features
- **Critique Extraction**: Extract structured critique points from peer reviews using Gemini 2.0
- **Disagreement Detection**: Identify conflicts and disagreements between reviewers
- **Search-Augmented Verification**: Retrieve supporting/contradicting evidence from academic sources
- **Disagreement Resolution**: AI-powered resolution using DeepSeek-R1 with reasoning
- **Meta-Review Generation**: Comprehensive meta-reviews synthesizing all analyses
- **Rate Limiting**: 10 requests per minute per client
- **Queue Management**: Up to 3 concurrent pipeline executions
- **Progress Tracking**: Real-time status updates for long-running tasks
## π Quick Start
### Local Development
1. **Clone and setup**
```bash
cd api
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
```
2. **Configure environment**
```bash
cp .env.example .env
# Edit .env with your API keys
```
3. **Run the application**
```bash
python app.py
```
Visit `http://localhost:7860` to access the Gradio interface.
### HuggingFace Spaces Deployment
1. **Create a new Space**
- Go to [HuggingFace Spaces](https://huggingface.co/spaces)
- Click "Create new Space"
- Select "Gradio" as SDK
2. **Upload files**
- Upload all files from the `api/` directory
- Ensure `requirements.txt` and `app.py` are in the root
3. **Configure secrets**
- Go to Space Settings β Repository secrets
- Add the following secrets:
- `GEMINI_API_KEY`
- `OPENROUTER_API_KEY`
- `TAVILY_API_KEY`
- `SERPAPI_API_KEY`
4. **Deploy**
- The Space will automatically build and deploy
## π API Endpoints
### Full Pipeline
**Endpoint**: `/api/full_pipeline`
**Method**: POST
**Description**: Run the complete consensus analysis pipeline
**Request Body**:
```json
{
"paper_title": "Visual Correspondence Hallucination",
"paper_abstract": "This paper investigates...",
"reviews": [
"Review 1: The methodology is sound but...",
"Review 2: While the experiments are comprehensive..."
]
}
```
**Response**:
```json
{
"request_id": "req_123456789",
"paper_title": "...",
"critique_points": [...],
"disagreements": [...],
"search_results": {...},
"resolution": [...],
"meta_review": "..."
}
```
### Individual Stages
#### Critique Extraction
**Endpoint**: `/api/critique_extraction`
**Method**: POST
```json
{
"reviews": ["Review 1 text...", "Review 2 text..."]
}
```
#### Disagreement Detection
**Endpoint**: `/api/disagreement_detection`
**Method**: POST
```json
{
"critiques": [
{"Methodology": [...], "Experiments": [...]},
{"Methodology": [...], "Experiments": [...]}
]
}
```
#### Search & Retrieval
**Endpoint**: `/api/search_retrieval`
**Method**: POST
```json
{
"paper_title": "...",
"paper_abstract": "...",
"critiques": [...]
}
```
#### Progress Tracking
**Endpoint**: `/api/progress/{request_id}`
**Method**: GET
**Response**:
```json
{
"stage": "search_retrieval",
"progress": 0.5,
"message": "Searching for relevant research...",
"timestamp": "2025-01-15T10:30:00"
}
```
## π§ Configuration
### Environment Variables
| Variable | Description | Default |
| ------------------------- | ------------------------------ | -------- |
| `GEMINI_API_KEY` | Google Gemini API key | Required |
| `OPENROUTER_API_KEY` | OpenRouter API key (DeepSeek) | Required |
| `TAVILY_API_KEY` | Tavily Search API key | Required |
| `SERPAPI_API_KEY` | SerpAPI key for Google Scholar | Optional |
| `MAX_REQUESTS_PER_MINUTE` | Rate limit | 10 |
| `MAX_CONCURRENT_TASKS` | Max parallel executions | 3 |
| `MAX_RETRIES` | Retry attempts on failure | 5 |
### Rate Limits
- **10 requests per minute** per client IP
- **Maximum 3 concurrent** pipeline executions
- **Queue size**: 20 pending requests
## ποΈ Architecture
```
api/
βββ app.py # Main Gradio application
βββ config.py # Configuration management
βββ requirements.txt # Python dependencies
βββ pipeline/ # Pipeline modules
β βββ critique_extraction.py # Gemini-based extraction
β βββ disagreement_detection.py
β βββ search_retrieval.py # LangChain search agent
β βββ disagreement_resolution.py # DeepSeek resolution
β βββ meta_review.py
βββ utils/ # Utility modules
βββ rate_limiter.py
βββ queue_manager.py
βββ validators.py
```
## π Pipeline Stages
1. **Critique Extraction** (Gemini 2.0)
- Extracts structured critique points
- Categories: Methodology, Experiments, Clarity, Significance, Novelty
2. **Disagreement Detection** (Gemini 2.0)
- Compares all review pairs
- Assigns disagreement scores (0-1)
- Identifies specific conflict points
3. **Search & Retrieval** (LangChain + Multi-Search)
- SoTA research discovery
- Evidence validation
- Sources: Semantic Scholar, arXiv, Google Scholar, Tavily
4. **Disagreement Resolution** (DeepSeek-R1)
- Validates critique points
- Accepts/rejects based on evidence
- Provides resolution summaries
5. **Meta-Review Generation** (DeepSeek-R1)
- Synthesizes all analyses
- Provides final verdict
- Offers actionable recommendations
## π Example Usage
### Python
```python
import requests
response = requests.post(
"https://your-space.hf.space/api/full_pipeline",
json={
"paper_title": "Novel Approach to X",
"paper_abstract": "We propose...",
"reviews": [
"Reviewer 1: Strong methodology...",
"Reviewer 2: Weak experimental validation..."
]
}
)
result = response.json()
print(result["meta_review"])
```
### cURL
```bash
curl -X POST https://your-space.hf.space/api/full_pipeline \
-H "Content-Type: application/json" \
-d '{
"paper_title": "Novel Approach to X",
"paper_abstract": "We propose...",
"reviews": ["Review 1...", "Review 2..."]
}'
```
## π License
See the main project LICENSE file.
|