Reapply "add app headers for openrouter"

This reverts commit 56ccd938f7.
This commit is contained in:
AI Christianson 2025-02-19 19:33:34 -05:00
parent 56ccd938f7
commit f9c83d496c
1 changed files with 7 additions and 0 deletions

View File

@ -122,6 +122,11 @@ def create_openrouter_client(
is_expert: bool = False,
) -> BaseChatModel:
"""Create OpenRouter client with appropriate configuration."""
default_headers = {
"HTTP-Referer": "https://ra-aid.ai",
"X-Title": "RA.Aid"
}
if model_name.startswith("deepseek/") and "deepseek-r1" in model_name.lower():
return ChatDeepseekReasoner(
api_key=api_key,
@ -132,6 +137,7 @@ def create_openrouter_client(
model=model_name,
timeout=LLM_REQUEST_TIMEOUT,
max_retries=LLM_MAX_RETRIES,
default_headers=default_headers,
)
return ChatOpenAI(
@ -140,6 +146,7 @@ def create_openrouter_client(
model=model_name,
timeout=LLM_REQUEST_TIMEOUT,
max_retries=LLM_MAX_RETRIES,
default_headers=default_headers,
**({"temperature": temperature} if temperature is not None else {}),
)