fix: read default_temperature from team.yaml; update docstrings

- Add default_temperature: 0 to config/team.yaml models block
- Read self._default_temperature from models cfg in __init__
- Use self._default_temperature as fallback in complete() instead of hardcoded 0
- Update class docstring to document both default_max_tokens and default_temperature
- Update complete() context param docs to reference team.yaml keys
This commit is contained in:
2026-03-15 21:40:05 -04:00
parent 6856f10c27
commit 8524b63a76
2 changed files with 12 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ class AnthropicAdapter(LLMAdapter):
models: models:
provider: anthropic provider: anthropic
default_max_tokens: 4096 # fallback max_tokens for all calls
default_temperature: 0 # fallback temperature for all calls
capability_map: capability_map:
reasoning-heavy: reasoning-heavy:
anthropic: claude-opus-4-6 anthropic: claude-opus-4-6
@@ -31,6 +33,9 @@ class AnthropicAdapter(LLMAdapter):
fast-cheap: fast-cheap:
anthropic: claude-haiku-3-5 anthropic: claude-haiku-3-5
Both ``default_max_tokens`` and ``default_temperature`` can be overridden
per-call via the ``context`` dict passed to :meth:`complete`.
Environment variables Environment variables
--------------------- ---------------------
ANTHROPIC_API_KEY : Required. Authenticates with the Anthropic API. ANTHROPIC_API_KEY : Required. Authenticates with the Anthropic API.
@@ -59,6 +64,7 @@ class AnthropicAdapter(LLMAdapter):
self._client = anthropic.Anthropic(api_key=api_key) self._client = anthropic.Anthropic(api_key=api_key)
self._models_cfg: dict = config.get("models", {}) self._models_cfg: dict = config.get("models", {})
self._default_max_tokens: int = self._models_cfg.get("default_max_tokens", 4096) self._default_max_tokens: int = self._models_cfg.get("default_max_tokens", 4096)
self._default_temperature: float = self._models_cfg.get("default_temperature", 0)
def complete(self, prompt: str, capability: str, context: dict) -> str: def complete(self, prompt: str, capability: str, context: dict) -> str:
""" """
@@ -68,10 +74,10 @@ class AnthropicAdapter(LLMAdapter):
---------- ----------
prompt : User-role prompt content. prompt : User-role prompt content.
capability : One of "reasoning-heavy" | "capable" | "fast-cheap". capability : One of "reasoning-heavy" | "capable" | "fast-cheap".
context : Optional overrides: context : Optional per-call overrides:
system_prompt (str) — prepended as the system turn. system_prompt (str) — prepended as the system turn.
max_tokens (int) — defaults to 4096. max_tokens (int) — defaults to models.default_max_tokens in team.yaml.
temperature (float) — defaults to 0. temperature (float) — defaults to models.default_temperature in team.yaml.
Returns Returns
------- -------
@@ -79,7 +85,7 @@ class AnthropicAdapter(LLMAdapter):
""" """
model = self.resolve_model(capability) model = self.resolve_model(capability)
max_tokens: int = context.get("max_tokens", self._default_max_tokens) max_tokens: int = context.get("max_tokens", self._default_max_tokens)
temperature: float = context.get("temperature", 0) temperature: float = context.get("temperature", self._default_temperature)
system_prompt: str = context.get("system_prompt", "") system_prompt: str = context.get("system_prompt", "")
create_kwargs: dict = { create_kwargs: dict = {
@@ -89,7 +95,7 @@ class AnthropicAdapter(LLMAdapter):
} }
if system_prompt: if system_prompt:
create_kwargs["system"] = system_prompt create_kwargs["system"] = system_prompt
if temperature != 0: if temperature != 0.0:
create_kwargs["temperature"] = temperature create_kwargs["temperature"] = temperature
response = self._client.messages.create(**create_kwargs) response = self._client.messages.create(**create_kwargs)

View File

@@ -12,6 +12,7 @@ adapters:
models: models:
provider: anthropic provider: anthropic
default_max_tokens: 4096 default_max_tokens: 4096
default_temperature: 0
capability_map: capability_map:
reasoning-heavy: reasoning-heavy:
anthropic: claude-opus-4-6 anthropic: claude-opus-4-6