Spaces:
Sleeping
Sleeping
File size: 2,434 Bytes
f2200ab 08a5a31 f2200ab 08a5a31 f2200ab 08a5a31 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 |
import os
from pathlib import Path
# Base directory
BASE_DIR = Path(__file__).parent
# API Configuration
API_TITLE = "Automated Consensus Analysis API"
API_VERSION = "1.0.0"
API_DESCRIPTION = """
## Automated Consensus Analysis for Peer Reviews
This API provides comprehensive analysis of peer review disagreements using:
- **LLM-based critique extraction** (Gemini 2.5 Flash Lite via OpenRouter)
- **Disagreement detection** between reviewers
- **Search-augmented evidence retrieval** (Semantic Scholar, arXiv, Google Scholar, Tavily)
- **AI-powered disagreement resolution** (DeepSeek-R1 via OpenRouter)
- **Meta-review generation**
### Features:
- ✅ Full pipeline or individual stage execution
- ✅ Rate limiting and queue management
- ✅ Progress tracking
- ✅ JSON and form data support
"""
# Rate Limiting
MAX_REQUESTS_PER_MINUTE = int(os.getenv("MAX_REQUESTS_PER_MINUTE", "10"))
MAX_CONCURRENT_TASKS = int(os.getenv("MAX_CONCURRENT_TASKS", "3"))
QUEUE_MAX_SIZE = int(os.getenv("QUEUE_MAX_SIZE", "20"))
# Model Configuration (all via OpenRouter)
GEMINI_MODEL = os.getenv("GEMINI_MODEL", "google/gemini-2.5-flash-lite")
DEEPSEEK_MODEL = os.getenv("DEEPSEEK_MODEL", "deepseek/deepseek-r1")
# API Keys (from HF Spaces secrets)
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
TAVILY_API_KEY = os.getenv("TAVILY_API_KEY")
SERPAPI_API_KEY = os.getenv("SERPAPI_API_KEY")
# Retry Configuration
MAX_RETRIES = int(os.getenv("MAX_RETRIES", "5"))
BASE_RETRY_WAIT = int(os.getenv("BASE_RETRY_WAIT", "2"))
# Timeout Configuration
REQUEST_TIMEOUT = int(os.getenv("REQUEST_TIMEOUT", "300")) # 5 minutes
SEARCH_TIMEOUT = int(os.getenv("SEARCH_TIMEOUT", "60")) # 1 minute
# Logging
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
def validate_environment():
"""
Validate that all required environment variables are set
Raises:
ValueError: If required variables are missing
"""
required_vars = {
"OPENROUTER_API_KEY": OPENROUTER_API_KEY,
"TAVILY_API_KEY": TAVILY_API_KEY,
}
missing = [var for var, value in required_vars.items() if not value]
if missing:
raise ValueError(
f"Missing required environment variables: {', '.join(missing)}\n"
f"Please set them in HuggingFace Spaces secrets."
)
# Validate on import
try:
validate_environment()
except ValueError as e:
print(f"⚠️ Configuration Warning: {e}")
|