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:
@@ -23,6 +23,8 @@ class AnthropicAdapter(LLMAdapter):
|
||||
|
||||
models:
|
||||
provider: anthropic
|
||||
default_max_tokens: 4096 # fallback max_tokens for all calls
|
||||
default_temperature: 0 # fallback temperature for all calls
|
||||
capability_map:
|
||||
reasoning-heavy:
|
||||
anthropic: claude-opus-4-6
|
||||
@@ -31,6 +33,9 @@ class AnthropicAdapter(LLMAdapter):
|
||||
fast-cheap:
|
||||
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
|
||||
---------------------
|
||||
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._models_cfg: dict = config.get("models", {})
|
||||
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:
|
||||
"""
|
||||
@@ -68,10 +74,10 @@ class AnthropicAdapter(LLMAdapter):
|
||||
----------
|
||||
prompt : User-role prompt content.
|
||||
capability : One of "reasoning-heavy" | "capable" | "fast-cheap".
|
||||
context : Optional overrides:
|
||||
context : Optional per-call overrides:
|
||||
system_prompt (str) — prepended as the system turn.
|
||||
max_tokens (int) — defaults to 4096.
|
||||
temperature (float) — defaults to 0.
|
||||
max_tokens (int) — defaults to models.default_max_tokens in team.yaml.
|
||||
temperature (float) — defaults to models.default_temperature in team.yaml.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -79,7 +85,7 @@ class AnthropicAdapter(LLMAdapter):
|
||||
"""
|
||||
model = self.resolve_model(capability)
|
||||
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", "")
|
||||
|
||||
create_kwargs: dict = {
|
||||
@@ -89,7 +95,7 @@ class AnthropicAdapter(LLMAdapter):
|
||||
}
|
||||
if system_prompt:
|
||||
create_kwargs["system"] = system_prompt
|
||||
if temperature != 0:
|
||||
if temperature != 0.0:
|
||||
create_kwargs["temperature"] = temperature
|
||||
|
||||
response = self._client.messages.create(**create_kwargs)
|
||||
|
||||
Reference in New Issue
Block a user