fix(notion-search): pin SDK model to dated ID + drop unused type alias
Code review caught that the bare alias 'claude-haiku-4-5' works in the Claude Code CLI but may not resolve in the Anthropic SDK. Pin the default to 'claude-haiku-4-5-20251001' (the full dated ID) via a DEFAULT_MODEL constant so the SDK path doesn't silently break the first time it hits the real API. Also document the max_tokens-ignored behavior on the CLI path in the public call_claude docstring (not just the private _call_via_cli), and drop the unused LLMCaller type alias (dead code). 3/3 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,9 +5,10 @@ from __future__ import annotations
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Callable
|
||||
|
||||
LLMCaller = Callable[..., str] # (prompt, *, model, max_tokens) -> response text
|
||||
# Anthropic SDK requires fully-qualified dated model IDs (the bare alias
|
||||
# `claude-haiku-4-5` works in Claude Code CLI but may not resolve via SDK).
|
||||
DEFAULT_MODEL = "claude-haiku-4-5-20251001"
|
||||
|
||||
|
||||
def _have_anthropic_sdk() -> bool:
|
||||
@@ -48,13 +49,16 @@ def _call_via_cli(prompt: str, model: str, max_tokens: int) -> str:
|
||||
def call_claude(
|
||||
prompt: str,
|
||||
*,
|
||||
model: str = "claude-haiku-4-5",
|
||||
model: str = DEFAULT_MODEL,
|
||||
max_tokens: int = 1000,
|
||||
) -> str:
|
||||
"""Send a prompt to Claude.
|
||||
|
||||
Tries the anthropic SDK first (requires ANTHROPIC_API_KEY), falls back to
|
||||
the `claude -p` CLI if available. Raises RuntimeError if neither works.
|
||||
|
||||
Note: ``max_tokens`` is honored by the SDK path but ignored by the CLI
|
||||
path (the CLI sets its own defaults).
|
||||
"""
|
||||
if _have_anthropic_sdk() and os.getenv("ANTHROPIC_API_KEY"):
|
||||
return _call_via_sdk(prompt, model, max_tokens)
|
||||
|
||||
Reference in New Issue
Block a user