mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-19 03:01:29 +00:00
docs: set default anthropic model (#21988)
`ChatAnthropic()` raises ValidationError.
This commit is contained in:
parent
5448e16fe6
commit
a983465694
@ -90,8 +90,8 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Note that we set max_retries = 0 to avoid retrying on RateLimits, etc\n",
|
"# Note that we set max_retries = 0 to avoid retrying on RateLimits, etc\n",
|
||||||
"openai_llm = ChatOpenAI(max_retries=0)\n",
|
"openai_llm = ChatOpenAI(model=\"gpt-3.5-turbo-0125\", max_retries=0)\n",
|
||||||
"anthropic_llm = ChatAnthropic()\n",
|
"anthropic_llm = ChatAnthropic(model=\"claude-3-haiku-20240307\")\n",
|
||||||
"llm = openai_llm.with_fallbacks([anthropic_llm])"
|
"llm = openai_llm.with_fallbacks([anthropic_llm])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -305,7 +305,7 @@ class FewShotChatMessagePromptTemplate(
|
|||||||
|
|
||||||
# Use within an LLM
|
# Use within an LLM
|
||||||
from langchain_core.chat_models import ChatAnthropic
|
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?"})
|
chain.invoke({"input": "What's 3+3?"})
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -61,7 +61,9 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]):
|
|||||||
from langchain_core.chat_models.openai import ChatOpenAI
|
from langchain_core.chat_models.openai import ChatOpenAI
|
||||||
from langchain_core.chat_models.anthropic import ChatAnthropic
|
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
|
# Will usually use ChatAnthropic, but fallback to ChatOpenAI
|
||||||
# if ChatAnthropic fails.
|
# if ChatAnthropic fails.
|
||||||
model.invoke('hello')
|
model.invoke('hello')
|
||||||
|
@ -117,7 +117,7 @@ def create_self_ask_with_search_agent(
|
|||||||
)
|
)
|
||||||
|
|
||||||
prompt = hub.pull("hwchase17/self-ask-with-search")
|
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`
|
tools = [...] # Should just be one tool with name `Intermediate Answer`
|
||||||
|
|
||||||
agent = create_self_ask_with_search_agent(model, tools, prompt)
|
agent = create_self_ask_with_search_agent(model, tools, prompt)
|
||||||
|
@ -147,7 +147,7 @@ def create_xml_agent(
|
|||||||
from langchain.agents import AgentExecutor, create_xml_agent
|
from langchain.agents import AgentExecutor, create_xml_agent
|
||||||
|
|
||||||
prompt = hub.pull("hwchase17/xml-agent-convo")
|
prompt = hub.pull("hwchase17/xml-agent-convo")
|
||||||
model = ChatAnthropic()
|
model = ChatAnthropic(model="claude-3-haiku-20240307")
|
||||||
tools = ...
|
tools = ...
|
||||||
|
|
||||||
agent = create_xml_agent(model, tools, prompt)
|
agent = create_xml_agent(model, tools, prompt)
|
||||||
|
Loading…
Reference in New Issue
Block a user