diff --git a/capabilities/classification/evaluation/promptfooconfig.yaml b/capabilities/classification/evaluation/promptfooconfig.yaml index 5ee72cfb..2e280ace 100644 --- a/capabilities/classification/evaluation/promptfooconfig.yaml +++ b/capabilities/classification/evaluation/promptfooconfig.yaml @@ -7,27 +7,27 @@ prompts: - prompts.py:rag_chain_of_thought_classify providers: - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "Haiku: T-0.0" config: max_tokens: 4096 temperature: 0 - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "Haiku: T-0.2" config: max_tokens: 4096 temperature: 0.2 - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "Haiku: T-0.4" config: max_tokens: 4096 temperature: 0.4 - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "Haiku: T-0.6" config: max_tokens: 4096 temperature: 0.6 - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "Haiku: T-0.8" config: max_tokens: 4096 diff --git a/capabilities/classification/guide.ipynb b/capabilities/classification/guide.ipynb index ca258a09..234ad283 100644 --- a/capabilities/classification/guide.ipynb +++ b/capabilities/classification/guide.ipynb @@ -490,7 +490,7 @@ " stop_sequences=[\"\"], \n", " max_tokens=4096, \n", " temperature=0.0,\n", - " model=\"claude-3-haiku-20240307\"\n", + " model=\"claude-haiku-4-5\"\n", " )\n", " \n", " # Extract the result from the response\n", @@ -734,7 +734,7 @@ " stop_sequences=[\"\"], \n", " max_tokens=4096, \n", " temperature=0.0,\n", - " model=\"claude-3-haiku-20240307\"\n", + " model=\"claude-haiku-4-5\"\n", " )\n", " \n", " # Extract the result from the response\n", @@ -846,7 +846,7 @@ " stop_sequences=[\"\"], \n", " max_tokens=4096, \n", " temperature=0.0,\n", - " model=\"claude-3-haiku-20240307\"\n", + " model=\"claude-haiku-4-5\"\n", " )\n", " \n", " # Extract the result from the response\n", diff --git a/capabilities/contextual-embeddings/guide.ipynb b/capabilities/contextual-embeddings/guide.ipynb index 5e1c0613..74343fd3 100644 --- a/capabilities/contextual-embeddings/guide.ipynb +++ b/capabilities/contextual-embeddings/guide.ipynb @@ -444,7 +444,7 @@ "\n", "def situate_context(doc: str, chunk: str) -> str:\n", " response = client.beta.prompt_caching.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=1024,\n", " temperature=0.0,\n", " messages=[\n", @@ -487,7 +487,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": "import os\nimport pickle\nimport json\nimport numpy as np\nimport voyageai\nfrom typing import List, Dict, Any\nfrom tqdm import tqdm\nimport anthropic\nimport threading\nimport time\nfrom concurrent.futures import ThreadPoolExecutor, as_completed\n\nclass ContextualVectorDB:\n def __init__(self, name: str, voyage_api_key=None, anthropic_api_key=None):\n if voyage_api_key is None:\n voyage_api_key = os.getenv(\"VOYAGE_API_KEY\")\n if anthropic_api_key is None:\n anthropic_api_key = os.getenv(\"ANTHROPIC_API_KEY\")\n \n self.voyage_client = voyageai.Client(api_key=voyage_api_key)\n self.anthropic_client = anthropic.Anthropic(api_key=anthropic_api_key)\n self.name = name\n self.embeddings = []\n self.metadata = []\n self.query_cache = {}\n self.db_path = f\"./data/{name}/contextual_vector_db.pkl\"\n\n self.token_counts = {\n 'input': 0,\n 'output': 0,\n 'cache_read': 0,\n 'cache_creation': 0\n }\n self.token_lock = threading.Lock()\n\n def situate_context(self, doc: str, chunk: str) -> tuple[str, Any]:\n DOCUMENT_CONTEXT_PROMPT = \"\"\"\n \n {doc_content}\n \n \"\"\"\n\n CHUNK_CONTEXT_PROMPT = \"\"\"\n Here is the chunk we want to situate within the whole document\n \n {chunk_content}\n \n\n Please give a short succinct context to situate this chunk within the overall document for the purposes of improving search retrieval of the chunk.\n Answer only with the succinct context and nothing else.\n \"\"\"\n\n response = self.anthropic_client.beta.prompt_caching.messages.create(\n model=\"claude-3-haiku-20240307\",\n max_tokens=1000,\n temperature=0.0,\n messages=[\n {\n \"role\": \"user\", \n \"content\": [\n {\n \"type\": \"text\",\n \"text\": DOCUMENT_CONTEXT_PROMPT.format(doc_content=doc),\n \"cache_control\": {\"type\": \"ephemeral\"} #we will make use of prompt caching for the full documents\n },\n {\n \"type\": \"text\",\n \"text\": CHUNK_CONTEXT_PROMPT.format(chunk_content=chunk),\n },\n ]\n },\n ],\n extra_headers={\"anthropic-beta\": \"prompt-caching-2024-07-31\"}\n )\n return response.content[0].text, response.usage\n\n def load_data(self, dataset: List[Dict[str, Any]], parallel_threads: int = 1):\n if self.embeddings and self.metadata:\n print(\"Vector database is already loaded. Skipping data loading.\")\n return\n if os.path.exists(self.db_path):\n print(\"Loading vector database from disk.\")\n self.load_db()\n return\n\n texts_to_embed = []\n metadata = []\n total_chunks = sum(len(doc['chunks']) for doc in dataset)\n\n def process_chunk(doc, chunk):\n #for each chunk, produce the context\n contextualized_text, usage = self.situate_context(doc['content'], chunk['content'])\n with self.token_lock:\n self.token_counts['input'] += usage.input_tokens\n self.token_counts['output'] += usage.output_tokens\n self.token_counts['cache_read'] += usage.cache_read_input_tokens\n self.token_counts['cache_creation'] += usage.cache_creation_input_tokens\n \n return {\n #append the context to the original text chunk\n 'text_to_embed': f\"{chunk['content']}\\n\\n{contextualized_text}\",\n 'metadata': {\n 'doc_id': doc['doc_id'],\n 'original_uuid': doc['original_uuid'],\n 'chunk_id': chunk['chunk_id'],\n 'original_index': chunk['original_index'],\n 'original_content': chunk['content'],\n 'contextualized_content': contextualized_text\n }\n }\n\n print(f\"Processing {total_chunks} chunks with {parallel_threads} threads\")\n with ThreadPoolExecutor(max_workers=parallel_threads) as executor:\n futures = []\n for doc in dataset:\n for chunk in doc['chunks']:\n futures.append(executor.submit(process_chunk, doc, chunk))\n \n for future in tqdm(as_completed(futures), total=total_chunks, desc=\"Processing chunks\"):\n result = future.result()\n texts_to_embed.append(result['text_to_embed'])\n metadata.append(result['metadata'])\n\n self._embed_and_store(texts_to_embed, metadata)\n self.save_db()\n\n #logging token usage\n print(f\"Contextual Vector database loaded and saved. Total chunks processed: {len(texts_to_embed)}\")\n print(f\"Total input tokens without caching: {self.token_counts['input']}\")\n print(f\"Total output tokens: {self.token_counts['output']}\")\n print(f\"Total input tokens written to cache: {self.token_counts['cache_creation']}\")\n print(f\"Total input tokens read from cache: {self.token_counts['cache_read']}\")\n \n total_tokens = self.token_counts['input'] + self.token_counts['cache_read'] + self.token_counts['cache_creation']\n savings_percentage = (self.token_counts['cache_read'] / total_tokens) * 100 if total_tokens > 0 else 0\n print(f\"Total input token savings from prompt caching: {savings_percentage:.2f}% of all input tokens used were read from cache.\")\n print(\"Tokens read from cache come at a 90 percent discount!\")\n\n #we use voyage AI here for embeddings. Read more here: https://docs.voyageai.com/docs/embeddings\n def _embed_and_store(self, texts: List[str], data: List[Dict[str, Any]]):\n batch_size = 128\n result = [\n self.voyage_client.embed(\n texts[i : i + batch_size],\n model=\"voyage-2\"\n ).embeddings\n for i in range(0, len(texts), batch_size)\n ]\n self.embeddings = [embedding for batch in result for embedding in batch]\n self.metadata = data\n\n def search(self, query: str, k: int = 20) -> List[Dict[str, Any]]:\n if query in self.query_cache:\n query_embedding = self.query_cache[query]\n else:\n query_embedding = self.voyage_client.embed([query], model=\"voyage-2\").embeddings[0]\n self.query_cache[query] = query_embedding\n\n if not self.embeddings:\n raise ValueError(\"No data loaded in the vector database.\")\n\n similarities = np.dot(self.embeddings, query_embedding)\n top_indices = np.argsort(similarities)[::-1][:k]\n \n top_results = []\n for idx in top_indices:\n result = {\n \"metadata\": self.metadata[idx],\n \"similarity\": float(similarities[idx]),\n }\n top_results.append(result)\n return top_results\n\n def save_db(self):\n data = {\n \"embeddings\": self.embeddings,\n \"metadata\": self.metadata,\n \"query_cache\": json.dumps(self.query_cache),\n }\n os.makedirs(os.path.dirname(self.db_path), exist_ok=True)\n with open(self.db_path, \"wb\") as file:\n pickle.dump(data, file)\n\n def load_db(self):\n if not os.path.exists(self.db_path):\n raise ValueError(\"Vector database file not found. Use load_data to create a new database.\")\n with open(self.db_path, \"rb\") as file:\n data = pickle.load(file)\n self.embeddings = data[\"embeddings\"]\n self.metadata = data[\"metadata\"]\n self.query_cache = json.loads(data[\"query_cache\"])" + "source": "import os\nimport pickle\nimport json\nimport numpy as np\nimport voyageai\nfrom typing import List, Dict, Any\nfrom tqdm import tqdm\nimport anthropic\nimport threading\nimport time\nfrom concurrent.futures import ThreadPoolExecutor, as_completed\n\nclass ContextualVectorDB:\n def __init__(self, name: str, voyage_api_key=None, anthropic_api_key=None):\n if voyage_api_key is None:\n voyage_api_key = os.getenv(\"VOYAGE_API_KEY\")\n if anthropic_api_key is None:\n anthropic_api_key = os.getenv(\"ANTHROPIC_API_KEY\")\n \n self.voyage_client = voyageai.Client(api_key=voyage_api_key)\n self.anthropic_client = anthropic.Anthropic(api_key=anthropic_api_key)\n self.name = name\n self.embeddings = []\n self.metadata = []\n self.query_cache = {}\n self.db_path = f\"./data/{name}/contextual_vector_db.pkl\"\n\n self.token_counts = {\n 'input': 0,\n 'output': 0,\n 'cache_read': 0,\n 'cache_creation': 0\n }\n self.token_lock = threading.Lock()\n\n def situate_context(self, doc: str, chunk: str) -> tuple[str, Any]:\n DOCUMENT_CONTEXT_PROMPT = \"\"\"\n \n {doc_content}\n \n \"\"\"\n\n CHUNK_CONTEXT_PROMPT = \"\"\"\n Here is the chunk we want to situate within the whole document\n \n {chunk_content}\n \n\n Please give a short succinct context to situate this chunk within the overall document for the purposes of improving search retrieval of the chunk.\n Answer only with the succinct context and nothing else.\n \"\"\"\n\n response = self.anthropic_client.beta.prompt_caching.messages.create(\n model=\"claude-haiku-4-5\",\n max_tokens=1000,\n temperature=0.0,\n messages=[\n {\n \"role\": \"user\", \n \"content\": [\n {\n \"type\": \"text\",\n \"text\": DOCUMENT_CONTEXT_PROMPT.format(doc_content=doc),\n \"cache_control\": {\"type\": \"ephemeral\"} #we will make use of prompt caching for the full documents\n },\n {\n \"type\": \"text\",\n \"text\": CHUNK_CONTEXT_PROMPT.format(chunk_content=chunk),\n },\n ]\n },\n ],\n extra_headers={\"anthropic-beta\": \"prompt-caching-2024-07-31\"}\n )\n return response.content[0].text, response.usage\n\n def load_data(self, dataset: List[Dict[str, Any]], parallel_threads: int = 1):\n if self.embeddings and self.metadata:\n print(\"Vector database is already loaded. Skipping data loading.\")\n return\n if os.path.exists(self.db_path):\n print(\"Loading vector database from disk.\")\n self.load_db()\n return\n\n texts_to_embed = []\n metadata = []\n total_chunks = sum(len(doc['chunks']) for doc in dataset)\n\n def process_chunk(doc, chunk):\n #for each chunk, produce the context\n contextualized_text, usage = self.situate_context(doc['content'], chunk['content'])\n with self.token_lock:\n self.token_counts['input'] += usage.input_tokens\n self.token_counts['output'] += usage.output_tokens\n self.token_counts['cache_read'] += usage.cache_read_input_tokens\n self.token_counts['cache_creation'] += usage.cache_creation_input_tokens\n \n return {\n #append the context to the original text chunk\n 'text_to_embed': f\"{chunk['content']}\\n\\n{contextualized_text}\",\n 'metadata': {\n 'doc_id': doc['doc_id'],\n 'original_uuid': doc['original_uuid'],\n 'chunk_id': chunk['chunk_id'],\n 'original_index': chunk['original_index'],\n 'original_content': chunk['content'],\n 'contextualized_content': contextualized_text\n }\n }\n\n print(f\"Processing {total_chunks} chunks with {parallel_threads} threads\")\n with ThreadPoolExecutor(max_workers=parallel_threads) as executor:\n futures = []\n for doc in dataset:\n for chunk in doc['chunks']:\n futures.append(executor.submit(process_chunk, doc, chunk))\n \n for future in tqdm(as_completed(futures), total=total_chunks, desc=\"Processing chunks\"):\n result = future.result()\n texts_to_embed.append(result['text_to_embed'])\n metadata.append(result['metadata'])\n\n self._embed_and_store(texts_to_embed, metadata)\n self.save_db()\n\n #logging token usage\n print(f\"Contextual Vector database loaded and saved. Total chunks processed: {len(texts_to_embed)}\")\n print(f\"Total input tokens without caching: {self.token_counts['input']}\")\n print(f\"Total output tokens: {self.token_counts['output']}\")\n print(f\"Total input tokens written to cache: {self.token_counts['cache_creation']}\")\n print(f\"Total input tokens read from cache: {self.token_counts['cache_read']}\")\n \n total_tokens = self.token_counts['input'] + self.token_counts['cache_read'] + self.token_counts['cache_creation']\n savings_percentage = (self.token_counts['cache_read'] / total_tokens) * 100 if total_tokens > 0 else 0\n print(f\"Total input token savings from prompt caching: {savings_percentage:.2f}% of all input tokens used were read from cache.\")\n print(\"Tokens read from cache come at a 90 percent discount!\")\n\n #we use voyage AI here for embeddings. Read more here: https://docs.voyageai.com/docs/embeddings\n def _embed_and_store(self, texts: List[str], data: List[Dict[str, Any]]):\n batch_size = 128\n result = [\n self.voyage_client.embed(\n texts[i : i + batch_size],\n model=\"voyage-2\"\n ).embeddings\n for i in range(0, len(texts), batch_size)\n ]\n self.embeddings = [embedding for batch in result for embedding in batch]\n self.metadata = data\n\n def search(self, query: str, k: int = 20) -> List[Dict[str, Any]]:\n if query in self.query_cache:\n query_embedding = self.query_cache[query]\n else:\n query_embedding = self.voyage_client.embed([query], model=\"voyage-2\").embeddings[0]\n self.query_cache[query] = query_embedding\n\n if not self.embeddings:\n raise ValueError(\"No data loaded in the vector database.\")\n\n similarities = np.dot(self.embeddings, query_embedding)\n top_indices = np.argsort(similarities)[::-1][:k]\n \n top_results = []\n for idx in top_indices:\n result = {\n \"metadata\": self.metadata[idx],\n \"similarity\": float(similarities[idx]),\n }\n top_results.append(result)\n return top_results\n\n def save_db(self):\n data = {\n \"embeddings\": self.embeddings,\n \"metadata\": self.metadata,\n \"query_cache\": json.dumps(self.query_cache),\n }\n os.makedirs(os.path.dirname(self.db_path), exist_ok=True)\n with open(self.db_path, \"wb\") as file:\n pickle.dump(data, file)\n\n def load_db(self):\n if not os.path.exists(self.db_path):\n raise ValueError(\"Vector database file not found. Use load_data to create a new database.\")\n with open(self.db_path, \"rb\") as file:\n data = pickle.load(file)\n self.embeddings = data[\"embeddings\"]\n self.metadata = data[\"metadata\"]\n self.query_cache = json.loads(data[\"query_cache\"])" }, { "cell_type": "code", diff --git a/capabilities/retrieval_augmented_generation/evaluation/eval_end_to_end.py b/capabilities/retrieval_augmented_generation/evaluation/eval_end_to_end.py index b8ee8860..1fdd1da8 100644 --- a/capabilities/retrieval_augmented_generation/evaluation/eval_end_to_end.py +++ b/capabilities/retrieval_augmented_generation/evaluation/eval_end_to_end.py @@ -35,7 +35,7 @@ def evaluate_end_to_end(query, generated_answer, correct_answer): client = Anthropic(api_key=os.environ.get('ANTHROPIC_API_KEY')) try: response = client.messages.create( - model="claude-3-5-sonnet-20241022", + model="claude-sonnet-4-5", max_tokens=1500, messages=[ {"role": "user", "content": prompt}, diff --git a/capabilities/retrieval_augmented_generation/evaluation/promptfooconfig_end_to_end.yaml b/capabilities/retrieval_augmented_generation/evaluation/promptfooconfig_end_to_end.yaml index e60d91a8..100c2afe 100644 --- a/capabilities/retrieval_augmented_generation/evaluation/promptfooconfig_end_to_end.yaml +++ b/capabilities/retrieval_augmented_generation/evaluation/promptfooconfig_end_to_end.yaml @@ -7,13 +7,13 @@ prompts: - prompts.py:answer_query_level_three providers: - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "Haiku: T-0.0" config: max_tokens: 2500 temperature: 0 - - id: anthropic:messages:claude-3-5-sonnet-20241022 + - id: anthropic:messages:claude-sonnet-4-5 label: "3.5 Sonnet: T-0.0" config: max_tokens: 2500 diff --git a/capabilities/retrieval_augmented_generation/evaluation/prompts.py b/capabilities/retrieval_augmented_generation/evaluation/prompts.py index 0a2fc1c5..dea172e2 100644 --- a/capabilities/retrieval_augmented_generation/evaluation/prompts.py +++ b/capabilities/retrieval_augmented_generation/evaluation/prompts.py @@ -106,7 +106,7 @@ def _rerank_results(query: str, results: List[Dict], k: int = 5) -> List[Dict]: """ try: response = client.messages.create( - model="claude-3-haiku-20240307", + model="claude-haiku-4-5", max_tokens=50, messages=[{"role": "user", "content": prompt}, {"role": "assistant", "content": ""}], temperature=0, diff --git a/capabilities/retrieval_augmented_generation/evaluation/provider_retrieval.py b/capabilities/retrieval_augmented_generation/evaluation/provider_retrieval.py index 7447a4e8..654f04ed 100644 --- a/capabilities/retrieval_augmented_generation/evaluation/provider_retrieval.py +++ b/capabilities/retrieval_augmented_generation/evaluation/provider_retrieval.py @@ -67,7 +67,7 @@ def _rerank_results(query: str, results: List[Dict], k: int = 3) -> List[Dict]: client = Anthropic(api_key=os.environ.get('ANTHROPIC_API_KEY')) try: response = client.messages.create( - model="claude-3-5-sonnet-20241022", + model="claude-sonnet-4-5", max_tokens=50, messages=[{"role": "user", "content": prompt}, {"role": "assistant", "content": ""}], temperature=0, diff --git a/capabilities/retrieval_augmented_generation/guide.ipynb b/capabilities/retrieval_augmented_generation/guide.ipynb index 213a5749..9d3ec2c9 100644 --- a/capabilities/retrieval_augmented_generation/guide.ipynb +++ b/capabilities/retrieval_augmented_generation/guide.ipynb @@ -360,7 +360,7 @@ " Answer the question now, and avoid providing preamble such as 'Here is the answer', etc\n", " \"\"\"\n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=2500,\n", " messages=[\n", " {\"role\": \"user\", \"content\": prompt}\n", @@ -643,7 +643,7 @@ " \n", " try:\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=1500,\n", " messages=[\n", " {\"role\": \"user\", \"content\": prompt},\n", @@ -3264,7 +3264,7 @@ " \"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=150,\n", " messages=[\n", " {\"role\": \"user\", \"content\": prompt}\n", @@ -3461,7 +3461,7 @@ " Answer the question now, and avoid providing preamble such as 'Here is the answer', etc\n", " \"\"\"\n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=2500,\n", " messages=[\n", " {\"role\": \"user\", \"content\": prompt}\n", @@ -5975,7 +5975,7 @@ " \"\"\"\n", " try:\n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=50,\n", " messages=[{\"role\": \"user\", \"content\": prompt}, {\"role\": \"assistant\", \"content\": \"\"}],\n", " temperature=0,\n", @@ -6044,7 +6044,7 @@ " Answer the question now, and avoid providing preamble such as 'Here is the answer', etc\n", " \"\"\"\n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=2500,\n", " messages=[{\"role\": \"user\", \"content\": prompt}],\n", " temperature=0\n", diff --git a/capabilities/summarization/evaluation/custom_evals/llm_eval.py b/capabilities/summarization/evaluation/custom_evals/llm_eval.py index 256d11a7..8b474e08 100644 --- a/capabilities/summarization/evaluation/custom_evals/llm_eval.py +++ b/capabilities/summarization/evaluation/custom_evals/llm_eval.py @@ -53,7 +53,7 @@ def llm_eval(summary, input): Evaluation (JSON format):""" response = client.messages.create( - model="claude-3-5-sonnet-20241022", + model="claude-sonnet-4-5", max_tokens=1000, temperature=0, messages=[ diff --git a/capabilities/summarization/evaluation/promptfooconfig.yaml b/capabilities/summarization/evaluation/promptfooconfig.yaml index 5df38b22..cfc728d3 100644 --- a/capabilities/summarization/evaluation/promptfooconfig.yaml +++ b/capabilities/summarization/evaluation/promptfooconfig.yaml @@ -6,12 +6,12 @@ prompts: - prompts.py:summarize_long_document providers: - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "3.0 Haiku" config: max_tokens: 4096 temperature: 0 - - id: anthropic:messages:claude-3-5-sonnet-20241022 + - id: anthropic:messages:claude-sonnet-4-5 label: "3.5 Sonnet" config: max_tokens: 4096 diff --git a/capabilities/summarization/guide.ipynb b/capabilities/summarization/guide.ipynb index 7b9f77a7..2c673137 100644 --- a/capabilities/summarization/guide.ipynb +++ b/capabilities/summarization/guide.ipynb @@ -198,7 +198,7 @@ " \"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=max_tokens,\n", " system=\"You are a legal analyst known for highly accurate and detailed summaries of legal documents.\",\n", " messages=[\n", @@ -338,7 +338,7 @@ " \"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=max_tokens,\n", " system=\"You are a legal analyst known for highly accurate and detailed summaries of legal documents.\",\n", " messages=[\n", @@ -463,7 +463,7 @@ " \"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=max_tokens,\n", " system=\"You are a legal analyst known for highly accurate and detailed summaries of legal documents.\",\n", " messages=[\n", @@ -561,7 +561,7 @@ "metadata": {}, "outputs": [], "source": [ - "def guided_sublease_summary(text, model=\"claude-3-5-sonnet-20241022\", max_tokens=1000):\n", + "def guided_sublease_summary(text, model=\"claude-sonnet-4-5\", max_tokens=1000):\n", "\n", " # Prompt the model to summarize the sublease agreement\n", " prompt = f\"\"\"Summarize the following sublease agreement. Focus on these key aspects:\n", @@ -793,7 +793,7 @@ " # Iterate over chunks and summarize each one\n", " # We use guided_legal_summary here, but you can use basic_summarize or any other summarization function\n", " # Note that we'll also use haiku for the interim summaries, and the 3.5 sonnet for the final summary\n", - " chunk_summaries = [guided_sublease_summary(chunk, model=\"claude-3-haiku-20240307\", max_tokens=max_tokens) for chunk in chunks]\n", + " chunk_summaries = [guided_sublease_summary(chunk, model=\"claude-haiku-4-5\", max_tokens=max_tokens) for chunk in chunks]\n", " \n", " final_summary_prompt = f\"\"\"\n", " \n", @@ -821,7 +821,7 @@ " \"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=max_tokens,\n", " system=\"You are a legal expert that summarizes notes on one document.\",\n", " messages=[\n", @@ -922,7 +922,7 @@ " \"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=500,\n", " temperature=0.2,\n", " messages=[\n", @@ -944,7 +944,7 @@ " prompt=f\"Legal document summary: {summary}\\n\\nLegal query: {query}\\n\\nRate the relevance of this legal document to the query on a scale of 0 to 10. Only output the numeric value:\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=2,\n", " temperature=0,\n", " messages=[\n", @@ -974,7 +974,7 @@ " Relevant clauses or sections (separated by '---'):\"\"\"\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-20241022\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=1000,\n", " temperature=0,\n", " messages=[\n", diff --git a/capabilities/text_to_sql/evaluation/promptfooconfig.yaml b/capabilities/text_to_sql/evaluation/promptfooconfig.yaml index 2c4d519c..31c03139 100644 --- a/capabilities/text_to_sql/evaluation/promptfooconfig.yaml +++ b/capabilities/text_to_sql/evaluation/promptfooconfig.yaml @@ -1,10 +1,10 @@ providers: - - id: anthropic:messages:claude-3-haiku-20240307 + - id: anthropic:messages:claude-haiku-4-5 label: "3 Haiku" config: max_tokens: 4096 temperature: 0 - - id: anthropic:messages:claude-3-5-sonnet-20241022 + - id: anthropic:messages:claude-sonnet-4-5 label: "3.5 Sonnet" config: max_tokens: 4096 diff --git a/capabilities/text_to_sql/guide.ipynb b/capabilities/text_to_sql/guide.ipynb index 3351b703..659a129c 100644 --- a/capabilities/text_to_sql/guide.ipynb +++ b/capabilities/text_to_sql/guide.ipynb @@ -106,7 +106,7 @@ "\n", "# Initialize the Anthropic client\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"\n", + "MODEL_NAME = \"claude-sonnet-4-5\"\n", "\n", "# Filepath to the SQLite database\n", "DATABASE_PATH = \"data/data.db\"" diff --git a/claude_code_sdk/.env.example b/claude_agent_sdk/.env.example similarity index 100% rename from claude_code_sdk/.env.example rename to claude_agent_sdk/.env.example diff --git a/claude_code_sdk/.gitignore b/claude_agent_sdk/.gitignore similarity index 100% rename from claude_code_sdk/.gitignore rename to claude_agent_sdk/.gitignore diff --git a/claude_code_sdk/00_The_one_liner_research_agent.ipynb b/claude_agent_sdk/00_The_one_liner_research_agent.ipynb similarity index 97% rename from claude_code_sdk/00_The_one_liner_research_agent.ipynb rename to claude_agent_sdk/00_The_one_liner_research_agent.ipynb index 13bf3d83..5a2a8430 100644 --- a/claude_code_sdk/00_The_one_liner_research_agent.ipynb +++ b/claude_agent_sdk/00_The_one_liner_research_agent.ipynb @@ -21,7 +21,7 @@ "from dotenv import load_dotenv\n", "from utils.agent_visualizer import print_activity\n", "\n", - "from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient, query\n", + "from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, query\n", "\n", "load_dotenv()" ] @@ -67,7 +67,7 @@ "messages = []\n", "async for msg in query(\n", " prompt=\"Research the latest trends in AI agents and give me a brief summary\",\n", - " options=ClaudeCodeOptions(model=\"claude-sonnet-4-20250514\", allowed_tools=[\"WebSearch\"]),\n", + " options=ClaudeAgentOptions(model=\"claude-sonnet-4-5\", allowed_tools=[\"WebSearch\"]),\n", "):\n", " print_activity(msg)\n", " messages.append(msg)" @@ -157,8 +157,8 @@ "source": [ "messages = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " cwd=\"research_agent\",\n", " system_prompt=\"You are a research agent specialized in AI\",\n", " allowed_tools=[\"WebSearch\", \"Read\"],\n", diff --git a/claude_code_sdk/01_The_chief_of_staff_agent.ipynb b/claude_agent_sdk/01_The_chief_of_staff_agent.ipynb similarity index 95% rename from claude_code_sdk/01_The_chief_of_staff_agent.ipynb rename to claude_agent_sdk/01_The_chief_of_staff_agent.ipynb index 13ed6358..8e8fc99e 100644 --- a/claude_code_sdk/01_The_chief_of_staff_agent.ipynb +++ b/claude_agent_sdk/01_The_chief_of_staff_agent.ipynb @@ -20,7 +20,7 @@ "from dotenv import load_dotenv\n", "from utils.agent_visualizer import print_activity, visualize_conversation\n", "\n", - "from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient\n", + "from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient\n", "\n", "load_dotenv()" ] @@ -79,8 +79,8 @@ "outputs": [], "source": [ "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " cwd=\"chief_of_staff_agent\", # Points to subdirectory with our CLAUDE.md\n", " )\n", ") as agent:\n", @@ -116,8 +116,8 @@ "outputs": [], "source": [ "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " allowed_tools=[\"Bash\", \"Read\"],\n", " cwd=\"chief_of_staff_agent\", # Points to subdirectory where our agent is defined\n", " )\n", @@ -165,8 +165,8 @@ "source": [ "messages_executive = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " cwd=\"chief_of_staff_agent\",\n", " settings='{\"outputStyle\": \"executive\"}',\n", " )\n", @@ -178,8 +178,8 @@ "\n", "messages_technical = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " cwd=\"chief_of_staff_agent\",\n", " settings='{\"outputStyle\": \"technical\"}',\n", " )\n", @@ -257,8 +257,8 @@ "messages = []\n", "async with (\n", " ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-opus-4-1-20250805\", # We're using Opus for this as Opus truly shines when it comes to planning!\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-opus-4-1\", # We're using Opus for this as Opus truly shines when it comes to planning!\n", " permission_mode=\"plan\",\n", " )\n", " ) as agent\n", @@ -338,7 +338,7 @@ "\n", "messages = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(model=\"claude-sonnet-4-20250514\", cwd=\"chief_of_staff_agent\")\n", + " options=ClaudeAgentOptions(model=\"claude-sonnet-4-5\", cwd=\"chief_of_staff_agent\")\n", ") as agent:\n", " await agent.query(\"/slash-command-test this is a test\")\n", " async for msg in agent.receive_response():\n", @@ -438,8 +438,8 @@ "source": [ "messages = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " cwd=\"chief_of_staff_agent\",\n", " allowed_tools=[\"Bash\", \"Write\", \"Edit\", \"MultiEdit\"],\n", " )\n", @@ -517,8 +517,8 @@ "source": [ "messages = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " allowed_tools=[\"Task\"], # this enables our Chief agent to invoke subagents\n", " system_prompt=\"Delegate financial questions to the financial-analyst subagent. Do not try to answer these questions yourself.\",\n", " cwd=\"chief_of_staff_agent\",\n", @@ -636,15 +636,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Conclusion\n", - "\n", - "We've demonstrated how the Claude Code SDK enables you to build sophisticated multi-agent systems with enterprise-grade features. Starting from basic script execution with the Bash tool, we progressively introduced advanced capabilities including persistent memory with CLAUDE.md, custom output styles for different audiences, strategic planning mode, slash commands for user convenience, compliance hooks for guardrailing, and subagent coordination for specialized tasks.\n", - "\n", - "By combining these features, we created an AI Chief of Staff capable of handling complex executive decision-making workflows. The system delegates financial analysis to specialized subagents, maintains audit trails through hooks, adapts communication styles for different stakeholders, and provides actionable insights backed by data-driven analysis.\n", - "\n", - "This foundation in advanced agentic patterns and multi-agent orchestration prepares you for building production-ready enterprise systems. In the next notebook, we'll explore how to connect our agents to external services through Model Context Protocol (MCP) servers, dramatically expanding their capabilities beyond the built-in tools.\n", - "\n", - "Next: [02_Connecting_to_MCP_servers.ipynb](02_Connecting_to_MCP_servers.ipynb) - Learn how to extend your agents with custom integrations and external data sources through MCP." + "## Conclusion", + "", + "We've demonstrated how the Claude Code SDK enables you to build sophisticated multi-agent systems with enterprise-grade features. Starting from basic script execution with the Bash tool, we progressively introduced advanced capabilities including persistent memory with CLAUDE.md, custom output styles for different audiences, strategic planning mode, slash commands for user convenience, compliance hooks for guardrailing, and subagent coordination for specialized tasks.", + "", + "By combining these features, we created an AI Chief of Staff capable of handling complex executive decision-making workflows. The system delegates financial analysis to specialized subagents, maintains audit trails through hooks, adapts communication styles for different stakeholders, and provides actionable insights backed by data-driven analysis.", + "", + "This foundation in advanced agentic patterns and multi-agent orchestration prepares you for building production-ready enterprise systems. In the next notebook, we'll explore how to connect our agents to external services through Model Context Protocol (MCP) servers, dramatically expanding their capabilities beyond the built-in tools.", + "", + "Next: [02_The_observability_agent.ipynb](02_The_observability_agent.ipynb) - Learn how to extend your agents with custom integrations and external data sources through MCP." ] } ], @@ -669,4 +669,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/claude_code_sdk/02_The_observability_agent.ipynb b/claude_agent_sdk/02_The_observability_agent.ipynb similarity index 97% rename from claude_code_sdk/02_The_observability_agent.ipynb rename to claude_agent_sdk/02_The_observability_agent.ipynb index 66b3c46a..a3eb18f3 100644 --- a/claude_code_sdk/02_The_observability_agent.ipynb +++ b/claude_agent_sdk/02_The_observability_agent.ipynb @@ -13,7 +13,7 @@ "from dotenv import load_dotenv\n", "from utils.agent_visualizer import print_activity\n", "\n", - "from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient" + "from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient" ] }, { @@ -85,8 +85,8 @@ "messages = []\n", "async with (\n", " ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " mcp_servers=git_mcp,\n", " allowed_tools=[\n", " \"mcp__git\"\n", @@ -184,15 +184,15 @@ "# run our agent\n", "messages = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " mcp_servers=github_mcp,\n", " allowed_tools=[\"mcp__github\"],\n", " permission_mode=\"acceptEdits\", # auto-accept permissions\n", " )\n", ") as agent:\n", " await agent.query(\n", - " \"Use ONLY your GitHub MCP tools to search for the anthropics/claude-code-sdk-python repository and and give me a couple facts about it\"\n", + " \"Use ONLY your GitHub MCP tools to search for the anthropics/claude-agent-sdk-python repository and and give me a couple facts about it\"\n", " )\n", " async for msg in agent.receive_response():\n", " print_activity(msg)\n", @@ -308,8 +308,8 @@ "\n", "messages = []\n", "async with ClaudeSDKClient(\n", - " options=ClaudeCodeOptions(\n", - " model=\"claude-sonnet-4-20250514\",\n", + " options=ClaudeAgentOptions(\n", + " model=\"claude-sonnet-4-5\",\n", " mcp_servers=github_mcp,\n", " allowed_tools=[\"mcp__github\"],\n", " permission_mode=\"acceptEdits\",\n", @@ -353,7 +353,7 @@ "from observability_agent.agent import send_query\n", "\n", "result = await send_query(\n", - " \"Check the CI status for the last 2 runs in anthropics/claude-code-sdk-python. Just do 3 tool calls, be efficient.\"\n", + " \"Check the CI status for the last 2 runs in anthropics/claude-agent-sdk-python. Just do 3 tool calls, be efficient.\"\n", ")\n", "print(f\"Monitoring result: {result}\")" ] diff --git a/claude_code_sdk/README.md b/claude_agent_sdk/README.md similarity index 88% rename from claude_code_sdk/README.md rename to claude_agent_sdk/README.md index c158c9b2..a9113577 100644 --- a/claude_code_sdk/README.md +++ b/claude_agent_sdk/README.md @@ -1,6 +1,6 @@ -# Building Powerful Agents with the Claude Code SDK +# Building Powerful Agents with the Claude Agent SDK -A tutorial series demonstrating how to build sophisticated general-purpose agentic systems using the [Claude Code SDK](https://github.com/anthropics/claude-code-sdk-python), progressing from simple research agents to multi-agent orchestration with external system integration. +A tutorial series demonstrating how to build sophisticated general-purpose agentic systems using the [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk-python), progressing from simple research agents to multi-agent orchestration with external system integration. ## Getting Started @@ -14,7 +14,7 @@ A tutorial series demonstrating how to build sophisticated general-purpose agent ```git clone https://github.com/anthropics/anthropic-cookbook.git ``` -```cd anthropic-cookbook/claude_code_sdk``` +```cd anthropic-cookbook/claude_agent_sdk``` ```uv sync ``` @@ -42,7 +42,7 @@ This tutorial series takes you on a journey from basic agent implementation to s ### What You'll Learn Through this series, you'll be exposed to: -- **Core SDK fundamentals** with `query()` and the `ClaudeSDKClient` & `ClaudeCodeOptions` interfaces in the Python SDK +- **Core SDK fundamentals** with `query()` and the `ClaudeSDKClient` & `ClaudeAgentOptions` interfaces in the Python SDK - **Tool usage patterns** from basic WebSearch to complex MCP server integration - **Multi-agent orchestration** with specialized subagents and coordination - **Enterprise features** by leveraging hooks for compliance tracking and audit trails @@ -54,7 +54,7 @@ Note: This tutorial assumes you have some level of familiarity with Claude Code. ### [Notebook 00: The One-Liner Research Agent](00_The_one_liner_research_agent.ipynb) -Start your journey with a simple yet powerful research agent built in just a few lines of code. This notebook introduces core SDK concepts and demonstrates how the Claude Code SDK enables autonomous information gathering and synthesis. +Start your journey with a simple yet powerful research agent built in just a few lines of code. This notebook introduces core SDK concepts and demonstrates how the Claude Agent SDK enables autonomous information gathering and synthesis. **Key Concepts:** - Basic agent loops with `query()` and async iteration @@ -95,7 +95,7 @@ Each notebook includes an agent implementation in its respective directory: - **`observability_agent/`** - DevOps monitoring agent with GitHub integration ## Background -### The Evolution of Claude Code SDK +### The Evolution of Claude Agent SDK Claude Code has emerged as one of Anthropic's most successful products, but not just for its SOTA coding capabilities. Its true breakthrough lies in something more fundamental: **Claude is exceptionally good at agentic work**. @@ -110,7 +110,7 @@ These capabilities have made Claude Code the closest thing to a "bare metal" har ### Beyond Coding: The Agent Builder's Toolkit -Originally an internal tool built by Anthropic engineers to accelerate development workflows, the SDK's public release revealed unexpected potential. After the release of the Claude Code SDK and its GitHub integration, developers began using it for tasks far beyond coding: +Originally an internal tool built by Anthropic engineers to accelerate development workflows, the SDK's public release revealed unexpected potential. After the release of the Claude Agent SDK and its GitHub integration, developers began using it for tasks far beyond coding: - **Research agents** that gather and synthesize information across multiple sources - **Data analysis agents** that explore datasets and generate insights @@ -120,7 +120,7 @@ Originally an internal tool built by Anthropic engineers to accelerate developme The pattern was clear: the SDK had inadvertently become an effective agent-building framework. Its architecture, designed to handle software development complexity, proved remarkably well-suited for general-purpose agent creation. -This tutorial series demonstrates how to leverage the Claude Code SDK to build highly efficient agents for any domain or use case, from simple automation to complex enterprise systems. +This tutorial series demonstrates how to leverage the Claude Agent SDK to build highly efficient agents for any domain or use case, from simple automation to complex enterprise systems. ## Contributing diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/agents/financial-analyst.md b/claude_agent_sdk/chief_of_staff_agent/.claude/agents/financial-analyst.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/agents/financial-analyst.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/agents/financial-analyst.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/agents/recruiter.md b/claude_agent_sdk/chief_of_staff_agent/.claude/agents/recruiter.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/agents/recruiter.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/agents/recruiter.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/commands/budget-impact.md b/claude_agent_sdk/chief_of_staff_agent/.claude/commands/budget-impact.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/commands/budget-impact.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/commands/budget-impact.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/commands/slash-command-test.md b/claude_agent_sdk/chief_of_staff_agent/.claude/commands/slash-command-test.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/commands/slash-command-test.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/commands/slash-command-test.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/commands/strategic-brief.md b/claude_agent_sdk/chief_of_staff_agent/.claude/commands/strategic-brief.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/commands/strategic-brief.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/commands/strategic-brief.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/commands/talent-scan.md b/claude_agent_sdk/chief_of_staff_agent/.claude/commands/talent-scan.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/commands/talent-scan.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/commands/talent-scan.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/hooks/report-tracker.py b/claude_agent_sdk/chief_of_staff_agent/.claude/hooks/report-tracker.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/hooks/report-tracker.py rename to claude_agent_sdk/chief_of_staff_agent/.claude/hooks/report-tracker.py diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/hooks/script-usage-logger.py b/claude_agent_sdk/chief_of_staff_agent/.claude/hooks/script-usage-logger.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/hooks/script-usage-logger.py rename to claude_agent_sdk/chief_of_staff_agent/.claude/hooks/script-usage-logger.py diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/output-styles/executive.md b/claude_agent_sdk/chief_of_staff_agent/.claude/output-styles/executive.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/output-styles/executive.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/output-styles/executive.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/output-styles/technical.md b/claude_agent_sdk/chief_of_staff_agent/.claude/output-styles/technical.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/output-styles/technical.md rename to claude_agent_sdk/chief_of_staff_agent/.claude/output-styles/technical.md diff --git a/claude_code_sdk/chief_of_staff_agent/.claude/settings.local.json b/claude_agent_sdk/chief_of_staff_agent/.claude/settings.local.json similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/.claude/settings.local.json rename to claude_agent_sdk/chief_of_staff_agent/.claude/settings.local.json diff --git a/claude_code_sdk/chief_of_staff_agent/CLAUDE.md b/claude_agent_sdk/chief_of_staff_agent/CLAUDE.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/CLAUDE.md rename to claude_agent_sdk/chief_of_staff_agent/CLAUDE.md diff --git a/claude_code_sdk/chief_of_staff_agent/agent.py b/claude_agent_sdk/chief_of_staff_agent/agent.py similarity index 96% rename from claude_code_sdk/chief_of_staff_agent/agent.py rename to claude_agent_sdk/chief_of_staff_agent/agent.py index 9e747402..3441cefe 100644 --- a/claude_code_sdk/chief_of_staff_agent/agent.py +++ b/claude_agent_sdk/chief_of_staff_agent/agent.py @@ -10,7 +10,7 @@ from dotenv import load_dotenv -from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient +from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient load_dotenv() @@ -79,7 +79,7 @@ async def send_query( # build options with optional output style options_dict = { - "model": "claude-sonnet-4-20250514", + "model": "claude-sonnet-4-5", "allowed_tools": [ "Task", # enables subagent delegation "Read", @@ -98,7 +98,7 @@ async def send_query( if output_style: options_dict["settings"] = json.dumps({"outputStyle": output_style}) - options = ClaudeCodeOptions(**options_dict) + options = ClaudeAgentOptions(**options_dict) result = None messages = [] # this is to append the messages ONLY for this agent turn diff --git a/claude_code_sdk/chief_of_staff_agent/audit/report_history.json b/claude_agent_sdk/chief_of_staff_agent/audit/report_history.json similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/audit/report_history.json rename to claude_agent_sdk/chief_of_staff_agent/audit/report_history.json diff --git a/claude_code_sdk/chief_of_staff_agent/audit/script_usage_log.json b/claude_agent_sdk/chief_of_staff_agent/audit/script_usage_log.json similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/audit/script_usage_log.json rename to claude_agent_sdk/chief_of_staff_agent/audit/script_usage_log.json diff --git a/claude_code_sdk/chief_of_staff_agent/financial_data/burn_rate.csv b/claude_agent_sdk/chief_of_staff_agent/financial_data/burn_rate.csv similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/financial_data/burn_rate.csv rename to claude_agent_sdk/chief_of_staff_agent/financial_data/burn_rate.csv diff --git a/claude_code_sdk/chief_of_staff_agent/financial_data/hiring_costs.csv b/claude_agent_sdk/chief_of_staff_agent/financial_data/hiring_costs.csv similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/financial_data/hiring_costs.csv rename to claude_agent_sdk/chief_of_staff_agent/financial_data/hiring_costs.csv diff --git a/claude_code_sdk/chief_of_staff_agent/financial_data/revenue_forecast.json b/claude_agent_sdk/chief_of_staff_agent/financial_data/revenue_forecast.json similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/financial_data/revenue_forecast.json rename to claude_agent_sdk/chief_of_staff_agent/financial_data/revenue_forecast.json diff --git a/claude_code_sdk/chief_of_staff_agent/flow_diagram.md b/claude_agent_sdk/chief_of_staff_agent/flow_diagram.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/flow_diagram.md rename to claude_agent_sdk/chief_of_staff_agent/flow_diagram.md diff --git a/claude_code_sdk/chief_of_staff_agent/output_reports/Q2_2024_Financial_Forecast.md b/claude_agent_sdk/chief_of_staff_agent/output_reports/Q2_2024_Financial_Forecast.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/output_reports/Q2_2024_Financial_Forecast.md rename to claude_agent_sdk/chief_of_staff_agent/output_reports/Q2_2024_Financial_Forecast.md diff --git a/claude_code_sdk/chief_of_staff_agent/output_reports/hiring_decision.md b/claude_agent_sdk/chief_of_staff_agent/output_reports/hiring_decision.md similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/output_reports/hiring_decision.md rename to claude_agent_sdk/chief_of_staff_agent/output_reports/hiring_decision.md diff --git a/claude_code_sdk/chief_of_staff_agent/scripts/decision_matrix.py b/claude_agent_sdk/chief_of_staff_agent/scripts/decision_matrix.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/scripts/decision_matrix.py rename to claude_agent_sdk/chief_of_staff_agent/scripts/decision_matrix.py diff --git a/claude_code_sdk/chief_of_staff_agent/scripts/financial_forecast.py b/claude_agent_sdk/chief_of_staff_agent/scripts/financial_forecast.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/scripts/financial_forecast.py rename to claude_agent_sdk/chief_of_staff_agent/scripts/financial_forecast.py diff --git a/claude_code_sdk/chief_of_staff_agent/scripts/hiring_impact.py b/claude_agent_sdk/chief_of_staff_agent/scripts/hiring_impact.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/scripts/hiring_impact.py rename to claude_agent_sdk/chief_of_staff_agent/scripts/hiring_impact.py diff --git a/claude_code_sdk/chief_of_staff_agent/scripts/simple_calculation.py b/claude_agent_sdk/chief_of_staff_agent/scripts/simple_calculation.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/scripts/simple_calculation.py rename to claude_agent_sdk/chief_of_staff_agent/scripts/simple_calculation.py diff --git a/claude_code_sdk/chief_of_staff_agent/scripts/talent_scorer.py b/claude_agent_sdk/chief_of_staff_agent/scripts/talent_scorer.py similarity index 100% rename from claude_code_sdk/chief_of_staff_agent/scripts/talent_scorer.py rename to claude_agent_sdk/chief_of_staff_agent/scripts/talent_scorer.py diff --git a/claude_code_sdk/observability_agent/agent.py b/claude_agent_sdk/observability_agent/agent.py similarity index 95% rename from claude_code_sdk/observability_agent/agent.py rename to claude_agent_sdk/observability_agent/agent.py index a52c026e..68e2f3f7 100644 --- a/claude_code_sdk/observability_agent/agent.py +++ b/claude_agent_sdk/observability_agent/agent.py @@ -10,7 +10,7 @@ from dotenv import load_dotenv -from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient +from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient load_dotenv() @@ -82,8 +82,8 @@ async def send_query( if mcp_servers: servers.update(mcp_servers) - options = ClaudeCodeOptions( - model="claude-sonnet-4-20250514", + options = ClaudeAgentOptions( + model="claude-sonnet-4-5", allowed_tools=["mcp__github", "WebSearch", "Read"], continue_conversation=continue_conversation, system_prompt="You are an observability agent specialized in monitoring GitHub repositories and CI/CD workflows", diff --git a/claude_code_sdk/observability_agent/architecture_diagram.md b/claude_agent_sdk/observability_agent/architecture_diagram.md similarity index 100% rename from claude_code_sdk/observability_agent/architecture_diagram.md rename to claude_agent_sdk/observability_agent/architecture_diagram.md diff --git a/claude_code_sdk/observability_agent/docker/Dockerfile b/claude_agent_sdk/observability_agent/docker/Dockerfile similarity index 97% rename from claude_code_sdk/observability_agent/docker/Dockerfile rename to claude_agent_sdk/observability_agent/docker/Dockerfile index b4b6cdc3..54ff34b5 100644 --- a/claude_code_sdk/observability_agent/docker/Dockerfile +++ b/claude_agent_sdk/observability_agent/docker/Dockerfile @@ -23,7 +23,7 @@ RUN npm install -g @anthropic-ai/claude-code COPY observability_agent ./observability_agent RUN pip install --no-cache-dir \ - claude-code-sdk \ + claude-agent-sdk \ fastapi \ python-dotenv \ uvicorn[standard] \ diff --git a/claude_code_sdk/observability_agent/docker/docker-compose.yml b/claude_agent_sdk/observability_agent/docker/docker-compose.yml similarity index 100% rename from claude_code_sdk/observability_agent/docker/docker-compose.yml rename to claude_agent_sdk/observability_agent/docker/docker-compose.yml diff --git a/claude_code_sdk/pyproject.toml b/claude_agent_sdk/pyproject.toml similarity index 88% rename from claude_code_sdk/pyproject.toml rename to claude_agent_sdk/pyproject.toml index 36209b58..35a21ebb 100644 --- a/claude_code_sdk/pyproject.toml +++ b/claude_agent_sdk/pyproject.toml @@ -5,7 +5,7 @@ description = "Add your description here" readme = "README.md" requires-python = ">=3.11" dependencies = [ - "claude-code-sdk>=0.0.20", + "claude-agent-sdk>=0.0.20", "ipykernel>=6.29.5", "mcp-server-git>=2025.1.14", "python-dotenv>=1.1.1", diff --git a/claude_code_sdk/research_agent/agent.py b/claude_agent_sdk/research_agent/agent.py similarity index 94% rename from claude_code_sdk/research_agent/agent.py rename to claude_agent_sdk/research_agent/agent.py index 79fb0290..87ea16bb 100644 --- a/claude_code_sdk/research_agent/agent.py +++ b/claude_agent_sdk/research_agent/agent.py @@ -8,7 +8,7 @@ from dotenv import load_dotenv -from claude_code_sdk import ClaudeCodeOptions, ClaudeSDKClient +from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient load_dotenv() @@ -60,8 +60,8 @@ async def send_query( Returns: The final result text or None if no result """ - options = ClaudeCodeOptions( - model="claude-sonnet-4-20250514", + options = ClaudeAgentOptions( + model="claude-sonnet-4-5", allowed_tools=["WebSearch", "Read"], continue_conversation=continue_conversation, system_prompt="You are a research agent specialized in AI", diff --git a/claude_code_sdk/research_agent/architecture_diagram.md b/claude_agent_sdk/research_agent/architecture_diagram.md similarity index 100% rename from claude_code_sdk/research_agent/architecture_diagram.md rename to claude_agent_sdk/research_agent/architecture_diagram.md diff --git a/claude_code_sdk/research_agent/projects_claude.png b/claude_agent_sdk/research_agent/projects_claude.png similarity index 100% rename from claude_code_sdk/research_agent/projects_claude.png rename to claude_agent_sdk/research_agent/projects_claude.png diff --git a/claude_code_sdk/utils/agent_visualizer.py b/claude_agent_sdk/utils/agent_visualizer.py similarity index 100% rename from claude_code_sdk/utils/agent_visualizer.py rename to claude_agent_sdk/utils/agent_visualizer.py diff --git a/extended_thinking/extended_thinking.ipynb b/extended_thinking/extended_thinking.ipynb index 0d87dc16..ebe5462e 100644 --- a/extended_thinking/extended_thinking.ipynb +++ b/extended_thinking/extended_thinking.ipynb @@ -88,7 +88,7 @@ "def count_tokens(messages):\n", " \"\"\"Count tokens for a given message list.\"\"\"\n", " result = client.messages.count_tokens(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " messages=messages\n", " )\n", " return result.input_tokens" @@ -174,7 +174,7 @@ "source": [ "def basic_thinking_example():\n", " response = client.messages.create(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4000,\n", " thinking= {\n", " \"type\": \"enabled\",\n", @@ -280,7 +280,7 @@ "source": [ "def streaming_with_thinking():\n", " with client.messages.stream(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4000,\n", " thinking={\n", " \"type\": \"enabled\",\n", @@ -403,7 +403,7 @@ " \n", " # Make a request with thinking and check actual usage\n", " response = client.messages.create(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=8000,\n", " thinking = {\n", " \"type\": \"enabled\",\n", @@ -491,7 +491,7 @@ "def redacted_thinking_example():\n", " # Using the special test string that triggers redacted thinking\n", " response = client.messages.create(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4000,\n", " thinking={\n", " \"type\": \"enabled\",\n", @@ -572,7 +572,7 @@ " # 1. Error from setting thinking budget too small\n", " try:\n", " response = client.messages.create(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4000,\n", " thinking={\n", " \"type\": \"enabled\",\n", @@ -589,7 +589,7 @@ " # 2. Error from using temperature with thinking\n", " try:\n", " response = client.messages.create(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4000,\n", " temperature=0.7, # Not compatible with thinking\n", " thinking={\n", @@ -610,7 +610,7 @@ " long_content = \"Please analyze this text. \" + \"This is sample text. \" * 150000\n", " \n", " response = client.messages.create(\n", - " model=\"claude-3-7-sonnet-20250219\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=20000, # This plus the long prompt will exceed context window\n", " thinking={\n", " \"type\": \"enabled\",\n", diff --git a/extended_thinking/extended_thinking_with_tool_use.ipynb b/extended_thinking/extended_thinking_with_tool_use.ipynb index caa70c35..ae7e1393 100644 --- a/extended_thinking/extended_thinking_with_tool_use.ipynb +++ b/extended_thinking/extended_thinking_with_tool_use.ipynb @@ -58,7 +58,7 @@ "import json\n", "\n", "# Global variables for model and token budgets\n", - "MODEL_NAME = \"claude-3-7-sonnet-20250219\"\n", + "MODEL_NAME = \"claude-sonnet-4-5\"\n", "MAX_TOKENS = 4000\n", "THINKING_BUDGET_TOKENS = 2000\n", "\n", @@ -131,7 +131,7 @@ "=== INITIAL RESPONSE ===\n", "Response ID: msg_01NhR4vE9nVh2sHs5fXbzji8\n", "Stop reason: tool_use\n", - "Model: claude-3-7-sonnet-20250219\n", + "Model: claude-sonnet-4-5\n", "Content blocks: 3 blocks\n", "\n", "Block 1: Type = thinking\n", @@ -323,7 +323,7 @@ "=== INITIAL RESPONSE ===\n", "Response ID: msg_01VwqpBMARVoTP1H8Ytvmvsb\n", "Stop reason: tool_use\n", - "Model: claude-3-7-sonnet-20250219\n", + "Model: claude-sonnet-4-5\n", "Content blocks: 3 blocks\n", "\n", "Block 1: Type = thinking\n", diff --git a/finetuning/finetuning_on_bedrock.ipynb b/finetuning/finetuning_on_bedrock.ipynb index 125fc348..a88d85d1 100644 --- a/finetuning/finetuning_on_bedrock.ipynb +++ b/finetuning/finetuning_on_bedrock.ipynb @@ -117,19 +117,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "# Configuration\n", - "job_name = \"anthropic-finetuning-cookbook-training\"\n", - "custom_model_name = \"anthropic_finetuning_cookbook\"\n", - "role = \"YOUR_AWS_SERVICE_ROLE_ARN\"\n", - "output_path = f\"s3://{bucket_name}/finetuning_example_results/\"\n", - "base_model_id = \"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-haiku-20240307-v1:0:200k\"\n", - "\n", - "# Hyperparameters\n", - "epoch_count = 5\n", - "batch_size = 4\n", - "learning_rate_multiplier = 1.0" - ] + "source": "# Configuration\njob_name = \"anthropic-finetuning-cookbook-training\"\ncustom_model_name = \"anthropic_finetuning_cookbook\"\nrole = \"YOUR_AWS_SERVICE_ROLE_ARN\"\noutput_path = f\"s3://{bucket_name}/finetuning_example_results/\"\nbase_model_id = \"arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-haiku-4-5-20251001-v1:0:200k\"\n\n# Hyperparameters\nepoch_count = 5\nbatch_size = 4\nlearning_rate_multiplier = 1.0" }, { "cell_type": "markdown", @@ -261,4 +249,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/misc/batch_processing.ipynb b/misc/batch_processing.ipynb index 28409690..647f6d85 100644 --- a/misc/batch_processing.ipynb +++ b/misc/batch_processing.ipynb @@ -48,7 +48,7 @@ "import time\n", "\n", "client = anthropic.Anthropic()\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"" + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { diff --git a/misc/building_evals.ipynb b/misc/building_evals.ipynb index f9987c74..d5377309 100644 --- a/misc/building_evals.ipynb +++ b/misc/building_evals.ipynb @@ -58,7 +58,7 @@ "source": [ "from anthropic import Anthropic\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, { diff --git a/misc/building_moderation_filter.ipynb b/misc/building_moderation_filter.ipynb index f37fff3b..50759324 100644 --- a/misc/building_moderation_filter.ipynb +++ b/misc/building_moderation_filter.ipynb @@ -60,7 +60,7 @@ "source": [ "from anthropic import Anthropic\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-haiku-20240307\"\n", + "MODEL_NAME = \"claude-haiku-4-5\"\n", "\n", "def moderate_text(user_text, guidelines):\n", " prompt_template = \"\"\"\n", diff --git a/misc/generate_test_cases.ipynb b/misc/generate_test_cases.ipynb index 57f7f3a8..99c5c96f 100644 --- a/misc/generate_test_cases.ipynb +++ b/misc/generate_test_cases.ipynb @@ -54,7 +54,7 @@ "# Enter your API key here\n", "api_key = \"\"\n", "CLIENT = anthropic.Anthropic(api_key=api_key)\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"" + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { diff --git a/misc/how_to_enable_json_mode.ipynb b/misc/how_to_enable_json_mode.ipynb index c314bd03..c9493847 100644 --- a/misc/how_to_enable_json_mode.ipynb +++ b/misc/how_to_enable_json_mode.ipynb @@ -55,7 +55,7 @@ "outputs": [], "source": [ "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, { diff --git a/misc/how_to_make_sql_queries.ipynb b/misc/how_to_make_sql_queries.ipynb index fccaf537..f2311723 100644 --- a/misc/how_to_make_sql_queries.ipynb +++ b/misc/how_to_make_sql_queries.ipynb @@ -41,7 +41,7 @@ "\n", "# Set up the Claude API client\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, { diff --git a/misc/metaprompt.ipynb b/misc/metaprompt.ipynb index 927ea5cd..41cbb447 100644 --- a/misc/metaprompt.ipynb +++ b/misc/metaprompt.ipynb @@ -49,7 +49,7 @@ "source": [ "import anthropic, re\n", "ANTHROPIC_API_KEY = \"\" # Put your API key here!\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"\n", + "MODEL_NAME = \"claude-sonnet-4-5\"\n", "CLIENT = anthropic.Anthropic(api_key=ANTHROPIC_API_KEY)" ] }, @@ -909,7 +909,7 @@ " prompt_with_variables = prompt_with_variables.replace(\"{\" + variable + \"}\", variable_values[variable])\n", "\n", "message = CLIENT.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=4096,\n", " messages=[\n", " {\n", diff --git a/misc/pdf_upload_summarization.ipynb b/misc/pdf_upload_summarization.ipynb index 11ad7778..3df858f7 100644 --- a/misc/pdf_upload_summarization.ipynb +++ b/misc/pdf_upload_summarization.ipynb @@ -62,8 +62,8 @@ " \"anthropic-beta\": \"pdfs-2024-09-25\"\n", " }\n", ")\n", - "# For now, only claude-3-5-sonnet-20241022 supports PDFs\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"" + "# For now, only claude-sonnet-4-5 supports PDFs\n", + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { diff --git a/misc/prompt_caching.ipynb b/misc/prompt_caching.ipynb index 75668e0a..62767603 100644 --- a/misc/prompt_caching.ipynb +++ b/misc/prompt_caching.ipynb @@ -55,7 +55,7 @@ "from bs4 import BeautifulSoup\n", "\n", "client = anthropic.Anthropic()\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"" + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { diff --git a/misc/read_web_pages_with_haiku.ipynb b/misc/read_web_pages_with_haiku.ipynb index b3173245..02feb859 100644 --- a/misc/read_web_pages_with_haiku.ipynb +++ b/misc/read_web_pages_with_haiku.ipynb @@ -39,7 +39,7 @@ "\n", "# Set up the Claude API client\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-haiku-20240229\"" + "MODEL_NAME = \"claude-haiku-4-5\"" ] }, { @@ -116,7 +116,7 @@ ], "source": [ "response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=1024,\n", " messages=messages\n", ")\n", diff --git a/misc/sampling_past_max_tokens.ipynb b/misc/sampling_past_max_tokens.ipynb index 7ebe9cc9..cc1a291c 100644 --- a/misc/sampling_past_max_tokens.ipynb +++ b/misc/sampling_past_max_tokens.ipynb @@ -63,7 +63,7 @@ " api_key=\"YOUR API KEY HERE\",\n", ")\n", "message = client.messages.create(\n", - " model=\"claude-3-sonnet-20240229\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4096,\n", " messages=[\n", " {\n", @@ -304,7 +304,7 @@ ], "source": [ "message2 = client.messages.create(\n", - " model=\"claude-3-sonnet-20240229\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4096,\n", " messages=[\n", " {\n", diff --git a/misc/speculative_prompt_caching.ipynb b/misc/speculative_prompt_caching.ipynb index 8c52f333..43d8fb85 100644 --- a/misc/speculative_prompt_caching.ipynb +++ b/misc/speculative_prompt_caching.ipynb @@ -64,7 +64,7 @@ "from anthropic import AsyncAnthropic\n", "\n", "# Configuration constants\n", - "MODEL = \"claude-3-5-sonnet-20241022\"\n", + "MODEL = \"claude-sonnet-4-5\"\n", "SQLITE_SOURCES = {\n", " \"btree.h\": \"https://sqlite.org/src/raw/18e5e7b2124c23426a283523e5f31a4bff029131b795bb82391f9d2f3136fc50?at=btree.h\",\n", " \"btree.c\": \"https://sqlite.org/src/raw/63ca6b647342e8cef643863cd0962a542f133e1069460725ba4461dcda92b03c?at=btree.c\",\n", diff --git a/misc/using_citations.ipynb b/misc/using_citations.ipynb index 4cf9ebea..b8e278e4 100644 --- a/misc/using_citations.ipynb +++ b/misc/using_citations.ipynb @@ -9,7 +9,7 @@ "The Claude API features citation support that enables Claude to provide detailed citations when answering questions about documents. Citations are a valuable affordance in many LLM powered applications to help users track and verify the sources of information in responses.\n", "\n", "Citations are supported on:\n", - "* `claude-3-5-sonnet-20241022`\n", + "* `claude-sonnet-4-5`\n", "* `claude-3-5-haiku-20241022`\n", "\n", "The citations feature is an alternative to prompt-based citation techniques. Using this featue has the following advantages:\n", @@ -155,7 +155,7 @@ "content = documents \n", "\n", "response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-latest\",\n", + " model=\"claude-sonnet-4-5\",\n", " temperature=0.0,\n", " max_tokens=1024,\n", " system='You are a customer support bot working for PetWorld. Your task is to provide short, helpful answers to user questions. Since you are in a chat interface avoid providing extra details. You will be given access to PetWorld\\'s help center articles to help you answer questions.',\n", @@ -473,7 +473,7 @@ " pdf_data = base64.b64encode(f.read()).decode()\n", "\n", "pdf_response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-latest\",\n", + " model=\"claude-sonnet-4-5\",\n", " temperature=0.0,\n", " max_tokens=1024,\n", " messages=[\n", @@ -584,7 +584,7 @@ "QUESTION = \"I just checked out, where is my order tracking number? Track package is not available on the website yet for my order.\"\n", "\n", "custom_content_response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-latest\",\n", + " model=\"claude-sonnet-4-5\",\n", " temperature=0.0,\n", " max_tokens=1024,\n", " system='You are a customer support bot working for PetWorld. Your task is to provide short, helpful answers to user questions. Since you are in a chat interface avoid providing extra details. You will be given access to PetWorld\\'s help center articles to help you answer questions.',\n", @@ -724,7 +724,7 @@ "QUESTION = \"How does PetWorld's loyalty program work? When do points expire?\"\n", "\n", "context_response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-latest\",\n", + " model=\"claude-sonnet-4-5\",\n", " temperature=0.0,\n", " max_tokens=1024,\n", " messages=[\n", @@ -824,7 +824,7 @@ " pdf_data = base64.b64encode(f.read()).decode()\n", "\n", "response = client.messages.create(\n", - " model=\"claude-3-5-sonnet-latest\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=1024,\n", " temperature=0,\n", " messages=[\n", diff --git a/multimodal/best_practices_for_vision.ipynb b/multimodal/best_practices_for_vision.ipynb index 18675670..5b8ae644 100644 --- a/multimodal/best_practices_for_vision.ipynb +++ b/multimodal/best_practices_for_vision.ipynb @@ -29,7 +29,7 @@ "from IPython.display import Image\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"\n", + "MODEL_NAME = \"claude-opus-4-1\"\n", "\n", "def get_base64_encoded_image(image_path):\n", " with open(image_path, \"rb\") as image_file:\n", diff --git a/multimodal/getting_started_with_vision.ipynb b/multimodal/getting_started_with_vision.ipynb index 16f8d410..7741f9f2 100644 --- a/multimodal/getting_started_with_vision.ipynb +++ b/multimodal/getting_started_with_vision.ipynb @@ -74,7 +74,7 @@ "from anthropic import Anthropic\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"\n", + "MODEL_NAME = \"claude-opus-4-1\"\n", "\n", "with open(\"../images/sunset.jpeg\", \"rb\") as image_file:\n", " binary_data = image_file.read()\n", diff --git a/multimodal/how_to_transcribe_text.ipynb b/multimodal/how_to_transcribe_text.ipynb index 21063eb9..9d398d7c 100644 --- a/multimodal/how_to_transcribe_text.ipynb +++ b/multimodal/how_to_transcribe_text.ipynb @@ -27,7 +27,7 @@ "import base64\n", "from anthropic import Anthropic\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"\n", + "MODEL_NAME = \"claude-opus-4-1\"\n", "\n", "def get_base64_encoded_image(image_path):\n", " with open(image_path, \"rb\") as image_file:\n", diff --git a/multimodal/reading_charts_graphs_powerpoints.ipynb b/multimodal/reading_charts_graphs_powerpoints.ipynb index 834e1da2..58339772 100644 --- a/multimodal/reading_charts_graphs_powerpoints.ipynb +++ b/multimodal/reading_charts_graphs_powerpoints.ipynb @@ -29,7 +29,7 @@ "### Ingestion and calling the Claude API\n", "The best way to pass Claude charts and graphs is to take advantage of its vision capabilities and the PDF support feature. That is, give Claude a PDF document of the chart or graph, along with a text question about it.\n", "\n", - "At the moment, only `claude-3-5-sonnet-20241022` supports the PDF feature. Since the feature is still in beta, you will need to provide it with the `pdfs-2024-09-25` beta header." + "At the moment, only `claude-sonnet-4-5` supports the PDF feature. Since the feature is still in beta, you will need to provide it with the `pdfs-2024-09-25` beta header." ] }, { @@ -63,8 +63,8 @@ " \"anthropic-beta\": \"pdfs-2024-09-25\"\n", " }\n", ")\n", - "# For now, only claude-3-5-sonnet-20241022 supports PDFs\n", - "MODEL_NAME = \"claude-3-5-sonnet-20241022\"" + "# For now, only claude-sonnet-4-5 supports PDFs\n", + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { diff --git a/multimodal/using_sub_agents.ipynb b/multimodal/using_sub_agents.ipynb index 3310a074..b4122423 100644 --- a/multimodal/using_sub_agents.ipynb +++ b/multimodal/using_sub_agents.ipynb @@ -44,7 +44,7 @@ "\n", "# Set up the Claude API client\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-haiku-20240229\"" + "MODEL_NAME = \"claude-haiku-4-5\"" ] }, { @@ -196,7 +196,7 @@ " ]\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-opus-20240229\",\n", + " model=\"claude-opus-4-1\",\n", " max_tokens=2048,\n", " messages=messages\n", " )\n", @@ -285,7 +285,7 @@ " ]\n", " \n", " response = client.messages.create(\n", - " model=\"claude-3-haiku-20240307\",\n", + " model=\"claude-haiku-4-5\",\n", " max_tokens=2048,\n", " messages=messages\n", " )\n", @@ -381,7 +381,7 @@ "\n", "# Generate the matplotlib code using the powerful model\n", "response = client.messages.create(\n", - " model=\"claude-3-opus-20240229\",\n", + " model=\"claude-opus-4-1\",\n", " max_tokens=4096,\n", " messages=messages\n", ")\n", diff --git a/observability/usage_cost_api.ipynb b/observability/usage_cost_api.ipynb index f97eacf4..0eca3670 100644 --- a/observability/usage_cost_api.ipynb +++ b/observability/usage_cost_api.ipynb @@ -403,11 +403,11 @@ "text": [ "πŸ“Š Usage by Model:\n", " claude-3-5-haiku-20241022: 995,781 tokens\n", - " claude-3-5-sonnet-20241022: 861,880 tokens\n", - " claude-3-opus-20240229: 394,646 tokens\n", - " claude-sonnet-4-20250514: 356,766 tokens\n", + " claude-sonnet-4-5: 861,880 tokens\n", + " claude-opus-4-1: 394,646 tokens\n", + " claude-sonnet-4-5: 356,766 tokens\n", " claude-opus-4-20250514: 308,223 tokens\n", - " claude-opus-4-1-20250805: 199,201 tokens\n", + " claude-opus-4-1: 199,201 tokens\n", "Found 7 days of filtered usage data\n" ] } @@ -490,7 +490,7 @@ "timedelta(days=7)).strftime('%Y-%m-%dT%H:%M:%SZ'),\n", " 'ending_at': datetime.combine(datetime.utcnow(),\n", "time.min).strftime('%Y-%m-%dT%H:%M:%SZ'),\n", - " 'models[]': ['claude-3-5-sonnet-20241022'], # Filter to specific model\n", + " 'models[]': ['claude-sonnet-4-5'], # Filter to specific model\n", " 'service_tiers[]': ['standard'], # Filter to standard tier\n", " 'bucket_width': '1d'\n", " }\n", diff --git a/patterns/agents/util.py b/patterns/agents/util.py index 54c372e7..93106399 100644 --- a/patterns/agents/util.py +++ b/patterns/agents/util.py @@ -4,14 +4,14 @@ client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) -def llm_call(prompt: str, system_prompt: str = "", model="claude-3-5-sonnet-20241022") -> str: +def llm_call(prompt: str, system_prompt: str = "", model="claude-sonnet-4-5") -> str: """ Calls the model with the given prompt and returns the response. Args: prompt (str): The user prompt to send to the model. system_prompt (str, optional): The system prompt to send to the model. Defaults to "". - model (str, optional): The model to use for the call. Defaults to "claude-3-5-sonnet-20241022". + model (str, optional): The model to use for the call. Defaults to "claude-sonnet-4-5". Returns: str: The response from the language model. diff --git a/scripts/validate_all_notebooks.py b/scripts/validate_all_notebooks.py index 0008d9a6..777c9b28 100644 --- a/scripts/validate_all_notebooks.py +++ b/scripts/validate_all_notebooks.py @@ -120,12 +120,15 @@ def validate_notebook(self, notebook_path: Path, mode: str = "full") -> dict: # Check for deprecated models deprecated_models = { - "claude-3-5-sonnet-20241022": "claude-3-7-sonnet-latest", - "claude-3-5-sonnet-20240620": "claude-3-7-sonnet-latest", - "claude-3-5-sonnet-latest": "claude-3-7-sonnet-latest", + "claude-3-5-sonnet-20240620": "claude-sonnet-4-5", + "claude-3-5-sonnet-20241022": "claude-sonnet-4-5", + "claude-3-5-sonnet-latest": "claude-sonnet-4-5", + "claude-3-haiku-20240307": "claude-haiku-4-5", + "claude-3-5-haiku-20241022": "claude-haiku-4-5", "claude-3-opus-20240229": "claude-opus-4-1", "claude-3-opus-latest": "claude-opus-4-1", - "claude-3-haiku-20240307": "claude-3-5-haiku-latest" + "claude-sonnet-4-20250514": "claude-sonnet-4-5", + "claude-opus-4-20250514": "claude-opus-4-1" } for i, cell in enumerate(nb.get('cells', [])): @@ -630,12 +633,15 @@ def fix_deprecated_models(self, notebook_path: Path) -> bool: nb = json.load(f) replacements = { - "claude-3-5-sonnet-20241022": "claude-3-7-sonnet-latest", - "claude-3-5-sonnet-20240620": "claude-3-7-sonnet-latest", - "claude-3-5-sonnet-latest": "claude-3-7-sonnet-latest", + "claude-3-5-sonnet-20240620": "claude-sonnet-4-5", + "claude-3-5-sonnet-20241022": "claude-sonnet-4-5", + "claude-3-5-sonnet-latest": "claude-sonnet-4-5", + "claude-3-haiku-20240307": "claude-haiku-4-5", + "claude-3-5-haiku-20241022": "claude-haiku-4-5", "claude-3-opus-20240229": "claude-opus-4-1", "claude-3-opus-latest": "claude-opus-4-1", - "claude-3-haiku-20240307": "claude-3-5-haiku-latest" + "claude-sonnet-4-20250514": "claude-sonnet-4-5", + "claude-opus-4-20250514": "claude-opus-4-1" } modified = False diff --git a/skills/notebooks/01_skills_introduction.ipynb b/skills/notebooks/01_skills_introduction.ipynb index f0a38c19..303650a1 100644 --- a/skills/notebooks/01_skills_introduction.ipynb +++ b/skills/notebooks/01_skills_introduction.ipynb @@ -77,7 +77,7 @@ "load_dotenv(Path.cwd().parent / \".env\")\n", "\n", "API_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\n", - "MODEL = os.getenv(\"ANTHROPIC_MODEL\", \"claude-sonnet-4-5-20250929\")\n", + "MODEL = os.getenv(\"ANTHROPIC_MODEL\", \"claude-sonnet-4-5\")\n", "\n", "if not API_KEY:\n", " raise ValueError(\n", @@ -154,7 +154,7 @@ "```python\n", "# Use client.beta.messages.create() for Skills support\n", "response = client.beta.messages.create(\n", - " model=\"claude-sonnet-4-5-20250929\",\n", + " model=\"claude-sonnet-4-5\",\n", " max_tokens=4096,\n", " container={\n", " \"skills\": [\n", diff --git a/skills/notebooks/02_skills_financial_applications.ipynb b/skills/notebooks/02_skills_financial_applications.ipynb index d686dfc2..6d1fdf36 100644 --- a/skills/notebooks/02_skills_financial_applications.ipynb +++ b/skills/notebooks/02_skills_financial_applications.ipynb @@ -86,7 +86,7 @@ "\n", "# Configuration\n", "API_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\n", - "MODEL = \"claude-sonnet-4-5-20250929\"\n", + "MODEL = \"claude-sonnet-4-5\"\n", "\n", "if not API_KEY:\n", " raise ValueError(\"ANTHROPIC_API_KEY not found. Please configure your .env file.\")\n", diff --git a/skills/notebooks/03_skills_custom_development.ipynb b/skills/notebooks/03_skills_custom_development.ipynb index 99a5c99a..54c70aec 100644 --- a/skills/notebooks/03_skills_custom_development.ipynb +++ b/skills/notebooks/03_skills_custom_development.ipynb @@ -71,7 +71,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": "import json\nimport os\nimport shutil\nimport sys\nfrom datetime import datetime\nfrom pathlib import Path\nfrom typing import Any, Optional\n\n# Add parent directory for imports\nsys.path.insert(0, str(Path.cwd().parent))\n\nfrom anthropic import Anthropic\nfrom anthropic.lib import files_from_dir\nfrom dotenv import load_dotenv\n\n# Import our utilities\nfrom file_utils import (\n download_all_files,\n extract_file_ids,\n get_file_info,\n print_download_summary,\n)\n\n# We'll create skill_utils later in this notebook\n# from skill_utils import (\n# create_skill,\n# list_skills,\n# delete_skill,\n# test_skill\n# )\n\n# Load environment variables\nload_dotenv(Path.cwd().parent / \".env\")\n\nAPI_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\nMODEL = os.getenv(\"ANTHROPIC_MODEL\", \"claude-sonnet-4-5-20250929\")\n\nif not API_KEY:\n raise ValueError(\n \"ANTHROPIC_API_KEY not found. \"\n \"Copy ../.env.example to ../.env and add your API key.\"\n )\n\n# Initialize client with Skills beta\nclient = Anthropic(\n api_key=API_KEY, default_headers={\"anthropic-beta\": \"skills-2025-10-02\"}\n)\n\n# Setup directories\nSKILLS_DIR = Path.cwd().parent / \"custom_skills\"\nOUTPUT_DIR = Path.cwd().parent / \"outputs\"\nOUTPUT_DIR.mkdir(exist_ok=True)\n\nprint(\"βœ“ API key loaded\")\nprint(f\"βœ“ Using model: {MODEL}\")\nprint(f\"βœ“ Custom skills directory: {SKILLS_DIR}\")\nprint(f\"βœ“ Output directory: {OUTPUT_DIR}\")\nprint(\"\\nπŸ“ Skills beta header configured for skill management\")" + "source": "import json\nimport os\nimport shutil\nimport sys\nfrom datetime import datetime\nfrom pathlib import Path\nfrom typing import Any, Optional\n\n# Add parent directory for imports\nsys.path.insert(0, str(Path.cwd().parent))\n\nfrom anthropic import Anthropic\nfrom anthropic.lib import files_from_dir\nfrom dotenv import load_dotenv\n\n# Import our utilities\nfrom file_utils import (\n download_all_files,\n extract_file_ids,\n get_file_info,\n print_download_summary,\n)\n\n# We'll create skill_utils later in this notebook\n# from skill_utils import (\n# create_skill,\n# list_skills,\n# delete_skill,\n# test_skill\n# )\n\n# Load environment variables\nload_dotenv(Path.cwd().parent / \".env\")\n\nAPI_KEY = os.getenv(\"ANTHROPIC_API_KEY\")\nMODEL = os.getenv(\"ANTHROPIC_MODEL\", \"claude-sonnet-4-5\")\n\nif not API_KEY:\n raise ValueError(\n \"ANTHROPIC_API_KEY not found. \"\n \"Copy ../.env.example to ../.env and add your API key.\"\n )\n\n# Initialize client with Skills beta\nclient = Anthropic(\n api_key=API_KEY, default_headers={\"anthropic-beta\": \"skills-2025-10-02\"}\n)\n\n# Setup directories\nSKILLS_DIR = Path.cwd().parent / \"custom_skills\"\nOUTPUT_DIR = Path.cwd().parent / \"outputs\"\nOUTPUT_DIR.mkdir(exist_ok=True)\n\nprint(\"βœ“ API key loaded\")\nprint(f\"βœ“ Using model: {MODEL}\")\nprint(f\"βœ“ Custom skills directory: {SKILLS_DIR}\")\nprint(f\"βœ“ Output directory: {OUTPUT_DIR}\")\nprint(\"\\nπŸ“ Skills beta header configured for skill management\")" }, { "cell_type": "markdown", @@ -92,7 +92,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": "def create_skill(\n client: Anthropic, skill_path: str, display_title: str\n) -> dict[str, Any]:\n \"\"\"\n Create a new custom skill from a directory.\n\n Args:\n client: Anthropic client instance\n skill_path: Path to skill directory\n display_title: Human-readable skill name\n\n Returns:\n Dictionary with skill_id, version, and metadata\n \"\"\"\n try:\n # Create skill using files_from_dir\n skill = client.beta.skills.create(\n display_title=display_title, files=files_from_dir(skill_path)\n )\n\n return {\n \"success\": True,\n \"skill_id\": skill.id,\n \"display_title\": skill.display_title,\n \"latest_version\": skill.latest_version,\n \"created_at\": skill.created_at,\n \"source\": skill.source,\n }\n except Exception as e:\n return {\"success\": False, \"error\": str(e)}\n\n\ndef list_custom_skills(client: Anthropic) -> list[dict[str, Any]]:\n \"\"\"\n List all custom skills in the workspace.\n\n Returns:\n List of skill dictionaries\n \"\"\"\n try:\n skills_response = client.beta.skills.list(source=\"custom\")\n\n skills = []\n for skill in skills_response.data:\n skills.append(\n {\n \"skill_id\": skill.id,\n \"display_title\": skill.display_title,\n \"latest_version\": skill.latest_version,\n \"created_at\": skill.created_at,\n \"updated_at\": skill.updated_at,\n }\n )\n\n return skills\n except Exception as e:\n print(f\"Error listing skills: {e}\")\n return []\n\n\ndef delete_skill(client: Anthropic, skill_id: str) -> bool:\n \"\"\"\n Delete a custom skill and all its versions.\n\n Args:\n client: Anthropic client\n skill_id: ID of skill to delete\n\n Returns:\n True if successful, False otherwise\n \"\"\"\n try:\n # First delete all versions\n versions = client.beta.skills.versions.list(skill_id=skill_id)\n\n for version in versions.data:\n client.beta.skills.versions.delete(\n skill_id=skill_id, version=version.version\n )\n\n # Then delete the skill itself\n client.beta.skills.delete(skill_id)\n return True\n\n except Exception as e:\n print(f\"Error deleting skill: {e}\")\n return False\n\n\ndef test_skill(\n client: Anthropic,\n skill_id: str,\n test_prompt: str,\n model: str = \"claude-sonnet-4-5-20250929\",\n) -> Any:\n \"\"\"\n Test a custom skill with a prompt.\n\n Args:\n client: Anthropic client\n skill_id: ID of skill to test\n test_prompt: Prompt to test the skill\n model: Model to use for testing\n\n Returns:\n Response from Claude\n \"\"\"\n response = client.beta.messages.create(\n model=model,\n max_tokens=4096,\n container={\n \"skills\": [{\"type\": \"custom\", \"skill_id\": skill_id, \"version\": \"latest\"}]\n },\n tools=[{\"type\": \"code_execution_20250825\", \"name\": \"code_execution\"}],\n messages=[{\"role\": \"user\", \"content\": test_prompt}],\n betas=[\n \"code-execution-2025-08-25\",\n \"files-api-2025-04-14\",\n \"skills-2025-10-02\",\n ],\n )\n\n return response\n\n\nprint(\"βœ“ Skill utility functions defined\")\nprint(\" - create_skill()\")\nprint(\" - list_custom_skills()\")\nprint(\" - delete_skill()\")\nprint(\" - test_skill()\")" + "source": "def create_skill(\n client: Anthropic, skill_path: str, display_title: str\n) -> dict[str, Any]:\n \"\"\"\n Create a new custom skill from a directory.\n\n Args:\n client: Anthropic client instance\n skill_path: Path to skill directory\n display_title: Human-readable skill name\n\n Returns:\n Dictionary with skill_id, version, and metadata\n \"\"\"\n try:\n # Create skill using files_from_dir\n skill = client.beta.skills.create(\n display_title=display_title, files=files_from_dir(skill_path)\n )\n\n return {\n \"success\": True,\n \"skill_id\": skill.id,\n \"display_title\": skill.display_title,\n \"latest_version\": skill.latest_version,\n \"created_at\": skill.created_at,\n \"source\": skill.source,\n }\n except Exception as e:\n return {\"success\": False, \"error\": str(e)}\n\n\ndef list_custom_skills(client: Anthropic) -> list[dict[str, Any]]:\n \"\"\"\n List all custom skills in the workspace.\n\n Returns:\n List of skill dictionaries\n \"\"\"\n try:\n skills_response = client.beta.skills.list(source=\"custom\")\n\n skills = []\n for skill in skills_response.data:\n skills.append(\n {\n \"skill_id\": skill.id,\n \"display_title\": skill.display_title,\n \"latest_version\": skill.latest_version,\n \"created_at\": skill.created_at,\n \"updated_at\": skill.updated_at,\n }\n )\n\n return skills\n except Exception as e:\n print(f\"Error listing skills: {e}\")\n return []\n\n\ndef delete_skill(client: Anthropic, skill_id: str) -> bool:\n \"\"\"\n Delete a custom skill and all its versions.\n\n Args:\n client: Anthropic client\n skill_id: ID of skill to delete\n\n Returns:\n True if successful, False otherwise\n \"\"\"\n try:\n # First delete all versions\n versions = client.beta.skills.versions.list(skill_id=skill_id)\n\n for version in versions.data:\n client.beta.skills.versions.delete(\n skill_id=skill_id, version=version.version\n )\n\n # Then delete the skill itself\n client.beta.skills.delete(skill_id)\n return True\n\n except Exception as e:\n print(f\"Error deleting skill: {e}\")\n return False\n\n\ndef test_skill(\n client: Anthropic,\n skill_id: str,\n test_prompt: str,\n model: str = \"claude-sonnet-4-5\",\n) -> Any:\n \"\"\"\n Test a custom skill with a prompt.\n\n Args:\n client: Anthropic client\n skill_id: ID of skill to test\n test_prompt: Prompt to test the skill\n model: Model to use for testing\n\n Returns:\n Response from Claude\n \"\"\"\n response = client.beta.messages.create(\n model=model,\n max_tokens=4096,\n container={\n \"skills\": [{\"type\": \"custom\", \"skill_id\": skill_id, \"version\": \"latest\"}]\n },\n tools=[{\"type\": \"code_execution_20250825\", \"name\": \"code_execution\"}],\n messages=[{\"role\": \"user\", \"content\": test_prompt}],\n betas=[\n \"code-execution-2025-08-25\",\n \"files-api-2025-04-14\",\n \"skills-2025-10-02\",\n ],\n )\n\n return response\n\n\nprint(\"βœ“ Skill utility functions defined\")\nprint(\" - create_skill()\")\nprint(\" - list_custom_skills()\")\nprint(\" - delete_skill()\")\nprint(\" - test_skill()\")" }, { "cell_type": "markdown", diff --git a/skills/skill_utils.py b/skills/skill_utils.py index 9d3ded9b..5bc89c71 100644 --- a/skills/skill_utils.py +++ b/skills/skill_utils.py @@ -246,7 +246,7 @@ def test_skill( client: Anthropic, skill_id: str, test_prompt: str, - model: str = "claude-sonnet-4-5-20250929", + model: str = "claude-sonnet-4-5", include_anthropic_skills: Optional[List[str]] = None ) -> Any: """ diff --git a/third_party/Deepgram/prerecorded_audio.ipynb b/third_party/Deepgram/prerecorded_audio.ipynb index 24a28946..31290186 100644 --- a/third_party/Deepgram/prerecorded_audio.ipynb +++ b/third_party/Deepgram/prerecorded_audio.ipynb @@ -242,7 +242,7 @@ "\n", "# Generate thoughtful, open-ended interview questions\n", "response = client.messages.create(\n", - " model=\"claude-3-opus-20240229\",\n", + " model=\"claude-opus-4-1\",\n", " max_tokens=1000,\n", " temperature=0.5,\n", " system=\"Your task is to generate a series of thoughtful, open-ended questions for an interview based on the given context. The questions should be designed to elicit insightful and detailed responses from the interviewee, allowing them to showcase their knowledge, experience, and critical thinking skills. Avoid yes/no questions or those with obvious answers. Instead, focus on questions that encourage reflection, self-assessment, and the sharing of specific examples or anecdotes.\",\n", diff --git a/third_party/LlamaIndex/Basic_RAG_With_LlamaIndex.ipynb b/third_party/LlamaIndex/Basic_RAG_With_LlamaIndex.ipynb index ca99acb3..07cf2789 100644 --- a/third_party/LlamaIndex/Basic_RAG_With_LlamaIndex.ipynb +++ b/third_party/LlamaIndex/Basic_RAG_With_LlamaIndex.ipynb @@ -177,7 +177,7 @@ } ], "source": [ - "llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229')\n", + "llm = Anthropic(temperature=0.0, model='claude-opus-4-1')\n", "embed_model = HuggingFaceEmbedding(model_name=\"BAAI/bge-base-en-v1.5\")" ] }, diff --git a/third_party/LlamaIndex/Multi_Document_Agents.ipynb b/third_party/LlamaIndex/Multi_Document_Agents.ipynb index 6d982718..2d72594b 100644 --- a/third_party/LlamaIndex/Multi_Document_Agents.ipynb +++ b/third_party/LlamaIndex/Multi_Document_Agents.ipynb @@ -203,7 +203,7 @@ }, "outputs": [], "source": [ - "llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229')\n", + "llm = Anthropic(temperature=0.0, model='claude-opus-4-1')\n", "embed_model = HuggingFaceEmbedding(model_name=\"BAAI/bge-base-en-v1.5\")" ] }, diff --git a/third_party/LlamaIndex/ReAct_Agent.ipynb b/third_party/LlamaIndex/ReAct_Agent.ipynb index 6f4ce871..881d410c 100644 --- a/third_party/LlamaIndex/ReAct_Agent.ipynb +++ b/third_party/LlamaIndex/ReAct_Agent.ipynb @@ -171,7 +171,7 @@ }, "outputs": [], "source": [ - "llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229')\n", + "llm = Anthropic(temperature=0.0, model='claude-opus-4-1')\n", "embed_model = HuggingFaceEmbedding(model_name=\"BAAI/bge-base-en-v1.5\")" ] }, diff --git a/third_party/LlamaIndex/Router_Query_Engine.ipynb b/third_party/LlamaIndex/Router_Query_Engine.ipynb index d08397bd..e1a7f5c0 100644 --- a/third_party/LlamaIndex/Router_Query_Engine.ipynb +++ b/third_party/LlamaIndex/Router_Query_Engine.ipynb @@ -203,7 +203,7 @@ }, "outputs": [], "source": [ - "llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229')\n", + "llm = Anthropic(temperature=0.0, model='claude-opus-4-1')\n", "embed_model = HuggingFaceEmbedding(model_name=\"BAAI/bge-base-en-v1.5\")" ] }, diff --git a/third_party/LlamaIndex/SubQuestion_Query_Engine.ipynb b/third_party/LlamaIndex/SubQuestion_Query_Engine.ipynb index a965fae5..8c2e90c4 100644 --- a/third_party/LlamaIndex/SubQuestion_Query_Engine.ipynb +++ b/third_party/LlamaIndex/SubQuestion_Query_Engine.ipynb @@ -160,7 +160,7 @@ }, "outputs": [], "source": [ - "llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229')\n", + "llm = Anthropic(temperature=0.0, model='claude-opus-4-1')\n", "embed_model = HuggingFaceEmbedding(model_name=\"BAAI/bge-base-en-v1.5\")" ] }, diff --git a/third_party/MongoDB/rag_using_mongodb.ipynb b/third_party/MongoDB/rag_using_mongodb.ipynb index 227ba9a6..16a1f557 100644 --- a/third_party/MongoDB/rag_using_mongodb.ipynb +++ b/third_party/MongoDB/rag_using_mongodb.ipynb @@ -457,7 +457,7 @@ "\n", "- Accept a user query in the form of a string.\n", "- Utilize the VoyageAI embedding model to generate embeddings for the user query.\n", - "- Load the Anthropic Claude 3, specifically the β€˜claude-3-opus-20240229’ model, to serve as the base model for the RAG system.\n", + "- Load the Anthropic Claude 3, specifically the β€˜claude-opus-4-1’ model, to serve as the base model for the RAG system.\n", "- Execute a vector search using the embeddings of the user query to fetch relevant information from the knowledge base, which provides additional context for the base model.\n", "- Submit both the user query and the gathered additional information to the base model to generate a response.\n", "\n", @@ -493,7 +493,7 @@ "1. Vector Search Execution: The function begins by calling `vector_search` with the user's query and a specified collection as arguments. This performs a search within the collection, leveraging vector embeddings to find relevant information related to the query.\n", "2. Compile Search Results: `search_result` is initialized as an empty string to aggregate information from the search. The search results are compiled by iterating over the results returned by the `vector_search` function, formates each item's details (title, company name, URL, publication date, article URL, and description) into a human-readable string, appending this information to search_result with a newline character \\n at the end of each entry.\n", "3. Generate Response Using Anthropic Client: The function then constructs a request to the Claude API (through a client object, presumably an instance of the anthropic. Client class created earlier). It specifies:\n", - "- The model to use (\"claude-3-opus-20240229\") indicates a specific version of the Claude 3 model.\n", + "- The model to use (\"claude-opus-4-1\") indicates a specific version of the Claude 3 model.\n", "- The maximum token limit for the generated response (max_tokens=1024).\n", "- A system description guides the model to behave as a \"Venture Capital Tech Analyst\" with access to tech company articles and information, using this context to advise.\n", "- The actual message for the model to process combines the user query with the aggregated search results as context.\n", @@ -524,7 +524,7 @@ " )\n", "\n", " response = client.messages.create(\n", - " model=\"claude-3-opus-20240229\",\n", + " model=\"claude-opus-4-1\",\n", " max_tokens=1024,\n", " system=\"You are Venture Captital Tech Analyst with access to some tech company articles and information. You use the information you are given to provide advice.\",\n", " messages=[\n", diff --git a/third_party/Pinecone/claude_3_rag_agent.ipynb b/third_party/Pinecone/claude_3_rag_agent.ipynb index f510e071..dbfd4306 100644 --- a/third_party/Pinecone/claude_3_rag_agent.ipynb +++ b/third_party/Pinecone/claude_3_rag_agent.ipynb @@ -700,7 +700,7 @@ "# chat completion llm\n", "llm = ChatAnthropic(\n", " ANTHROPIC_API_KEY=ANTHROPIC_API_KEY,\n", - " model_name=\"claude-3-opus-20240229\", # change \"opus\" -> \"sonnet\" for speed\n", + " model_name=\"claude-opus-4-1\", # change \"opus\" -> \"sonnet\" for speed\n", " temperature=0.0\n", ")" ] diff --git a/tool_evaluation/tool_evaluation.ipynb b/tool_evaluation/tool_evaluation.ipynb index 84030788..78994921 100644 --- a/tool_evaluation/tool_evaluation.ipynb +++ b/tool_evaluation/tool_evaluation.ipynb @@ -89,7 +89,7 @@ "outputs": [], "source": [ "client = Anthropic()\n", - "model = \"claude-3-7-sonnet-20250219\"\n", + "model = \"claude-sonnet-4-5\"\n", "\n", "\n", "def agent_loop(\n", diff --git a/tool_use/.env.example b/tool_use/.env.example index 333d0a50..ac89a5a5 100644 --- a/tool_use/.env.example +++ b/tool_use/.env.example @@ -5,10 +5,8 @@ ANTHROPIC_API_KEY=your_api_key_here # Model name - Use a model that supports memory_20250818 tool -# Supported models (as of launch): -# - claude-sonnet-4-20250514 -# - claude-opus-4-20250514 -# - claude-opus-4-1-20250805 -# - claude-sonnet-4-5-20250929 +# Supported models: +# - claude-opus-4-1 +# - claude-sonnet-4-5 -ANTHROPIC_MODEL=claude-sonnet-4-5-20250929 \ No newline at end of file +ANTHROPIC_MODEL=claude-sonnet-4-5 \ No newline at end of file diff --git a/tool_use/calculator_tool.ipynb b/tool_use/calculator_tool.ipynb index 6cb1942b..7e7942a5 100644 --- a/tool_use/calculator_tool.ipynb +++ b/tool_use/calculator_tool.ipynb @@ -35,7 +35,7 @@ "from anthropic import Anthropic\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, { diff --git a/tool_use/customer_service_agent.ipynb b/tool_use/customer_service_agent.ipynb index 43d9efa7..00107f8f 100644 --- a/tool_use/customer_service_agent.ipynb +++ b/tool_use/customer_service_agent.ipynb @@ -36,7 +36,7 @@ "import anthropic\n", "\n", "client = anthropic.Client()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, { diff --git a/tool_use/extracting_structured_json.ipynb b/tool_use/extracting_structured_json.ipynb index 08a9fbdc..4818ccea 100644 --- a/tool_use/extracting_structured_json.ipynb +++ b/tool_use/extracting_structured_json.ipynb @@ -41,7 +41,7 @@ "import json\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-haiku-20240307\"" + "MODEL_NAME = \"claude-haiku-4-5\"" ] }, { diff --git a/tool_use/memory_cookbook.ipynb b/tool_use/memory_cookbook.ipynb index e409cfed..d46b6e92 100644 --- a/tool_use/memory_cookbook.ipynb +++ b/tool_use/memory_cookbook.ipynb @@ -101,36 +101,7 @@ { "cell_type": "markdown", "metadata": {}, - "source": [ - "## 2. Use Cases {#use-cases}\n", - "\n", - "Memory and context management enable powerful new workflows:\n", - "\n", - "### πŸ” Code Review Assistant\n", - "- Learns debugging patterns from past reviews\n", - "- Recognizes similar bugs instantly in future sessions\n", - "- Builds team-specific code quality knowledge\n", - "- **Production ready**: Integrate with [claude-code-action](https://github.com/anthropics/claude-code-action) for GitHub PR reviews\n", - "\n", - "### πŸ“š Research Assistant\n", - "- Accumulates knowledge on topics over multiple sessions\n", - "- Connects insights across different research threads\n", - "- Maintains bibliography and source tracking\n", - "\n", - "### πŸ’¬ Customer Support Bot\n", - "- Learns user preferences and communication style\n", - "- Remembers common issues and solutions\n", - "- Builds product knowledge base from interactions\n", - "\n", - "### πŸ“Š Data Analysis Helper\n", - "- Remembers dataset patterns and anomalies\n", - "- Stores analysis techniques that work well\n", - "- Builds domain-specific insights over time\n", - "\n", - "**Supported Models**: Claude Opus 4 (`claude-opus-4-20250514`), Claude Opus 4.1 (`claude-opus-4-1-20250805`), Claude Sonnet 4 (`claude-sonnet-4-20250514`), and Claude Sonnet 4.5 (`claude-sonnet-4-5-20250929`)\n", - "\n", - "**This cookbook focuses on the Code Review Assistant** as it clearly demonstrates both memory (learning patterns) and context editing (handling long reviews)." - ] + "source": "## 2. Use Cases {#use-cases}\n\nMemory and context management enable powerful new workflows:\n\n### πŸ” Code Review Assistant\n- Learns debugging patterns from past reviews\n- Recognizes similar bugs instantly in future sessions\n- Builds team-specific code quality knowledge\n- **Production ready**: Integrate with [claude-code-action](https://github.com/anthropics/claude-code-action) for GitHub PR reviews\n\n### πŸ“š Research Assistant\n- Accumulates knowledge on topics over multiple sessions\n- Connects insights across different research threads\n- Maintains bibliography and source tracking\n\n### πŸ’¬ Customer Support Bot\n- Learns user preferences and communication style\n- Remembers common issues and solutions\n- Builds product knowledge base from interactions\n\n### πŸ“Š Data Analysis Helper\n- Remembers dataset patterns and anomalies\n- Stores analysis techniques that work well\n- Builds domain-specific insights over time\n\n**Supported Models**: Claude Opus 4.1 (`claude-opus-4-1`) and Claude Sonnet 4.5 (`claude-sonnet-4-5`)\n\n**This cookbook focuses on the Code Review Assistant** as it clearly demonstrates both memory (learning patterns) and context editing (handling long reviews)." }, { "cell_type": "markdown", @@ -199,7 +170,7 @@ "output_type": "stream", "text": [ "βœ“ API key loaded\n", - "βœ“ Using model: claude-sonnet-4-5-20250929\n" + "βœ“ Using model: claude-sonnet-4-5\n" ] } ], diff --git a/tool_use/parallel_tools_claude_3_7_sonnet.ipynb b/tool_use/parallel_tools.ipynb similarity index 99% rename from tool_use/parallel_tools_claude_3_7_sonnet.ipynb rename to tool_use/parallel_tools.ipynb index bb3df9e7..66cfcd89 100644 --- a/tool_use/parallel_tools_claude_3_7_sonnet.ipynb +++ b/tool_use/parallel_tools.ipynb @@ -25,7 +25,7 @@ "from anthropic import Anthropic\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-7-sonnet-20250219\"" + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { diff --git a/tool_use/tool_choice.ipynb b/tool_use/tool_choice.ipynb index f5c35663..3037d2cc 100644 --- a/tool_use/tool_choice.ipynb +++ b/tool_use/tool_choice.ipynb @@ -30,7 +30,7 @@ "source": [ "from anthropic import Anthropic\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-sonnet-20240229\"" + "MODEL_NAME = \"claude-sonnet-4-5\"" ] }, { @@ -333,7 +333,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "ToolsBetaMessage(id='msg_staging_01ApgXx7W7qsDugdaRWh6p21', content=[TextBlock(text=\"That's great to hear! I don't actually have the capability to assess sentiment from text, but it sounds like you're really excited and proud of the incredible meal you made. Cooking something delicious that you're proud of can definitely give a sense of accomplishment and happiness. Well done on creating such an amazing dish!\", type='text')], model='claude-3-sonnet-20240229', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=429, output_tokens=69))\n" + "ToolsBetaMessage(id='msg_staging_01ApgXx7W7qsDugdaRWh6p21', content=[TextBlock(text=\"That's great to hear! I don't actually have the capability to assess sentiment from text, but it sounds like you're really excited and proud of the incredible meal you made. Cooking something delicious that you're proud of can definitely give a sense of accomplishment and happiness. Well done on creating such an amazing dish!\", type='text')], model='claude-sonnet-4-5', role='assistant', stop_reason='end_turn', stop_sequence=None, type='message', usage=Usage(input_tokens=429, output_tokens=69))\n" ] } ], @@ -360,7 +360,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "ToolsBetaMessage(id='msg_staging_018gTrwrx6YwBR2jjhdPooVg', content=[TextBlock(text=\"That's wonderful that you love your cats and adopted two more! To figure out how many cats you have now, I can use the calculator tool:\", type='text'), ToolUseBlock(id='toolu_staging_01RFker5oMQoY6jErz5prmZg', input={'num1': 4, 'num2': 2}, name='calculator', type='tool_use')], model='claude-3-sonnet-20240229', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=442, output_tokens=101))\n" + "ToolsBetaMessage(id='msg_staging_018gTrwrx6YwBR2jjhdPooVg', content=[TextBlock(text=\"That's wonderful that you love your cats and adopted two more! To figure out how many cats you have now, I can use the calculator tool:\", type='text'), ToolUseBlock(id='toolu_staging_01RFker5oMQoY6jErz5prmZg', input={'num1': 4, 'num2': 2}, name='calculator', type='tool_use')], model='claude-sonnet-4-5', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=442, output_tokens=101))\n" ] } ], @@ -425,7 +425,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "ToolsBetaMessage(id='msg_staging_018GtYk8Xvee3w8Eeh6pbgoq', content=[ToolUseBlock(id='toolu_staging_01FMRQ9pZniZqFUGQwTcFU4N', input={'positive_score': 0.9, 'negative_score': 0.0, 'neutral_score': 0.1}, name='print_sentiment_scores', type='tool_use')], model='claude-3-sonnet-20240229', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=527, output_tokens=79))\n" + "ToolsBetaMessage(id='msg_staging_018GtYk8Xvee3w8Eeh6pbgoq', content=[ToolUseBlock(id='toolu_staging_01FMRQ9pZniZqFUGQwTcFU4N', input={'positive_score': 0.9, 'negative_score': 0.0, 'neutral_score': 0.1}, name='print_sentiment_scores', type='tool_use')], model='claude-sonnet-4-5', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=527, output_tokens=79))\n" ] } ], @@ -453,7 +453,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "ToolsBetaMessage(id='msg_staging_01RACamfrHdpvLxWaNwDfZEF', content=[ToolUseBlock(id='toolu_staging_01Wb6ZKSwKvqVSKLDAte9cKU', input={'positive_score': 0.8, 'negative_score': 0.0, 'neutral_score': 0.2}, name='print_sentiment_scores', type='tool_use')], model='claude-3-sonnet-20240229', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=540, output_tokens=79))\n" + "ToolsBetaMessage(id='msg_staging_01RACamfrHdpvLxWaNwDfZEF', content=[ToolUseBlock(id='toolu_staging_01Wb6ZKSwKvqVSKLDAte9cKU', input={'positive_score': 0.8, 'negative_score': 0.0, 'neutral_score': 0.2}, name='print_sentiment_scores', type='tool_use')], model='claude-sonnet-4-5', role='assistant', stop_reason='tool_use', stop_sequence=None, type='message', usage=Usage(input_tokens=540, output_tokens=79))\n" ] } ], diff --git a/tool_use/tool_use_with_pydantic.ipynb b/tool_use/tool_use_with_pydantic.ipynb index 4fcc07a0..678b09a5 100644 --- a/tool_use/tool_use_with_pydantic.ipynb +++ b/tool_use/tool_use_with_pydantic.ipynb @@ -37,7 +37,7 @@ "from typing import Optional\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, { diff --git a/tool_use/vision_with_tools.ipynb b/tool_use/vision_with_tools.ipynb index b4d68596..359e7ab2 100644 --- a/tool_use/vision_with_tools.ipynb +++ b/tool_use/vision_with_tools.ipynb @@ -42,7 +42,7 @@ "import base64\n", "\n", "client = Anthropic()\n", - "MODEL_NAME = \"claude-3-opus-20240229\"" + "MODEL_NAME = \"claude-opus-4-1\"" ] }, {