Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: langsmith callback 防覆盖 + 加 optional dep
Xubin Ren20b4fb3bff7a
diff --git a/nanobot/providers/litellm_provider.py b/nanobot/providers/litellm_provider.pyindex a9a051785..ebc8c9b91 100644--- a/nanobot/providers/litellm_provider.py+++ b/nanobot/providers/litellm_provider.py@@ -62,6 +62,8 @@ class LiteLLMProvider(LLMProvider):# Drop unsupported parameters for providers (e.g., gpt-5 rejects some params)litellm.drop_params = True+ self._langsmith_enabled = bool(os.getenv("LANGSMITH_API_KEY"))+def _setup_env(self, api_key: str, api_base: str | None, model: str) -> None:"""Set environment variables based on detected provider."""spec = self._gateway or find_by_model(model)@@ -250,10 +252,9 @@ class LiteLLMProvider(LLMProvider):# Apply model-specific overrides (e.g. kimi-k2.5 temperature)self._apply_model_overrides(model, kwargs)- # Use langsmith to view the conversation- if os.getenv("LANGSMITH_API_KEY"):- kwargs["callbacks"] = ["langsmith"]-+ if self._langsmith_enabled:+ kwargs.setdefault("callbacks", []).append("langsmith")+# Pass api_key directly — more reliable than env vars aloneif self.api_key:kwargs["api_key"] = self.api_keydiff --git a/pyproject.toml b/pyproject.tomlindex 5eb77c3e2..dce9e26fd 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -56,6 +56,9 @@ matrix = ["mistune>=3.0.0,<4.0.0","nh3>=0.2.17,<1.0.0",]+langsmith = [+ "langsmith>=0.1.0",+]dev = ["pytest>=9.0.0,<10.0.0","pytest-asyncio>=1.3.0,<2.0.0",