mirror of
https://github.com/hwchase17/langchain
synced 2024-11-16 06:13:16 +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": [],
|
||||
"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])"
|
||||
]
|
||||
},
|
||||
|
@ -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?"})
|
||||
"""
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user