litellm-haystack 1.2.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/CHANGELOG.md +9 -3
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/LICENSE.txt +1 -1
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/PKG-INFO +3 -4
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/pyproject.toml +1 -2
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/src/haystack_integrations/components/generators/litellm/chat/chat_generator.py +7 -4
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/tests/test_litellm_chat_generator.py +28 -5
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/.gitignore +0 -0
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/README.md +0 -0
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/pydoc/config_docusaurus.yml +0 -0
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/src/haystack_integrations/components/generators/litellm/__init__.py +0 -0
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/src/haystack_integrations/components/generators/litellm/chat/__init__.py +0 -0
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/src/haystack_integrations/components/generators/py.typed +0 -0
- {litellm_haystack-1.2.0 → litellm_haystack-2.0.0}/tests/__init__.py +0 -0
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [integrations/litellm-v1.
|
|
3
|
+
## [integrations/litellm-v1.2.0] - 2026-07-30
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
- *(litellm)* Include provider cache tokens in usage metadata (#3678)
|
|
8
|
+
|
|
9
|
+
### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- Cap litellm dependency below 1.92.0 (#3601)
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
### 🌀 Miscellaneous
|
|
8
14
|
|
|
9
15
|
|
|
10
16
|
## [integrations/litellm-v1.1.1] - 2026-07-15
|
|
@@ -58,7 +58,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|
|
58
58
|
|
|
59
59
|
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
60
|
|
|
61
|
-
Copyright
|
|
61
|
+
Copyright 2023-present deepset GmbH
|
|
62
62
|
|
|
63
63
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
64
|
you may not use this file except in compliance with the License.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: litellm-haystack
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: An integration of LiteLLM AI gateway into the Haystack framework, routing to 100+ LLM providers.
|
|
5
5
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/litellm#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
@@ -12,13 +12,12 @@ Keywords: ai-gateway,haystack,litellm,llm
|
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
19
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.11
|
|
22
21
|
Requires-Dist: haystack-ai>=2.30.0
|
|
23
22
|
Requires-Dist: litellm<1.92.0,>=1.84.0
|
|
24
23
|
Description-Content-Type: text/markdown
|
|
@@ -7,7 +7,7 @@ name = "litellm-haystack"
|
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = "An integration of LiteLLM AI gateway into the Haystack framework, routing to 100+ LLM providers."
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
keywords = ["haystack", "litellm", "llm", "ai-gateway"]
|
|
13
13
|
authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
|
|
@@ -15,7 +15,6 @@ classifiers = [
|
|
|
15
15
|
"License :: OSI Approved :: Apache Software License",
|
|
16
16
|
"Development Status :: 4 - Beta",
|
|
17
17
|
"Programming Language :: Python",
|
|
18
|
-
"Programming Language :: Python :: 3.10",
|
|
19
18
|
"Programming Language :: Python :: 3.11",
|
|
20
19
|
"Programming Language :: Python :: 3.12",
|
|
21
20
|
"Programming Language :: Python :: 3.13",
|
|
@@ -25,7 +25,7 @@ from haystack.tools import (
|
|
|
25
25
|
flatten_tools_or_toolsets,
|
|
26
26
|
serialize_tools_or_toolset,
|
|
27
27
|
)
|
|
28
|
-
from haystack.utils.auth import Secret
|
|
28
|
+
from haystack.utils.auth import Secret
|
|
29
29
|
from haystack.utils.callable_serialization import deserialize_callable, serialize_callable
|
|
30
30
|
|
|
31
31
|
logger = logging.getLogger(__name__)
|
|
@@ -149,7 +149,9 @@ class LiteLLMChatGenerator:
|
|
|
149
149
|
:param messages: Input messages as ChatMessage instances.
|
|
150
150
|
If a string is provided, it is converted to a list containing a ChatMessage with user role.
|
|
151
151
|
:param streaming_callback: Override the streaming callback for this call.
|
|
152
|
-
:param generation_kwargs:
|
|
152
|
+
:param generation_kwargs: Additional parameters for this call. These are merged per key with the
|
|
153
|
+
`generation_kwargs` passed at initialization: keys provided here take precedence, keys set only
|
|
154
|
+
at initialization are kept.
|
|
153
155
|
:param tools: Override tools for this call.
|
|
154
156
|
:returns: A dict with key ``replies`` containing ChatMessage instances.
|
|
155
157
|
"""
|
|
@@ -186,7 +188,9 @@ class LiteLLMChatGenerator:
|
|
|
186
188
|
:param messages: Input messages as ChatMessage instances.
|
|
187
189
|
If a string is provided, it is converted to a list containing a ChatMessage with user role.
|
|
188
190
|
:param streaming_callback: Override the streaming callback for this call.
|
|
189
|
-
:param generation_kwargs:
|
|
191
|
+
:param generation_kwargs: Additional parameters for this call. These are merged per key with the
|
|
192
|
+
`generation_kwargs` passed at initialization: keys provided here take precedence, keys set only
|
|
193
|
+
at initialization are kept.
|
|
190
194
|
:param tools: Override tools for this call.
|
|
191
195
|
:returns: A dict with key ``replies`` containing ChatMessage instances.
|
|
192
196
|
"""
|
|
@@ -246,7 +250,6 @@ class LiteLLMChatGenerator:
|
|
|
246
250
|
@classmethod
|
|
247
251
|
def from_dict(cls, data: dict[str, Any]) -> "LiteLLMChatGenerator":
|
|
248
252
|
"""Deserialize a component from a dictionary."""
|
|
249
|
-
deserialize_secrets_inplace(data["init_parameters"], keys=["api_key"])
|
|
250
253
|
deserialize_tools_or_toolset_inplace(data["init_parameters"], key="tools")
|
|
251
254
|
if data["init_parameters"].get("streaming_callback"):
|
|
252
255
|
data["init_parameters"]["streaming_callback"] = deserialize_callable(
|
|
@@ -201,18 +201,20 @@ class TestRun:
|
|
|
201
201
|
call_kwargs = fake_litellm.completion.call_args
|
|
202
202
|
assert call_kwargs.kwargs["api_base"] == "https://proxy.local"
|
|
203
203
|
|
|
204
|
-
def
|
|
205
|
-
gen = LiteLLMChatGenerator(
|
|
204
|
+
def test_run_with_generation_kwargs(self):
|
|
205
|
+
gen = LiteLLMChatGenerator(
|
|
206
|
+
model="openai/gpt-4o", generation_kwargs={"temperature": 0.5, "max_completion_tokens": 100}
|
|
207
|
+
)
|
|
206
208
|
mock_resp = _make_mock_response()
|
|
207
209
|
|
|
208
210
|
fake_litellm = types.ModuleType("litellm")
|
|
209
211
|
fake_litellm.completion = MagicMock(return_value=mock_resp)
|
|
210
212
|
|
|
211
213
|
with mock.patch.dict(sys.modules, {"litellm": fake_litellm}):
|
|
212
|
-
gen.run(messages=[ChatMessage.from_user("hi")], generation_kwargs={"
|
|
214
|
+
gen.run(messages=[ChatMessage.from_user("hi")], generation_kwargs={"temperature": 0.9})
|
|
213
215
|
call_kwargs = fake_litellm.completion.call_args
|
|
214
|
-
assert call_kwargs.kwargs["temperature"] == 0.
|
|
215
|
-
assert call_kwargs.kwargs["
|
|
216
|
+
assert call_kwargs.kwargs["temperature"] == 0.9
|
|
217
|
+
assert call_kwargs.kwargs["max_completion_tokens"] == 100
|
|
216
218
|
|
|
217
219
|
def test_empty_messages_returns_empty(self):
|
|
218
220
|
gen = LiteLLMChatGenerator()
|
|
@@ -463,6 +465,27 @@ class TestAsync:
|
|
|
463
465
|
assert len(result["replies"]) == 1
|
|
464
466
|
assert isinstance(result["replies"][0], ChatMessage)
|
|
465
467
|
|
|
468
|
+
@pytest.mark.asyncio
|
|
469
|
+
async def test_run_async_with_generation_kwargs(self):
|
|
470
|
+
gen = LiteLLMChatGenerator(
|
|
471
|
+
model="openai/gpt-4o", generation_kwargs={"temperature": 0.5, "max_completion_tokens": 100}
|
|
472
|
+
)
|
|
473
|
+
mock_resp = _make_mock_response()
|
|
474
|
+
|
|
475
|
+
fake_litellm = types.ModuleType("litellm")
|
|
476
|
+
captured_kwargs = {}
|
|
477
|
+
|
|
478
|
+
async def _acompletion(**kwargs):
|
|
479
|
+
captured_kwargs.update(kwargs)
|
|
480
|
+
return mock_resp
|
|
481
|
+
|
|
482
|
+
fake_litellm.acompletion = _acompletion
|
|
483
|
+
|
|
484
|
+
with mock.patch.dict(sys.modules, {"litellm": fake_litellm}):
|
|
485
|
+
await gen.run_async(messages=[ChatMessage.from_user("hi")], generation_kwargs={"temperature": 0.9})
|
|
486
|
+
assert captured_kwargs["temperature"] == 0.9
|
|
487
|
+
assert captured_kwargs["max_completion_tokens"] == 100
|
|
488
|
+
|
|
466
489
|
@pytest.mark.asyncio
|
|
467
490
|
async def test_run_async_empty_messages(self):
|
|
468
491
|
gen = LiteLLMChatGenerator(model="openai/gpt-4o")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|