diff --git a/Anthropic 1P/00_Tutorial_How-To.ipynb b/Anthropic 1P/00_Tutorial_How-To.ipynb index befac63..d125abe 100644 --- a/Anthropic 1P/00_Tutorial_How-To.ipynb +++ b/Anthropic 1P/00_Tutorial_How-To.ipynb @@ -44,7 +44,7 @@ "outputs": [], "source": [ "API_KEY = \"your_api_key_here\"\n", - "MODEL_NAME = \"claude-3-haiku-20240307\"\n", + "MODEL_NAME = \"claude-3-5-haiku-latest\"\n", "\n", "# Stores the API_KEY & MODEL_NAME variables for use across notebooks within the IPython store\n", "%store API_KEY\n", diff --git a/Anthropic 1P/10.2_Appendix_Tool Use.ipynb b/Anthropic 1P/10.2_Appendix_Tool Use.ipynb index fb632a0..65fb43b 100644 --- a/Anthropic 1P/10.2_Appendix_Tool Use.ipynb +++ b/Anthropic 1P/10.2_Appendix_Tool Use.ipynb @@ -32,10 +32,13 @@ "\n", "client = anthropic.Anthropic(api_key=API_KEY)\n", "\n", - "# Rewrittten to call Claude 3 Sonnet, which is generally better at tool use, and include stop_sequences\n", + "# Use the rolling Sonnet alias so the tool-use appendix keeps working after dated snapshots are retired.\n", + "%store -r MODEL_NAME\n", + "TOOL_USE_MODEL = MODEL_NAME if MODEL_NAME and \"sonnet\" in MODEL_NAME else \"claude-3-5-sonnet-latest\"\n", + "\n", "def get_completion(messages, system_prompt=\"\", prefill=\"\",stop_sequences=None):\n", " message = client.messages.create(\n", - " model=\"claude-3-sonnet-20240229\",\n", + " model=TOOL_USE_MODEL,\n", " max_tokens=2000,\n", " temperature=0.0,\n", " system=system_prompt,\n", diff --git a/scripts/check_deprecated_anthropic_models.py b/scripts/check_deprecated_anthropic_models.py new file mode 100644 index 0000000..1edc715 --- /dev/null +++ b/scripts/check_deprecated_anthropic_models.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +from pathlib import Path +import json +import sys + +BLOCKED_MODELS = { + "claude-3-haiku-20240307", + "claude-3-sonnet-20240229", + "claude-3-opus-20240229", +} + +paths = sorted(Path("Anthropic 1P").glob("*.ipynb")) +violations = [] +for path in paths: + nb = json.loads(path.read_text()) + for cell_index, cell in enumerate(nb.get("cells", []), start=1): + if cell.get("cell_type") != "code": + continue + source = "".join(cell.get("source", [])) + for model in BLOCKED_MODELS: + if model in source: + violations.append(f"{path}: cell {cell_index} still references deprecated model {model}") + +if violations: + print("\n".join(violations)) + sys.exit(1) + +print(f"checked {len(paths)} notebooks, no deprecated direct Anthropic model snapshots found")