Skip to content

The agent engineering platform.

docs: set default anthropic model (#21988)

ccurmea983465694c7
diff --git a/docs/docs/how_to/fallbacks.ipynb b/docs/docs/how_to/fallbacks.ipynb
index 8f8117d76c..bdb234c83c 100644
--- a/docs/docs/how_to/fallbacks.ipynb
+++ b/docs/docs/how_to/fallbacks.ipynb
@@ -90,8 +90,8 @@
"outputs": [],
"source": [
"# Note that we set max_retries = 0 to avoid retrying on RateLimits, etc\n",
- "openai_llm = ChatOpenAI(max_retries=0)\n",
- "anthropic_llm = ChatAnthropic()\n",
+ "openai_llm = ChatOpenAI(model=\"gpt-3.5-turbo-0125\", max_retries=0)\n",
+ "anthropic_llm = ChatAnthropic(model=\"claude-3-haiku-20240307\")\n",
"llm = openai_llm.with_fallbacks([anthropic_llm])"
]
},
diff --git a/libs/core/langchain_core/prompts/few_shot.py b/libs/core/langchain_core/prompts/few_shot.py
index bf0d55f84e..2fbc7d7a46 100644
--- a/libs/core/langchain_core/prompts/few_shot.py
+++ b/libs/core/langchain_core/prompts/few_shot.py
@@ -305,7 +305,7 @@ class FewShotChatMessagePromptTemplate(
# Use within an LLM
from langchain_core.chat_models import ChatAnthropic
- chain = final_prompt | ChatAnthropic()
+ chain = final_prompt | ChatAnthropic(model="claude-3-haiku-20240307")
chain.invoke({"input": "What's 3+3?"})
"""
diff --git a/libs/core/langchain_core/runnables/fallbacks.py b/libs/core/langchain_core/runnables/fallbacks.py
index 131061e9e9..494c27a4bc 100644
--- a/libs/core/langchain_core/runnables/fallbacks.py
+++ b/libs/core/langchain_core/runnables/fallbacks.py
@@ -61,7 +61,9 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]):
from langchain_core.chat_models.openai import ChatOpenAI
from langchain_core.chat_models.anthropic import ChatAnthropic
- model = ChatAnthropic().with_fallbacks([ChatOpenAI()])
+ model = ChatAnthropic(
+ model="claude-3-haiku-20240307"
+ ).with_fallbacks([ChatOpenAI(model="gpt-3.5-turbo-0125")])
# Will usually use ChatAnthropic, but fallback to ChatOpenAI
# if ChatAnthropic fails.
model.invoke('hello')
diff --git a/libs/langchain/langchain/agents/self_ask_with_search/base.py b/libs/langchain/langchain/agents/self_ask_with_search/base.py
index d616a06de2..a930a59b4b 100644
--- a/libs/langchain/langchain/agents/self_ask_with_search/base.py
+++ b/libs/langchain/langchain/agents/self_ask_with_search/base.py
@@ -117,7 +117,7 @@ def create_self_ask_with_search_agent(
)
prompt = hub.pull("hwchase17/self-ask-with-search")
- model = ChatAnthropic()
+ model = ChatAnthropic(model="claude-3-haiku-20240307")
tools = [...] # Should just be one tool with name `Intermediate Answer`
agent = create_self_ask_with_search_agent(model, tools, prompt)
diff --git a/libs/langchain/langchain/agents/xml/base.py b/libs/langchain/langchain/agents/xml/base.py
index 1fc70f50be..2a224736e5 100644
--- a/libs/langchain/langchain/agents/xml/base.py
+++ b/libs/langchain/langchain/agents/xml/base.py
@@ -147,7 +147,7 @@ def create_xml_agent(
from langchain.agents import AgentExecutor, create_xml_agent
prompt = hub.pull("hwchase17/xml-agent-convo")
- model = ChatAnthropic()
+ model = ChatAnthropic(model="claude-3-haiku-20240307")
tools = ...
agent = create_xml_agent(model, tools, prompt)