Skip to content

Commit 6802502

Browse files
authored
build: add pins for Anthropic (#1811)
* build: add pins for Anthropic * rm file incorrectly added
1 parent 435675b commit 6802502

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.github/workflows/anthropic.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,16 @@ jobs:
5757
- name: Run tests
5858
run: hatch run cov-retry
5959

60+
- name: Run unit tests with lowest direct dependencies
61+
run: |
62+
hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt
63+
hatch run uv pip install -r requirements_lowest_direct.txt
64+
hatch run test -m "not integration"
65+
6066
- name: Nightly - run unit tests with Haystack main branch
6167
if: github.event_name == 'schedule'
6268
run: |
69+
hatch env prune
6370
hatch run uv pip install git+https://github.com/deepset-ai/haystack.git@main
6471
hatch run cov-retry -m "not integration"
6572

integrations/anthropic/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: Implementation :: CPython",
2424
"Programming Language :: Python :: Implementation :: PyPy",
2525
]
26-
dependencies = ["haystack-ai>=2.9.0", "anthropic"]
26+
dependencies = ["haystack-ai>=2.11.0", "anthropic>=0.47.0"]
2727

2828
[project.urls]
2929
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/anthropic#readme"

integrations/anthropic/tests/test_chat_generator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ def test_convert_anthropic_chunk_to_streaming_chunk(self):
339339
)
340340
streaming_chunk = component._convert_anthropic_chunk_to_streaming_chunk(message_start_chunk)
341341
assert streaming_chunk.content == ""
342+
343+
# remove fields not present in the pinned version of the Anthropic SDK.
344+
# This ensures the test passes with both the pinned and the latest version of the Anthropic SDK.
345+
streaming_chunk.meta["message"]["usage"].pop("server_tool_use", None)
346+
streaming_chunk.meta["message"]["usage"].pop("service_tier", None)
347+
342348
assert streaming_chunk.meta == {
343349
"type": "message_start",
344350
"message": {
@@ -354,8 +360,6 @@ def test_convert_anthropic_chunk_to_streaming_chunk(self):
354360
"output_tokens": 1,
355361
"cache_creation_input_tokens": None,
356362
"cache_read_input_tokens": None,
357-
"server_tool_use": None,
358-
"service_tier": None,
359363
},
360364
},
361365
}

0 commit comments

Comments
 (0)