mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 08:56:27 +00:00
anthropic[patch]: de-beta anthropic messages, release 0.0.2 (#17540)
This commit is contained in:
parent
a99c667c22
commit
bfaa8c3048
@ -5,11 +5,9 @@ all: help
|
|||||||
|
|
||||||
# Define a variable for the test file path.
|
# Define a variable for the test file path.
|
||||||
TEST_FILE ?= tests/unit_tests/
|
TEST_FILE ?= tests/unit_tests/
|
||||||
|
integration_test integration_tests: TEST_FILE=tests/integration_tests/
|
||||||
|
|
||||||
test:
|
test tests integration_test integration_tests:
|
||||||
poetry run pytest $(TEST_FILE)
|
|
||||||
|
|
||||||
tests:
|
|
||||||
poetry run pytest $(TEST_FILE)
|
poetry run pytest $(TEST_FILE)
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def _format_messages(messages: List[BaseMessage]) -> Tuple[Optional[str], List[D
|
|||||||
|
|
||||||
|
|
||||||
class ChatAnthropicMessages(BaseChatModel):
|
class ChatAnthropicMessages(BaseChatModel):
|
||||||
"""Beta ChatAnthropicMessages chat model.
|
"""ChatAnthropicMessages chat model.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@ -143,7 +143,7 @@ class ChatAnthropicMessages(BaseChatModel):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> Iterator[ChatGenerationChunk]:
|
) -> Iterator[ChatGenerationChunk]:
|
||||||
params = self._format_params(messages=messages, stop=stop, **kwargs)
|
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:
|
for text in stream.text_stream:
|
||||||
yield ChatGenerationChunk(message=AIMessageChunk(content=text))
|
yield ChatGenerationChunk(message=AIMessageChunk(content=text))
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class ChatAnthropicMessages(BaseChatModel):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> AsyncIterator[ChatGenerationChunk]:
|
) -> AsyncIterator[ChatGenerationChunk]:
|
||||||
params = self._format_params(messages=messages, stop=stop, **kwargs)
|
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:
|
async for text in stream.text_stream:
|
||||||
yield ChatGenerationChunk(message=AIMessageChunk(content=text))
|
yield ChatGenerationChunk(message=AIMessageChunk(content=text))
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ class ChatAnthropicMessages(BaseChatModel):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> ChatResult:
|
) -> ChatResult:
|
||||||
params = self._format_params(messages=messages, stop=stop, **kwargs)
|
params = self._format_params(messages=messages, stop=stop, **kwargs)
|
||||||
data = self._client.beta.messages.create(**params)
|
data = self._client.messages.create(**params)
|
||||||
return ChatResult(
|
return ChatResult(
|
||||||
generations=[
|
generations=[
|
||||||
ChatGeneration(message=AIMessage(content=data.content[0].text))
|
ChatGeneration(message=AIMessage(content=data.content[0].text))
|
||||||
@ -183,7 +183,7 @@ class ChatAnthropicMessages(BaseChatModel):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> ChatResult:
|
) -> ChatResult:
|
||||||
params = self._format_params(messages=messages, stop=stop, **kwargs)
|
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(
|
return ChatResult(
|
||||||
generations=[
|
generations=[
|
||||||
ChatGeneration(message=AIMessage(content=data.content[0].text))
|
ChatGeneration(message=AIMessage(content=data.content[0].text))
|
||||||
|
20
libs/partners/anthropic/poetry.lock
generated
20
libs/partners/anthropic/poetry.lock
generated
@ -16,13 +16,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""}
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anthropic"
|
name = "anthropic"
|
||||||
version = "0.8.1"
|
version = "0.16.0"
|
||||||
description = "The official Python library for the anthropic API"
|
description = "The official Python library for the anthropic API"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
files = [
|
files = [
|
||||||
{file = "anthropic-0.8.1-py3-none-any.whl", hash = "sha256:4578b99d6e140c84ad5f409e460aabc85acffc6e189dfd91378b9277b4c158b7"},
|
{file = "anthropic-0.16.0-py3-none-any.whl", hash = "sha256:fb6657050c14c90ebc49df3510541a4f74a926f04598eaa2c4f5a3be772a95da"},
|
||||||
{file = "anthropic-0.8.1.tar.gz", hash = "sha256:736cf85681b8ed066014b0485d8d5be1f2aae65f86e6a25c76a5d5ebb970eee5"},
|
{file = "anthropic-0.16.0.tar.gz", hash = "sha256:130730820d1b327f31a097f575e42721d7ef69c731728f4c2d7fa70cf3b7eee0"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@ -34,6 +34,10 @@ sniffio = "*"
|
|||||||
tokenizers = ">=0.13.0"
|
tokenizers = ">=0.13.0"
|
||||||
typing-extensions = ">=4.7,<5"
|
typing-extensions = ">=4.7,<5"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
bedrock = ["boto3 (>=1.28.57)", "botocore (>=1.31.57)"]
|
||||||
|
vertex = ["google-auth (>=2,<3)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyio"
|
name = "anyio"
|
||||||
version = "4.2.0"
|
version = "4.2.0"
|
||||||
@ -297,13 +301,13 @@ files = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httpcore"
|
name = "httpcore"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
description = "A minimal low-level HTTP client."
|
description = "A minimal low-level HTTP client."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
files = [
|
files = [
|
||||||
{file = "httpcore-1.0.2-py3-none-any.whl", hash = "sha256:096cc05bca73b8e459a1fc3dcf585148f63e534eae4339559c9b8a8d6399acc7"},
|
{file = "httpcore-1.0.3-py3-none-any.whl", hash = "sha256:9a6a501c3099307d9fd76ac244e08503427679b1e81ceb1d922485e2f2462ad2"},
|
||||||
{file = "httpcore-1.0.2.tar.gz", hash = "sha256:9fc092e4799b26174648e54b74ed5f683132a464e95643b226e00c2ed2fa6535"},
|
{file = "httpcore-1.0.3.tar.gz", hash = "sha256:5c0f9546ad17dac4d0772b0808856eb616eb8b48ce94f49ed819fd6982a8a544"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
@ -314,7 +318,7 @@ h11 = ">=0.13,<0.15"
|
|||||||
asyncio = ["anyio (>=4.0,<5.0)"]
|
asyncio = ["anyio (>=4.0,<5.0)"]
|
||||||
http2 = ["h2 (>=3,<5)"]
|
http2 = ["h2 (>=3,<5)"]
|
||||||
socks = ["socksio (==1.*)"]
|
socks = ["socksio (==1.*)"]
|
||||||
trio = ["trio (>=0.22.0,<0.23.0)"]
|
trio = ["trio (>=0.22.0,<0.24.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "httpx"
|
name = "httpx"
|
||||||
@ -1130,4 +1134,4 @@ watchmedo = ["PyYAML (>=3.10)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = ">=3.8.1,<4.0"
|
python-versions = ">=3.8.1,<4.0"
|
||||||
content-hash = "cdf1b6440668689dbe94c11db2fdfa79ea690bd750a9611868f27768ea4b132c"
|
content-hash = "c4d03a1586b121b905ea4c0f86d04427cbb3e155e60d67c4b3351186de0d540a"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "langchain-anthropic"
|
name = "langchain-anthropic"
|
||||||
version = "0.0.1.post2"
|
version = "0.0.2"
|
||||||
description = "An integration package connecting AnthropicMessages and LangChain"
|
description = "An integration package connecting AnthropicMessages and LangChain"
|
||||||
authors = []
|
authors = []
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -13,7 +13,7 @@ license = "MIT"
|
|||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = ">=3.8.1,<4.0"
|
python = ">=3.8.1,<4.0"
|
||||||
langchain-core = "^0.1"
|
langchain-core = "^0.1"
|
||||||
anthropic = "^0.8.0"
|
anthropic = ">=0.16.0,<1"
|
||||||
|
|
||||||
[tool.poetry.group.test]
|
[tool.poetry.group.test]
|
||||||
optional = true
|
optional = true
|
||||||
|
Loading…
Reference in New Issue
Block a user