From bfaa8c304864dd869318e69cd88d87d5b1205b78 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Wed, 14 Feb 2024 10:31:45 -0800 Subject: [PATCH] anthropic[patch]: de-beta anthropic messages, release 0.0.2 (#17540) --- libs/partners/anthropic/Makefile | 6 ++---- .../langchain_anthropic/chat_models.py | 10 +++++----- libs/partners/anthropic/poetry.lock | 20 +++++++++++-------- libs/partners/anthropic/pyproject.toml | 4 ++-- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/libs/partners/anthropic/Makefile b/libs/partners/anthropic/Makefile index bf2408a100..c3d56b1132 100644 --- a/libs/partners/anthropic/Makefile +++ b/libs/partners/anthropic/Makefile @@ -5,11 +5,9 @@ all: help # Define a variable for the test file path. TEST_FILE ?= tests/unit_tests/ +integration_test integration_tests: TEST_FILE=tests/integration_tests/ -test: - poetry run pytest $(TEST_FILE) - -tests: +test tests integration_test integration_tests: poetry run pytest $(TEST_FILE) diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index 812b829589..a7382c3cd1 100644 --- a/libs/partners/anthropic/langchain_anthropic/chat_models.py +++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py @@ -51,7 +51,7 @@ def _format_messages(messages: List[BaseMessage]) -> Tuple[Optional[str], List[D class ChatAnthropicMessages(BaseChatModel): - """Beta ChatAnthropicMessages chat model. + """ChatAnthropicMessages chat model. Example: .. code-block:: python @@ -143,7 +143,7 @@ class ChatAnthropicMessages(BaseChatModel): **kwargs: Any, ) -> Iterator[ChatGenerationChunk]: params = self._format_params(messages=messages, stop=stop, **kwargs) - with self._client.beta.messages.stream(**params) as stream: + with self._client.messages.stream(**params) as stream: for text in stream.text_stream: yield ChatGenerationChunk(message=AIMessageChunk(content=text)) @@ -155,7 +155,7 @@ class ChatAnthropicMessages(BaseChatModel): **kwargs: Any, ) -> AsyncIterator[ChatGenerationChunk]: params = self._format_params(messages=messages, stop=stop, **kwargs) - async with self._async_client.beta.messages.stream(**params) as stream: + async with self._async_client.messages.stream(**params) as stream: async for text in stream.text_stream: yield ChatGenerationChunk(message=AIMessageChunk(content=text)) @@ -167,7 +167,7 @@ class ChatAnthropicMessages(BaseChatModel): **kwargs: Any, ) -> ChatResult: params = self._format_params(messages=messages, stop=stop, **kwargs) - data = self._client.beta.messages.create(**params) + data = self._client.messages.create(**params) return ChatResult( generations=[ ChatGeneration(message=AIMessage(content=data.content[0].text)) @@ -183,7 +183,7 @@ class ChatAnthropicMessages(BaseChatModel): **kwargs: Any, ) -> ChatResult: params = self._format_params(messages=messages, stop=stop, **kwargs) - data = await self._async_client.beta.messages.create(**params) + data = await self._async_client.messages.create(**params) return ChatResult( generations=[ ChatGeneration(message=AIMessage(content=data.content[0].text)) diff --git a/libs/partners/anthropic/poetry.lock b/libs/partners/anthropic/poetry.lock index eaef3fe26f..f06d19b59a 100644 --- a/libs/partners/anthropic/poetry.lock +++ b/libs/partners/anthropic/poetry.lock @@ -16,13 +16,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anthropic" -version = "0.8.1" +version = "0.16.0" description = "The official Python library for the anthropic API" optional = false python-versions = ">=3.7" files = [ - {file = "anthropic-0.8.1-py3-none-any.whl", hash = "sha256:4578b99d6e140c84ad5f409e460aabc85acffc6e189dfd91378b9277b4c158b7"}, - {file = "anthropic-0.8.1.tar.gz", hash = "sha256:736cf85681b8ed066014b0485d8d5be1f2aae65f86e6a25c76a5d5ebb970eee5"}, + {file = "anthropic-0.16.0-py3-none-any.whl", hash = "sha256:fb6657050c14c90ebc49df3510541a4f74a926f04598eaa2c4f5a3be772a95da"}, + {file = "anthropic-0.16.0.tar.gz", hash = "sha256:130730820d1b327f31a097f575e42721d7ef69c731728f4c2d7fa70cf3b7eee0"}, ] [package.dependencies] @@ -34,6 +34,10 @@ sniffio = "*" tokenizers = ">=0.13.0" typing-extensions = ">=4.7,<5" +[package.extras] +bedrock = ["boto3 (>=1.28.57)", "botocore (>=1.31.57)"] +vertex = ["google-auth (>=2,<3)"] + [[package]] name = "anyio" version = "4.2.0" @@ -297,13 +301,13 @@ files = [ [[package]] name = "httpcore" -version = "1.0.2" +version = "1.0.3" description = "A minimal low-level HTTP client." optional = false python-versions = ">=3.8" files = [ - {file = "httpcore-1.0.2-py3-none-any.whl", hash = "sha256:096cc05bca73b8e459a1fc3dcf585148f63e534eae4339559c9b8a8d6399acc7"}, - {file = "httpcore-1.0.2.tar.gz", hash = "sha256:9fc092e4799b26174648e54b74ed5f683132a464e95643b226e00c2ed2fa6535"}, + {file = "httpcore-1.0.3-py3-none-any.whl", hash = "sha256:9a6a501c3099307d9fd76ac244e08503427679b1e81ceb1d922485e2f2462ad2"}, + {file = "httpcore-1.0.3.tar.gz", hash = "sha256:5c0f9546ad17dac4d0772b0808856eb616eb8b48ce94f49ed819fd6982a8a544"}, ] [package.dependencies] @@ -314,7 +318,7 @@ h11 = ">=0.13,<0.15" asyncio = ["anyio (>=4.0,<5.0)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] -trio = ["trio (>=0.22.0,<0.23.0)"] +trio = ["trio (>=0.22.0,<0.24.0)"] [[package]] name = "httpx" @@ -1130,4 +1134,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "cdf1b6440668689dbe94c11db2fdfa79ea690bd750a9611868f27768ea4b132c" +content-hash = "c4d03a1586b121b905ea4c0f86d04427cbb3e155e60d67c4b3351186de0d540a" diff --git a/libs/partners/anthropic/pyproject.toml b/libs/partners/anthropic/pyproject.toml index 2e2428f91b..2cdfaba198 100644 --- a/libs/partners/anthropic/pyproject.toml +++ b/libs/partners/anthropic/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain-anthropic" -version = "0.0.1.post2" +version = "0.0.2" 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 = "^0.1" -anthropic = "^0.8.0" +anthropic = ">=0.16.0,<1" [tool.poetry.group.test] optional = true