The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
chore: update references to use the latest version of Claude-3.5 Sonnet (#32594)
Mason Daughertyf69f9598f5f4
diff --git a/docs/docs/how_to/chat_models_universal_init.ipynb b/docs/docs/how_to/chat_models_universal_init.ipynbindex 63e2be0aed..8779a70682 100644--- a/docs/docs/how_to/chat_models_universal_init.ipynb+++ b/docs/docs/how_to/chat_models_universal_init.ipynb@@ -159,7 +159,7 @@},{"cell_type": "code",- "execution_count": 8,+ "execution_count": null,"id": "321e3036-abd2-4e1f-bcc6-606efd036954","metadata": {"execution": {@@ -183,7 +183,7 @@],"source": ["configurable_model.invoke(\n",- " \"what's your name\", config={\"configurable\": {\"model\": \"claude-3-5-sonnet-20240620\"}}\n",+ " \"what's your name\", config={\"configurable\": {\"model\": \"claude-3-5-sonnet-latest\"}}\n",")"]},@@ -234,7 +234,7 @@},{"cell_type": "code",- "execution_count": 7,+ "execution_count": null,"id": "6c8755ba-c001-4f5a-a497-be3f1db83244","metadata": {"execution": {@@ -261,7 +261,7 @@" \"what's your name\",\n"," config={\n"," \"configurable\": {\n",- " \"first_model\": \"claude-3-5-sonnet-20240620\",\n",+ " \"first_model\": \"claude-3-5-sonnet-latest\",\n"," \"first_temperature\": 0.5,\n"," \"first_max_tokens\": 100,\n"," }\n",@@ -336,7 +336,7 @@},{"cell_type": "code",- "execution_count": 9,+ "execution_count": null,"id": "e57dfe9f-cd24-4e37-9ce9-ccf8daf78f89","metadata": {"execution": {@@ -368,14 +368,14 @@"source": ["llm_with_tools.invoke(\n"," \"what's bigger in 2024 LA or NYC\",\n",- " config={\"configurable\": {\"model\": \"claude-3-5-sonnet-20240620\"}},\n",+ " config={\"configurable\": {\"model\": \"claude-3-5-sonnet-latest\"}},\n",").tool_calls"]}],"metadata": {"kernelspec": {- "display_name": "langchain",+ "display_name": "langchain-monorepo","language": "python","name": "python3"},@@ -389,7 +389,7 @@"name": "python","nbconvert_exporter": "python","pygments_lexer": "ipython3",- "version": "3.10.16"+ "version": "3.12.11"}},"nbformat": 4,diff --git a/docs/docs/how_to/tool_artifacts.ipynb b/docs/docs/how_to/tool_artifacts.ipynbindex 58501354ef..ad36d79df8 100644--- a/docs/docs/how_to/tool_artifacts.ipynb+++ b/docs/docs/how_to/tool_artifacts.ipynb@@ -147,7 +147,7 @@},{"cell_type": "code",- "execution_count": 5,+ "execution_count": null,"id": "74de0286-b003-4b48-9cdd-ecab435515ca","metadata": {},"outputs": [],@@ -157,7 +157,7 @@"\n","from langchain_anthropic import ChatAnthropic\n","\n",- "llm = ChatAnthropic(model=\"claude-3-5-sonnet-20240620\", temperature=0)"+ "llm = ChatAnthropic(model=\"claude-3-5-sonnet-latest\", temperature=0)"]},{diff --git a/docs/docs/how_to/tool_stream_events.ipynb b/docs/docs/how_to/tool_stream_events.ipynbindex 55b3b73cbf..02e35fe6b8 100644--- a/docs/docs/how_to/tool_stream_events.ipynb+++ b/docs/docs/how_to/tool_stream_events.ipynb@@ -38,7 +38,7 @@},{"cell_type": "code",- "execution_count": 1,+ "execution_count": null,"metadata": {},"outputs": [],"source": [@@ -53,7 +53,7 @@"if \"ANTHROPIC_API_KEY\" not in os.environ:\n"," os.environ[\"ANTHROPIC_API_KEY\"] = getpass()\n","\n",- "model = ChatAnthropic(model=\"claude-3-5-sonnet-20240620\", temperature=0)"+ "model = ChatAnthropic(model=\"claude-3-5-sonnet-latest\", temperature=0)"]},{diff --git a/docs/docs/integrations/chat/anthropic.ipynb b/docs/docs/integrations/chat/anthropic.ipynbindex bcd6637ce5..380f671284 100644--- a/docs/docs/integrations/chat/anthropic.ipynb+++ b/docs/docs/integrations/chat/anthropic.ipynb@@ -124,7 +124,7 @@},{"cell_type": "code",- "execution_count": 4,+ "execution_count": null,"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae","metadata": {},"outputs": [],@@ -132,7 +132,7 @@"from langchain_anthropic import ChatAnthropic\n","\n","llm = ChatAnthropic(\n",- " model=\"claude-3-5-sonnet-20240620\",\n",+ " model=\"claude-3-5-sonnet-latest\",\n"," temperature=0,\n"," max_tokens=1024,\n"," timeout=None,\n",diff --git a/docs/docs/integrations/chat/bedrock.ipynb b/docs/docs/integrations/chat/bedrock.ipynbindex 504ea2564c..a246357a25 100644--- a/docs/docs/integrations/chat/bedrock.ipynb+++ b/docs/docs/integrations/chat/bedrock.ipynb@@ -129,7 +129,7 @@},{"cell_type": "code",- "execution_count": 1,+ "execution_count": null,"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae","metadata": {},"outputs": [],@@ -137,7 +137,7 @@"from langchain_aws import ChatBedrockConverse\n","\n","llm = ChatBedrockConverse(\n",- " model_id=\"anthropic.claude-3-5-sonnet-20240620-v1:0\",\n",+ " model_id=\"anthropic.claude-3-5-sonnet-latest-v1:0\",\n"," # region_name=...,\n"," # aws_access_key_id=...,\n"," # aws_secret_access_key=...,\n",diff --git a/docs/docs/integrations/tools/stripe.ipynb b/docs/docs/integrations/tools/stripe.ipynbindex 3ae6029e2d..b33aca42b8 100644--- a/docs/docs/integrations/tools/stripe.ipynb+++ b/docs/docs/integrations/tools/stripe.ipynb@@ -153,7 +153,7 @@"from langgraph.prebuilt import create_react_agent\n","\n","llm = ChatAnthropic(\n",- " model=\"claude-3-5-sonnet-20240620\",\n",+ " model=\"claude-3-5-sonnet-latest\",\n",")\n","\n","langgraph_agent_executor = create_react_agent(llm, stripe_agent_toolkit.get_tools())\n",diff --git a/docs/docs/troubleshooting/errors/MESSAGE_COERCION_FAILURE.ipynb b/docs/docs/troubleshooting/errors/MESSAGE_COERCION_FAILURE.ipynbindex c24eae7329..8af0445de9 100644--- a/docs/docs/troubleshooting/errors/MESSAGE_COERCION_FAILURE.ipynb+++ b/docs/docs/troubleshooting/errors/MESSAGE_COERCION_FAILURE.ipynb@@ -45,7 +45,7 @@},{"cell_type": "code",- "execution_count": 5,+ "execution_count": null,"metadata": {},"outputs": [{@@ -74,7 +74,7 @@"\n","uncoercible_message = {\"role\": \"HumanMessage\", \"random_field\": \"random value\"}\n","\n",- "model = ChatAnthropic(model=\"claude-3-5-sonnet-20240620\")\n",+ "model = ChatAnthropic(model=\"claude-3-5-sonnet-latest\")\n","\n","model.invoke([uncoercible_message])"]diff --git a/docs/docs/tutorials/summarization.ipynb b/docs/docs/tutorials/summarization.ipynbindex dc8e3d1b0d..62e867bd3c 100644--- a/docs/docs/tutorials/summarization.ipynb+++ b/docs/docs/tutorials/summarization.ipynb@@ -236,7 +236,7 @@"We can use [create_stuff_documents_chain](https://python.langchain.com/api_reference/langchain/chains/langchain.chains.combine_documents.stuff.create_stuff_documents_chain.html), especially if using larger context window models such as:\n","\n","* 128k token OpenAI `gpt-4o` \n",- "* 200k token Anthropic `claude-3-5-sonnet-20240620`\n",+ "* 200k token Anthropic `claude-3-5-sonnet-latest`\n","\n","The chain will take a list of documents, insert them all into a prompt, and pass that prompt to an LLM:"]diff --git a/libs/langchain/langchain/chat_models/base.py b/libs/langchain/langchain/chat_models/base.pyindex dec9cd9e7a..18ce3418d7 100644--- a/libs/langchain/langchain/chat_models/base.py+++ b/libs/langchain/langchain/chat_models/base.py@@ -230,7 +230,7 @@ def init_chat_model("what's your name",config={"configurable": {- "foo_model": "anthropic:claude-3-5-sonnet-20240620",+ "foo_model": "anthropic:claude-3-5-sonnet-latest","foo_temperature": 0.6}}@@ -272,7 +272,7 @@ def init_chat_model(configurable_model_with_tools.invoke("Which city is hotter today and which is bigger: LA or NY?",- config={"configurable": {"model": "claude-3-5-sonnet-20240620"}}+ config={"configurable": {"model": "claude-3-5-sonnet-latest"}})# Claude-3.5 sonnet response with toolsdiff --git a/libs/langchain_v1/langchain/chat_models/base.py b/libs/langchain_v1/langchain/chat_models/base.pyindex 6a093e0cdf..8c18097cd7 100644--- a/libs/langchain_v1/langchain/chat_models/base.py+++ b/libs/langchain_v1/langchain/chat_models/base.py@@ -224,7 +224,7 @@ def init_chat_model("what's your name",config={"configurable": {- "foo_model": "anthropic:claude-3-5-sonnet-20240620",+ "foo_model": "anthropic:claude-3-5-sonnet-latest","foo_temperature": 0.6}}@@ -266,7 +266,7 @@ def init_chat_model(configurable_model_with_tools.invoke("Which city is hotter today and which is bigger: LA or NY?",- config={"configurable": {"model": "claude-3-5-sonnet-20240620"}}+ config={"configurable": {"model": "claude-3-5-sonnet-latest"}})# Claude-3.5 sonnet response with toolsdiff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.pyindex 09d1868905..66f07c7ffd 100644--- a/libs/partners/anthropic/langchain_anthropic/chat_models.py+++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py@@ -1731,7 +1731,7 @@ class ChatAnthropic(BaseChatModel):product: str = Field(..., description="The product to look up.")- llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", temperature=0)+ llm = ChatAnthropic(model="claude-3-5-sonnet-latest", temperature=0)llm_with_tools = llm.bind_tools([GetWeather, GetPrice])llm_with_tools.invoke("what is the weather like in San Francisco",)# -> AIMessage(@@ -1739,7 +1739,7 @@ class ChatAnthropic(BaseChatModel):# {'text': '<thinking>\nBased on the user\'s question, the relevant function to call is GetWeather, which requires the "location" parameter.\n\nThe user has directly specified the location as "San Francisco". Since San Francisco is a well known city, I can reasonably infer they mean San Francisco, CA without needing the state specified.\n\nAll the required parameters are provided, so I can proceed with the API call.\n</thinking>', 'type': 'text'},# {'text': None, 'type': 'tool_use', 'id': 'toolu_01SCgExKzQ7eqSkMHfygvYuu', 'name': 'GetWeather', 'input': {'location': 'San Francisco, CA'}}# ],- # response_metadata={'id': 'msg_01GM3zQtoFv8jGQMW7abLnhi', 'model': 'claude-3-5-sonnet-20240620', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 487, 'output_tokens': 145}},+ # response_metadata={'id': 'msg_01GM3zQtoFv8jGQMW7abLnhi', 'model': 'claude-3-5-sonnet-latest', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 487, 'output_tokens': 145}},# id='run-87b1331e-9251-4a68-acef-f0a018b639cc-0'# )@@ -1761,7 +1761,7 @@ class ChatAnthropic(BaseChatModel):product: str = Field(..., description="The product to look up.")- llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", temperature=0)+ llm = ChatAnthropic(model="claude-3-5-sonnet-latest", temperature=0)llm_with_tools = llm.bind_tools([GetWeather, GetPrice], tool_choice="any")llm_with_tools.invoke("what is the weather like in San Francisco",)@@ -1784,7 +1784,7 @@ class ChatAnthropic(BaseChatModel):product: str = Field(..., description="The product to look up.")- llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", temperature=0)+ llm = ChatAnthropic(model="claude-3-5-sonnet-latest", temperature=0)llm_with_tools = llm.bind_tools([GetWeather, GetPrice], tool_choice="GetWeather")llm_with_tools.invoke("what is the weather like in San Francisco",)@@ -1816,7 +1816,7 @@ class ChatAnthropic(BaseChatModel):# We need to pass in extra headers to enable use of the beta cache# control API.llm = ChatAnthropic(- model="claude-3-5-sonnet-20240620",+ model="claude-3-5-sonnet-latest",temperature=0,)llm_with_tools = llm.bind_tools([GetWeather, cached_price_tool])@@ -1826,13 +1826,13 @@ class ChatAnthropic(BaseChatModel):.. code-block:: python- AIMessage(content=[{'text': "Certainly! I can help you find out the current weather in San Francisco. To get this information, I'll use the GetWeather function. Let me fetch that data for you right away.", 'type': 'text'}, {'id': 'toolu_01TS5h8LNo7p5imcG7yRiaUM', 'input': {'location': 'San Francisco, CA'}, 'name': 'GetWeather', 'type': 'tool_use'}], response_metadata={'id': 'msg_01Xg7Wr5inFWgBxE5jH9rpRo', 'model': 'claude-3-5-sonnet-20240620', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 171, 'output_tokens': 96, 'cache_creation_input_tokens': 1470, 'cache_read_input_tokens': 0}}, id='run-b36a5b54-5d69-470e-a1b0-b932d00b089e-0', tool_calls=[{'name': 'GetWeather', 'args': {'location': 'San Francisco, CA'}, 'id': 'toolu_01TS5h8LNo7p5imcG7yRiaUM', 'type': 'tool_call'}], usage_metadata={'input_tokens': 171, 'output_tokens': 96, 'total_tokens': 267})+ AIMessage(content=[{'text': "Certainly! I can help you find out the current weather in San Francisco. To get this information, I'll use the GetWeather function. Let me fetch that data for you right away.", 'type': 'text'}, {'id': 'toolu_01TS5h8LNo7p5imcG7yRiaUM', 'input': {'location': 'San Francisco, CA'}, 'name': 'GetWeather', 'type': 'tool_use'}], response_metadata={'id': 'msg_01Xg7Wr5inFWgBxE5jH9rpRo', 'model': 'claude-3-5-sonnet-latest', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 171, 'output_tokens': 96, 'cache_creation_input_tokens': 1470, 'cache_read_input_tokens': 0}}, id='run-b36a5b54-5d69-470e-a1b0-b932d00b089e-0', tool_calls=[{'name': 'GetWeather', 'args': {'location': 'San Francisco, CA'}, 'id': 'toolu_01TS5h8LNo7p5imcG7yRiaUM', 'type': 'tool_call'}], usage_metadata={'input_tokens': 171, 'output_tokens': 96, 'total_tokens': 267})If we invoke the tool again, we can see that the "usage" information in the AIMessage.response_metadata shows that we had a cache hit:.. code-block:: python- AIMessage(content=[{'text': 'To get the current weather in San Francisco, I can use the GetWeather function. Let me check that for you.', 'type': 'text'}, {'id': 'toolu_01HtVtY1qhMFdPprx42qU2eA', 'input': {'location': 'San Francisco, CA'}, 'name': 'GetWeather', 'type': 'tool_use'}], response_metadata={'id': 'msg_016RfWHrRvW6DAGCdwB6Ac64', 'model': 'claude-3-5-sonnet-20240620', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 171, 'output_tokens': 82, 'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 1470}}, id='run-88b1f825-dcb7-4277-ac27-53df55d22001-0', tool_calls=[{'name': 'GetWeather', 'args': {'location': 'San Francisco, CA'}, 'id': 'toolu_01HtVtY1qhMFdPprx42qU2eA', 'type': 'tool_call'}], usage_metadata={'input_tokens': 171, 'output_tokens': 82, 'total_tokens': 253})+ AIMessage(content=[{'text': 'To get the current weather in San Francisco, I can use the GetWeather function. Let me check that for you.', 'type': 'text'}, {'id': 'toolu_01HtVtY1qhMFdPprx42qU2eA', 'input': {'location': 'San Francisco, CA'}, 'name': 'GetWeather', 'type': 'tool_use'}], response_metadata={'id': 'msg_016RfWHrRvW6DAGCdwB6Ac64', 'model': 'claude-3-5-sonnet-latest', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 171, 'output_tokens': 82, 'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 1470}}, id='run-88b1f825-dcb7-4277-ac27-53df55d22001-0', tool_calls=[{'name': 'GetWeather', 'args': {'location': 'San Francisco, CA'}, 'id': 'toolu_01HtVtY1qhMFdPprx42qU2eA', 'type': 'tool_call'}], usage_metadata={'input_tokens': 171, 'output_tokens': 82, 'total_tokens': 253})""" # noqa: E501formatted_tools = [@@ -1929,7 +1929,7 @@ class ChatAnthropic(BaseChatModel):answer: strjustification: str- llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", temperature=0)+ llm = ChatAnthropic(model="claude-3-5-sonnet-latest", temperature=0)structured_llm = llm.with_structured_output(AnswerWithJustification)structured_llm.invoke("What weighs more a pound of bricks or a pound of feathers")@@ -1951,7 +1951,7 @@ class ChatAnthropic(BaseChatModel):answer: strjustification: str- llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", temperature=0)+ llm = ChatAnthropic(model="claude-3-5-sonnet-latest", temperature=0)structured_llm = llm.with_structured_output(AnswerWithJustification, include_raw=True)structured_llm.invoke("What weighs more a pound of bricks or a pound of feathers")@@ -1979,7 +1979,7 @@ class ChatAnthropic(BaseChatModel):"required": ["answer", "justification"]}}- llm = ChatAnthropic(model="claude-3-5-sonnet-20240620", temperature=0)+ llm = ChatAnthropic(model="claude-3-5-sonnet-latest", temperature=0)structured_llm = llm.with_structured_output(schema)structured_llm.invoke("What weighs more a pound of bricks or a pound of feathers")