π OpenHands: AI-Driven Development
[llm] Add app name for OpenRouter (#4010)
Xingyao Wang8ea2d61ff22c
diff --git a/openhands/core/config/llm_config.py b/openhands/core/config/llm_config.pyindex af766045ea..cf60184251 100644--- a/openhands/core/config/llm_config.py+++ b/openhands/core/config/llm_config.py@@ -50,6 +50,8 @@ class LLMConfig:aws_access_key_id: str | None = Noneaws_secret_access_key: str | None = Noneaws_region_name: str | None = None+ openrouter_site_url: str = 'https://docs.all-hands.dev/'+ openrouter_app_name: str = 'OpenHands'num_retries: int = 8retry_multiplier: float = 2retry_min_wait: int = 15diff --git a/openhands/llm/llm.py b/openhands/llm/llm.pyindex 9e4c00399f..022ec0f6dd 100644--- a/openhands/llm/llm.py+++ b/openhands/llm/llm.py@@ -1,5 +1,6 @@import asyncioimport copy+import osimport timeimport warningsfrom functools import partial@@ -75,6 +76,9 @@ class LLM:self.cost_metric_supported = Trueself.config = copy.deepcopy(config)+ os.environ['OR_SITE_URL'] = self.config.openrouter_site_url+ os.environ['OR_APP_NAME'] = self.config.openrouter_app_name+# list of LLM completions (for logging purposes). Each completion is a dict with the following keys:# - 'messages': list of messages# - 'response': response from the LLM