Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Anthropic 1P/00_Tutorial_How-To.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions Anthropic 1P/10.2_Appendix_Tool Use.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 28 additions & 0 deletions scripts/check_deprecated_anthropic_models.py
Original file line number Diff line number Diff line change
@@ -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")