Add OpenRouter app attribution headers to skills_guard and trajectory_compressor
These two files were creating bare OpenAI clients pointing at OpenRouter without the HTTP-Referer / X-OpenRouter-Title / X-OpenRouter-Categories headers that the rest of the codebase sends for app attribution. - skills_guard.py: LLM audit client (always OpenRouter) - trajectory_compressor.py: sync + async summarization clients (guarded with 'openrouter' in base_url check since the endpoint is user-configurable)
This commit is contained in:
parent
cd77c7100c
commit
4d53b7ccaa
2 changed files with 18 additions and 2 deletions
|
|
@ -946,6 +946,11 @@ def llm_audit_skill(skill_path: Path, static_result: ScanResult,
|
||||||
client = OpenAI(
|
client = OpenAI(
|
||||||
base_url=OPENROUTER_BASE_URL,
|
base_url=OPENROUTER_BASE_URL,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
|
default_headers={
|
||||||
|
"HTTP-Referer": "https://github.com/NousResearch/hermes-agent",
|
||||||
|
"X-OpenRouter-Title": "Hermes Agent",
|
||||||
|
"X-OpenRouter-Categories": "productivity,cli-agent",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model=model,
|
model=model,
|
||||||
|
|
|
||||||
|
|
@ -351,16 +351,27 @@ class TrajectoryCompressor:
|
||||||
|
|
||||||
from openai import OpenAI, AsyncOpenAI
|
from openai import OpenAI, AsyncOpenAI
|
||||||
|
|
||||||
|
# OpenRouter app attribution headers (only for OpenRouter endpoints)
|
||||||
|
extra = {}
|
||||||
|
if "openrouter" in self.config.base_url.lower():
|
||||||
|
extra["default_headers"] = {
|
||||||
|
"HTTP-Referer": "https://github.com/NousResearch/hermes-agent",
|
||||||
|
"X-OpenRouter-Title": "Hermes Agent",
|
||||||
|
"X-OpenRouter-Categories": "productivity,cli-agent",
|
||||||
|
}
|
||||||
|
|
||||||
# Sync client (for backwards compatibility)
|
# Sync client (for backwards compatibility)
|
||||||
self.client = OpenAI(
|
self.client = OpenAI(
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
base_url=self.config.base_url
|
base_url=self.config.base_url,
|
||||||
|
**extra,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Async client for parallel processing
|
# Async client for parallel processing
|
||||||
self.async_client = AsyncOpenAI(
|
self.async_client = AsyncOpenAI(
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
base_url=self.config.base_url
|
base_url=self.config.base_url,
|
||||||
|
**extra,
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"✅ Initialized OpenRouter client: {self.config.summarization_model}")
|
print(f"✅ Initialized OpenRouter client: {self.config.summarization_model}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue