diff --git a/custom-skills/31-notion-organizer/code/scripts/_search_llm.py b/custom-skills/31-notion-organizer/code/scripts/_search_llm.py index 166aee2..84a3baa 100644 --- a/custom-skills/31-notion-organizer/code/scripts/_search_llm.py +++ b/custom-skills/31-notion-organizer/code/scripts/_search_llm.py @@ -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)