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
Merge branch 'main' into pr-854
Re-binafa051324390
diff --cc nanobot/providers/litellm_provider.pyindex 950a1383c,3fec618b0..08c2f532c--- a/nanobot/providers/litellm_provider.py+++ b/nanobot/providers/litellm_provider.py@@@ -88,46 -88,22 +88,57 @@@ class LiteLLMProvider(LLMProvider)# Standard mode: auto-prefix for known providersspec = find_by_model(model)if spec and spec.litellm_prefix:+ model = self._canonicalize_explicit_prefix(model, spec.name, spec.litellm_prefix)if not any(model.startswith(s) for s in spec.skip_prefixes):model = f"{spec.litellm_prefix}/{model}"-+return model++ @staticmethod+ def _canonicalize_explicit_prefix(model: str, spec_name: str, canonical_prefix: str) -> str:+ """Normalize explicit provider prefixes like `github-copilot/...`."""+ if "/" not in model:+ return model+ prefix, remainder = model.split("/", 1)+ if prefix.lower().replace("-", "_") != spec_name:+ return model+ return f"{canonical_prefix}/{remainder}"+ def _supports_cache_control(self, model: str) -> bool:+ """Return True when the provider supports cache_control on content blocks."""+ if self._gateway is not None:+ return False+ spec = find_by_model(model)+ return spec is not None and spec.supports_prompt_caching++ def _apply_cache_control(+ self,+ messages: list[dict[str, Any]],+ tools: list[dict[str, Any]] | None,+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]] | None]:+ """Return copies of messages and tools with cache_control injected."""+ # Transform the system message+ new_messages = []+ for msg in messages:+ if msg.get("role") == "system":+ content = msg["content"]+ if isinstance(content, str):+ new_content = [{"type": "text", "text": content, "cache_control": {"type": "ephemeral"}}]+ else:+ new_content = list(content)+ new_content[-1] = {**new_content[-1], "cache_control": {"type": "ephemeral"}}+ new_messages.append({**msg, "content": new_content})+ else:+ new_messages.append(msg)++ # Add cache_control to the last tool definition+ new_tools = tools+ if tools:+ new_tools = list(tools)+ new_tools[-1] = {**new_tools[-1], "cache_control": {"type": "ephemeral"}}++ return new_messages, new_tools+def _apply_model_overrides(self, model: str, kwargs: dict[str, Any]) -> None:"""Apply model-specific parameter overrides from the registry."""model_lower = model.lower()