NLPGenius's picture
Initial API app, Dockerfile, and requirements for Space deployment
89fd50e
raw
history blame
980 Bytes
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional, Dict
import os
@dataclass
class OpenRouterConfig:
api_key: Optional[str]
model: str = "deepseek/deepseek-r1-0528"
base_url: str = "https://openrouter.ai/api/v1"
temperature: float = 0.2
max_tokens: int = 800
headers: Optional[Dict[str, str]] = None
def load_openrouter_config(api_key: Optional[str] = None) -> OpenRouterConfig:
key = api_key or os.getenv("OPENROUTER_API_KEY") or os.getenv("OPENAI_API_KEY")
model = os.getenv("FACTCHECK_MODEL") or "deepseek/deepseek-r1-0528"
try:
max_tokens = int(os.getenv("FACTCHECK_MAX_TOKENS", "800"))
except ValueError:
max_tokens = 800
headers = {
"HTTP-Referer": os.getenv("APP_DOMAIN", "http://localhost"),
"X-Title": os.getenv("APP_TITLE", "CVE Fact Checker"),
}
return OpenRouterConfig(api_key=key, headers=headers, model=model, max_tokens=max_tokens)