mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-15 07:36:08 +00:00
anthropic[patch]: integration test update (#18823)
This commit is contained in:
parent
d1f5bc4906
commit
a8de6d1533
@ -10,6 +10,7 @@ from langchain_core.pydantic_v1 import BaseModel, Field
|
|||||||
from langchain_anthropic.experimental import ChatAnthropicTools
|
from langchain_anthropic.experimental import ChatAnthropicTools
|
||||||
|
|
||||||
MODEL_NAME = "claude-3-sonnet-20240229"
|
MODEL_NAME = "claude-3-sonnet-20240229"
|
||||||
|
BIG_MODEL_NAME = "claude-3-opus-20240229"
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
### Test Basic features, no tools ###
|
### Test Basic features, no tools ###
|
||||||
@ -108,7 +109,9 @@ def test_tools() -> None:
|
|||||||
name: str
|
name: str
|
||||||
age: int
|
age: int
|
||||||
|
|
||||||
llm = ChatAnthropicTools(model_name=MODEL_NAME).bind_tools([Person])
|
llm = ChatAnthropicTools(model_name=BIG_MODEL_NAME, temperature=0).bind_tools(
|
||||||
|
[Person]
|
||||||
|
)
|
||||||
result = llm.invoke("Erick is 27 years old")
|
result = llm.invoke("Erick is 27 years old")
|
||||||
assert result.content == "", f"content should be empty, not {result.content}"
|
assert result.content == "", f"content should be empty, not {result.content}"
|
||||||
assert "tool_calls" in result.additional_kwargs
|
assert "tool_calls" in result.additional_kwargs
|
||||||
@ -126,7 +129,9 @@ def test_with_structured_output() -> None:
|
|||||||
name: str
|
name: str
|
||||||
age: int
|
age: int
|
||||||
|
|
||||||
chain = ChatAnthropicTools(model_name=MODEL_NAME).with_structured_output(Person)
|
chain = ChatAnthropicTools(
|
||||||
|
model_name=BIG_MODEL_NAME, temperature=0
|
||||||
|
).with_structured_output(Person)
|
||||||
result = chain.invoke("Erick is 27 years old")
|
result = chain.invoke("Erick is 27 years old")
|
||||||
assert isinstance(result, Person)
|
assert isinstance(result, Person)
|
||||||
assert result.name == "Erick"
|
assert result.name == "Erick"
|
||||||
@ -167,7 +172,7 @@ def test_anthropic_complex_structured_output() -> None:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
llm = ChatAnthropicTools(temperature=0, model_name="claude-3-sonnet-20240229")
|
llm = ChatAnthropicTools(temperature=0, model_name=BIG_MODEL_NAME)
|
||||||
|
|
||||||
extraction_chain = prompt | llm.with_structured_output(Email)
|
extraction_chain = prompt | llm.with_structured_output(Email)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user