From a8098f5ddb50577aaf999491e1a4c40c037275e5 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Fri, 31 May 2024 12:10:22 -0700 Subject: [PATCH] anthropic[patch]: Release 0.1.15, fix sdk tools break (#22369) --- .../langchain_anthropic/chat_models.py | 13 +++--------- libs/partners/anthropic/poetry.lock | 21 +++++++++---------- libs/partners/anthropic/pyproject.toml | 4 ++-- .../tests/unit_tests/test_chat_models.py | 4 ++-- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index 42a9117ab7d..ac47322aca9 100644 --- a/libs/partners/anthropic/langchain_anthropic/chat_models.py +++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py @@ -22,7 +22,7 @@ from typing import ( ) import anthropic -from langchain_core._api import beta, deprecated +from langchain_core._api import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, @@ -522,10 +522,7 @@ class ChatAnthropic(BaseChatModel): messages, stop=stop, run_manager=run_manager, **kwargs ) return generate_from_stream(stream_iter) - if _tools_in_params(params): - data = self._client.beta.tools.messages.create(**params) - else: - data = self._client.messages.create(**params) + data = self._client.messages.create(**params) return self._format_output(data, **kwargs) async def _agenerate( @@ -546,13 +543,9 @@ class ChatAnthropic(BaseChatModel): messages, stop=stop, run_manager=run_manager, **kwargs ) return await agenerate_from_stream(stream_iter) - if _tools_in_params(params): - data = await self._async_client.beta.tools.messages.create(**params) - else: - data = await self._async_client.messages.create(**params) + data = await self._async_client.messages.create(**params) return self._format_output(data, **kwargs) - @beta() def bind_tools( self, tools: Sequence[Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]], diff --git a/libs/partners/anthropic/poetry.lock b/libs/partners/anthropic/poetry.lock index bfbd38aa425..17cfdd1d97c 100644 --- a/libs/partners/anthropic/poetry.lock +++ b/libs/partners/anthropic/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "annotated-types" @@ -16,20 +16,19 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anthropic" -version = "0.26.1" +version = "0.28.0" description = "The official Python library for the anthropic API" optional = false python-versions = ">=3.7" files = [ - {file = "anthropic-0.26.1-py3-none-any.whl", hash = "sha256:2812b9b250b551ed8a1f0a7e6ae3f005654098994f45ebca5b5808bd154c9628"}, - {file = "anthropic-0.26.1.tar.gz", hash = "sha256:26680ff781a6f678a30a1dccd0743631e602b23a47719439ffdef5335fa167d8"}, + {file = "anthropic-0.28.0-py3-none-any.whl", hash = "sha256:2b620b21aee3d20c5d8005483c34df239d53ae895687113b26b8a36892a7e20f"}, ] [package.dependencies] anyio = ">=3.5.0,<5" distro = ">=1.7.0,<2" httpx = ">=0.23.0,<1" -jiter = ">=0.1.0,<1" +jiter = ">=0.4.0,<1" pydantic = ">=1.9.0,<3" sniffio = "*" tokenizers = ">=0.13.0" @@ -512,7 +511,7 @@ files = [ [[package]] name = "langchain-core" -version = "0.2.2rc1" +version = "0.2.3" description = "Building applications with LLMs through composability" optional = false python-versions = ">=3.8.1,<4.0" @@ -521,7 +520,7 @@ develop = true [package.dependencies] jsonpatch = "^1.33" -langsmith = "^0.1.0" +langsmith = "^0.1.65" packaging = "^23.2" pydantic = ">=1,<3" PyYAML = ">=5.3" @@ -553,13 +552,13 @@ url = "../../standard-tests" [[package]] name = "langsmith" -version = "0.1.63" +version = "0.1.67" description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." optional = false python-versions = "<4.0,>=3.8.1" files = [ - {file = "langsmith-0.1.63-py3-none-any.whl", hash = "sha256:7810afdf5e3f3b472fc581a29371fb96cd843dde2149e048d1b9610325159d1e"}, - {file = "langsmith-0.1.63.tar.gz", hash = "sha256:a609405b52f6f54df442a142cbf19ab38662d54e532f96028b4c546434d4afdf"}, + {file = "langsmith-0.1.67-py3-none-any.whl", hash = "sha256:7eb2e1c1b375925ff47700ed8071e10c15e942e9d1d634b4a449a9060364071a"}, + {file = "langsmith-0.1.67.tar.gz", hash = "sha256:149558669a2ac4f21471cd964e61072687bba23b7c1ccb51f190a8f59b595b39"}, ] [package.dependencies] @@ -1286,4 +1285,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "b7a5f1c41811ecfc4f87a5261e0d4627abcd79a070355faa60408a3e7a1c691c" +content-hash = "a88c10c902a287792de08135f1c17391a89c7363a30c8d55a185f0c90efc22ac" diff --git a/libs/partners/anthropic/pyproject.toml b/libs/partners/anthropic/pyproject.toml index 859536541da..2bbb3fdd026 100644 --- a/libs/partners/anthropic/pyproject.toml +++ b/libs/partners/anthropic/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain-anthropic" -version = "0.1.14rc2" +version = "0.1.15" description = "An integration package connecting AnthropicMessages and LangChain" authors = [] readme = "README.md" @@ -13,7 +13,7 @@ license = "MIT" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" langchain-core = { version = ">=0.2.2rc1,<0.3", allow-prereleases = true } -anthropic = ">=0.26.0,<1" +anthropic = ">=0.28.0,<1" defusedxml = { version = "^0.7.1", optional = true } [tool.poetry.group.test] diff --git a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py index 3c5c5b2691c..09ae57b5425 100644 --- a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py +++ b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py @@ -4,7 +4,7 @@ import os from typing import Any, Callable, Dict, Literal, Type, cast import pytest -from anthropic.types import ContentBlock, Message, Usage +from anthropic.types import Message, TextBlock, Usage from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolMessage from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.pydantic_v1 import BaseModel, Field, SecretStr @@ -79,7 +79,7 @@ def test_anthropic_initialization() -> None: def test__format_output() -> None: anthropic_msg = Message( id="foo", - content=[ContentBlock(type="text", text="bar")], + content=[TextBlock(type="text", text="bar")], model="baz", role="assistant", stop_reason=None,