litellm-haystack 1.0.0__py3-none-any.whl
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.
- haystack_integrations/components/generators/litellm/__init__.py +7 -0
- haystack_integrations/components/generators/litellm/chat/__init__.py +3 -0
- haystack_integrations/components/generators/litellm/chat/chat_generator.py +371 -0
- haystack_integrations/components/generators/py.typed +0 -0
- litellm_haystack-1.0.0.dist-info/METADATA +40 -0
- litellm_haystack-1.0.0.dist-info/RECORD +8 -0
- litellm_haystack-1.0.0.dist-info/WHEEL +4 -0
- litellm_haystack-1.0.0.dist-info/licenses/LICENSE.txt +73 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from haystack import component, default_from_dict, default_to_dict, logging
|
|
9
|
+
from haystack.components.generators.utils import _convert_streaming_chunks_to_chat_message
|
|
10
|
+
from haystack.dataclasses import ChatMessage, ToolCall
|
|
11
|
+
from haystack.dataclasses.streaming_chunk import (
|
|
12
|
+
AsyncStreamingCallbackT,
|
|
13
|
+
ComponentInfo,
|
|
14
|
+
FinishReason,
|
|
15
|
+
StreamingCallbackT,
|
|
16
|
+
StreamingChunk,
|
|
17
|
+
SyncStreamingCallbackT,
|
|
18
|
+
ToolCallDelta,
|
|
19
|
+
select_streaming_callback,
|
|
20
|
+
)
|
|
21
|
+
from haystack.tools import (
|
|
22
|
+
ToolsType,
|
|
23
|
+
_check_duplicate_tool_names,
|
|
24
|
+
deserialize_tools_or_toolset_inplace,
|
|
25
|
+
flatten_tools_or_toolsets,
|
|
26
|
+
serialize_tools_or_toolset,
|
|
27
|
+
)
|
|
28
|
+
from haystack.utils.auth import Secret, deserialize_secrets_inplace
|
|
29
|
+
from haystack.utils.callable_serialization import deserialize_callable, serialize_callable
|
|
30
|
+
|
|
31
|
+
logger = logging.getLogger(__name__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@component
|
|
35
|
+
class LiteLLMChatGenerator:
|
|
36
|
+
"""Completes chats using any of 100+ LLM providers via LiteLLM.
|
|
37
|
+
|
|
38
|
+
LiteLLM routes to OpenAI, Anthropic, Google, AWS Bedrock, Azure, Cohere,
|
|
39
|
+
Mistral, Groq, and many more through a single unified interface.
|
|
40
|
+
|
|
41
|
+
Model names use LiteLLM format: ``provider/model-name``, e.g.
|
|
42
|
+
``anthropic/claude-sonnet-4-20250514``, ``openai/gpt-4o``,
|
|
43
|
+
``bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0``.
|
|
44
|
+
|
|
45
|
+
See https://docs.litellm.ai/docs/providers for the full list.
|
|
46
|
+
|
|
47
|
+
Usage example:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from haystack_integrations.components.generators.litellm import LiteLLMChatGenerator
|
|
51
|
+
from haystack.dataclasses import ChatMessage
|
|
52
|
+
|
|
53
|
+
generator = LiteLLMChatGenerator(
|
|
54
|
+
model="anthropic/claude-sonnet-4-20250514",
|
|
55
|
+
generation_kwargs={"max_tokens": 1024, "temperature": 0.7},
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
messages = [
|
|
59
|
+
ChatMessage.from_system("You are a helpful assistant"),
|
|
60
|
+
ChatMessage.from_user("What's Natural Language Processing?"),
|
|
61
|
+
]
|
|
62
|
+
result = generator.run(messages=messages)
|
|
63
|
+
print(result["replies"][0].text)
|
|
64
|
+
```
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
*,
|
|
70
|
+
api_key: Secret | None = None,
|
|
71
|
+
model: str = "openai/gpt-4o",
|
|
72
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
73
|
+
api_base_url: str | None = None,
|
|
74
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
75
|
+
tools: ToolsType | None = None,
|
|
76
|
+
) -> None:
|
|
77
|
+
"""Create a LiteLLMChatGenerator instance.
|
|
78
|
+
|
|
79
|
+
:param api_key:
|
|
80
|
+
The API key for the provider. Optional: when not set, LiteLLM resolves
|
|
81
|
+
credentials itself from the provider's standard environment variable
|
|
82
|
+
(e.g. ``ANTHROPIC_API_KEY``, ``OPENAI_API_KEY``). Pass a ``Secret`` only
|
|
83
|
+
when you want Haystack to manage and serialize the key explicitly.
|
|
84
|
+
:param model:
|
|
85
|
+
The model name in LiteLLM format (provider/model-name).
|
|
86
|
+
:param streaming_callback:
|
|
87
|
+
A callback function invoked with each new StreamingChunk.
|
|
88
|
+
:param api_base_url:
|
|
89
|
+
Custom API base URL (e.g. for a self-hosted LiteLLM proxy).
|
|
90
|
+
:param generation_kwargs:
|
|
91
|
+
Additional parameters passed to litellm.completion().
|
|
92
|
+
See https://docs.litellm.ai/docs/completion/input for details.
|
|
93
|
+
:param tools:
|
|
94
|
+
A list of Tool / Toolset objects the model can prepare calls for.
|
|
95
|
+
"""
|
|
96
|
+
self.model = model
|
|
97
|
+
self.api_key = api_key
|
|
98
|
+
self.streaming_callback = streaming_callback
|
|
99
|
+
self.api_base_url = api_base_url
|
|
100
|
+
self.generation_kwargs = generation_kwargs or {}
|
|
101
|
+
self.tools = tools
|
|
102
|
+
|
|
103
|
+
def _build_litellm_kwargs(
|
|
104
|
+
self,
|
|
105
|
+
messages: list[ChatMessage],
|
|
106
|
+
streaming_callback: StreamingCallbackT | None,
|
|
107
|
+
generation_kwargs: dict[str, Any] | None,
|
|
108
|
+
tools: ToolsType | None,
|
|
109
|
+
) -> dict[str, Any]:
|
|
110
|
+
merged_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})}
|
|
111
|
+
openai_messages = [m.to_openai_dict_format() for m in messages]
|
|
112
|
+
|
|
113
|
+
extra: dict[str, Any] = {}
|
|
114
|
+
if self.api_key:
|
|
115
|
+
extra["api_key"] = self.api_key.resolve_value()
|
|
116
|
+
if self.api_base_url:
|
|
117
|
+
extra["api_base"] = self.api_base_url
|
|
118
|
+
|
|
119
|
+
flattened_tools = flatten_tools_or_toolsets(tools or self.tools)
|
|
120
|
+
_check_duplicate_tool_names(flattened_tools)
|
|
121
|
+
tool_defs = None
|
|
122
|
+
if flattened_tools:
|
|
123
|
+
tool_defs = [{"type": "function", "function": t.tool_spec} for t in flattened_tools]
|
|
124
|
+
|
|
125
|
+
# User-supplied generation_kwargs go first so the framework-controlled keys below
|
|
126
|
+
# (model, messages, stream, tools, drop_params, credentials) always take precedence
|
|
127
|
+
# and can't be silently overridden.
|
|
128
|
+
return {
|
|
129
|
+
**merged_kwargs,
|
|
130
|
+
"model": self.model,
|
|
131
|
+
"messages": openai_messages,
|
|
132
|
+
"stream": streaming_callback is not None,
|
|
133
|
+
"tools": tool_defs,
|
|
134
|
+
"drop_params": True,
|
|
135
|
+
**extra,
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@component.output_types(replies=list[ChatMessage])
|
|
139
|
+
def run(
|
|
140
|
+
self,
|
|
141
|
+
messages: list[ChatMessage],
|
|
142
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
143
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
144
|
+
*,
|
|
145
|
+
tools: ToolsType | None = None,
|
|
146
|
+
) -> dict[str, list[ChatMessage]]:
|
|
147
|
+
"""Invoke chat completion via LiteLLM.
|
|
148
|
+
|
|
149
|
+
:param messages: Input messages as ChatMessage instances.
|
|
150
|
+
:param streaming_callback: Override the streaming callback for this call.
|
|
151
|
+
:param generation_kwargs: Override generation parameters for this call.
|
|
152
|
+
:param tools: Override tools for this call.
|
|
153
|
+
:returns: A dict with key ``replies`` containing ChatMessage instances.
|
|
154
|
+
"""
|
|
155
|
+
if not messages:
|
|
156
|
+
return {"replies": []}
|
|
157
|
+
|
|
158
|
+
import litellm
|
|
159
|
+
|
|
160
|
+
streaming_callback = select_streaming_callback(
|
|
161
|
+
init_callback=self.streaming_callback, runtime_callback=streaming_callback, requires_async=False
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
kwargs = self._build_litellm_kwargs(messages, streaming_callback, generation_kwargs, tools)
|
|
165
|
+
response = litellm.completion(**kwargs)
|
|
166
|
+
|
|
167
|
+
if streaming_callback is not None:
|
|
168
|
+
return {"replies": self._handle_streaming(response, streaming_callback)}
|
|
169
|
+
|
|
170
|
+
completions = [_build_chat_message(response, choice) for choice in response.choices]
|
|
171
|
+
return {"replies": completions}
|
|
172
|
+
|
|
173
|
+
@component.output_types(replies=list[ChatMessage])
|
|
174
|
+
async def run_async(
|
|
175
|
+
self,
|
|
176
|
+
messages: list[ChatMessage],
|
|
177
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
178
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
179
|
+
*,
|
|
180
|
+
tools: ToolsType | None = None,
|
|
181
|
+
) -> dict[str, list[ChatMessage]]:
|
|
182
|
+
"""Async version of run()."""
|
|
183
|
+
if not messages:
|
|
184
|
+
return {"replies": []}
|
|
185
|
+
|
|
186
|
+
import litellm
|
|
187
|
+
|
|
188
|
+
streaming_callback = select_streaming_callback(
|
|
189
|
+
init_callback=self.streaming_callback, runtime_callback=streaming_callback, requires_async=True
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
kwargs = self._build_litellm_kwargs(messages, streaming_callback, generation_kwargs, tools)
|
|
193
|
+
response = await litellm.acompletion(**kwargs)
|
|
194
|
+
|
|
195
|
+
if streaming_callback is not None:
|
|
196
|
+
return {"replies": await self._ahandle_streaming(response, streaming_callback)}
|
|
197
|
+
|
|
198
|
+
completions = [_build_chat_message(response, choice) for choice in response.choices]
|
|
199
|
+
return {"replies": completions}
|
|
200
|
+
|
|
201
|
+
def _handle_streaming(self, stream_response: Any, callback: SyncStreamingCallbackT) -> list[ChatMessage]:
|
|
202
|
+
component_info = ComponentInfo.from_component(self)
|
|
203
|
+
chunks: list[StreamingChunk] = []
|
|
204
|
+
for chunk in stream_response:
|
|
205
|
+
stream_chunk = _convert_litellm_chunk_to_streaming_chunk(chunk, chunks, component_info)
|
|
206
|
+
chunks.append(stream_chunk)
|
|
207
|
+
callback(stream_chunk)
|
|
208
|
+
return [_convert_streaming_chunks_to_chat_message(chunks=chunks)]
|
|
209
|
+
|
|
210
|
+
async def _ahandle_streaming(self, stream_response: Any, callback: AsyncStreamingCallbackT) -> list[ChatMessage]:
|
|
211
|
+
component_info = ComponentInfo.from_component(self)
|
|
212
|
+
chunks: list[StreamingChunk] = []
|
|
213
|
+
async for chunk in stream_response:
|
|
214
|
+
stream_chunk = _convert_litellm_chunk_to_streaming_chunk(chunk, chunks, component_info)
|
|
215
|
+
chunks.append(stream_chunk)
|
|
216
|
+
await callback(stream_chunk)
|
|
217
|
+
return [_convert_streaming_chunks_to_chat_message(chunks=chunks)]
|
|
218
|
+
|
|
219
|
+
def to_dict(self) -> dict[str, Any]:
|
|
220
|
+
"""Serialize this component to a dictionary."""
|
|
221
|
+
callback_name = serialize_callable(self.streaming_callback) if self.streaming_callback else None
|
|
222
|
+
return default_to_dict(
|
|
223
|
+
self,
|
|
224
|
+
model=self.model,
|
|
225
|
+
api_key=self.api_key.to_dict() if self.api_key else None,
|
|
226
|
+
streaming_callback=callback_name,
|
|
227
|
+
api_base_url=self.api_base_url,
|
|
228
|
+
generation_kwargs=self.generation_kwargs,
|
|
229
|
+
tools=serialize_tools_or_toolset(self.tools),
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
@classmethod
|
|
233
|
+
def from_dict(cls, data: dict[str, Any]) -> "LiteLLMChatGenerator":
|
|
234
|
+
"""Deserialize a component from a dictionary."""
|
|
235
|
+
deserialize_secrets_inplace(data["init_parameters"], keys=["api_key"])
|
|
236
|
+
deserialize_tools_or_toolset_inplace(data["init_parameters"], key="tools")
|
|
237
|
+
if data["init_parameters"].get("streaming_callback"):
|
|
238
|
+
data["init_parameters"]["streaming_callback"] = deserialize_callable(
|
|
239
|
+
data["init_parameters"]["streaming_callback"]
|
|
240
|
+
)
|
|
241
|
+
return default_from_dict(cls, data)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
# LiteLLM normalizes provider finish reasons to OpenAI's vocabulary, but we still map
|
|
245
|
+
# explicitly so the value matches Haystack's FinishReason literal.
|
|
246
|
+
_FINISH_REASON_MAPPING: dict[str, FinishReason] = {
|
|
247
|
+
"stop": "stop",
|
|
248
|
+
"length": "length",
|
|
249
|
+
"content_filter": "content_filter",
|
|
250
|
+
"tool_calls": "tool_calls",
|
|
251
|
+
"function_call": "tool_calls",
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _extract_usage(obj: Any) -> dict[str, int]:
|
|
256
|
+
"""Pull token usage off a litellm response or chunk, tolerating its absence."""
|
|
257
|
+
usage = getattr(obj, "usage", None)
|
|
258
|
+
if not usage:
|
|
259
|
+
return {}
|
|
260
|
+
return {
|
|
261
|
+
"prompt_tokens": getattr(usage, "prompt_tokens", 0),
|
|
262
|
+
"completion_tokens": getattr(usage, "completion_tokens", 0),
|
|
263
|
+
"total_tokens": getattr(usage, "total_tokens", 0),
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def _build_chat_message(response: Any, choice: Any) -> ChatMessage:
|
|
268
|
+
"""Convert a single litellm choice into a haystack ChatMessage."""
|
|
269
|
+
message = choice.message
|
|
270
|
+
|
|
271
|
+
# Keep content as-is (None for tool-only replies) so we don't attach an empty text block,
|
|
272
|
+
# matching both Haystack's OpenAI generator and our own streaming aggregation.
|
|
273
|
+
text = message.content
|
|
274
|
+
|
|
275
|
+
tool_calls = []
|
|
276
|
+
if getattr(message, "tool_calls", None):
|
|
277
|
+
for tc in message.tool_calls:
|
|
278
|
+
arguments = tc.function.arguments
|
|
279
|
+
if isinstance(arguments, str):
|
|
280
|
+
try:
|
|
281
|
+
arguments = json.loads(arguments)
|
|
282
|
+
except json.JSONDecodeError:
|
|
283
|
+
logger.warning(
|
|
284
|
+
"The LLM provider returned a malformed JSON string for tool call arguments. This tool "
|
|
285
|
+
"call will be skipped. Tool call ID: {_id}, Tool name: {_name}, Arguments: {_arguments}",
|
|
286
|
+
_id=tc.id,
|
|
287
|
+
_name=tc.function.name,
|
|
288
|
+
_arguments=arguments,
|
|
289
|
+
)
|
|
290
|
+
continue
|
|
291
|
+
tool_calls.append(ToolCall(tool_name=tc.function.name, arguments=arguments, id=tc.id))
|
|
292
|
+
|
|
293
|
+
meta: dict[str, Any] = {
|
|
294
|
+
"model": response.model,
|
|
295
|
+
"index": choice.index,
|
|
296
|
+
"finish_reason": choice.finish_reason,
|
|
297
|
+
"usage": _extract_usage(response),
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return ChatMessage.from_assistant(text=text, tool_calls=tool_calls, meta=meta)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def _convert_litellm_chunk_to_streaming_chunk(
|
|
304
|
+
chunk: Any, previous_chunks: list[StreamingChunk], component_info: ComponentInfo
|
|
305
|
+
) -> StreamingChunk:
|
|
306
|
+
"""Convert a single litellm streaming chunk into a Haystack ``StreamingChunk``.
|
|
307
|
+
|
|
308
|
+
The structured fields (``tool_calls``, ``finish_reason``, ``index``) are populated so that
|
|
309
|
+
``_convert_streaming_chunks_to_chat_message`` can reconstruct tool calls and metadata; it reads
|
|
310
|
+
those fields, not ``meta``. LiteLLM returns OpenAI-compatible chunks, but unlike the OpenAI SDK
|
|
311
|
+
its chunk objects don't always expose a ``usage`` attribute, so it is accessed defensively.
|
|
312
|
+
"""
|
|
313
|
+
usage = _extract_usage(chunk) or None
|
|
314
|
+
|
|
315
|
+
# Final usage-only chunk: no choices, just aggregate token counts.
|
|
316
|
+
if not chunk.choices:
|
|
317
|
+
return StreamingChunk(
|
|
318
|
+
content="",
|
|
319
|
+
component_info=component_info,
|
|
320
|
+
index=None,
|
|
321
|
+
finish_reason=None,
|
|
322
|
+
meta={"model": chunk.model, "usage": usage},
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
choice = chunk.choices[0]
|
|
326
|
+
delta = choice.delta
|
|
327
|
+
finish_reason = _FINISH_REASON_MAPPING.get(choice.finish_reason) if choice.finish_reason else None
|
|
328
|
+
meta: dict[str, Any] = {
|
|
329
|
+
"model": chunk.model,
|
|
330
|
+
"index": choice.index,
|
|
331
|
+
"finish_reason": choice.finish_reason,
|
|
332
|
+
"usage": usage,
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
tool_calls = getattr(delta, "tool_calls", None) if delta else None
|
|
336
|
+
if tool_calls:
|
|
337
|
+
tool_call_deltas = []
|
|
338
|
+
for tc in tool_calls:
|
|
339
|
+
function = tc.function
|
|
340
|
+
tool_call_deltas.append(
|
|
341
|
+
ToolCallDelta(
|
|
342
|
+
index=tc.index,
|
|
343
|
+
id=tc.id,
|
|
344
|
+
tool_name=function.name if function else None,
|
|
345
|
+
arguments=function.arguments if function and function.arguments else None,
|
|
346
|
+
)
|
|
347
|
+
)
|
|
348
|
+
return StreamingChunk(
|
|
349
|
+
content=(delta.content or "") if delta else "",
|
|
350
|
+
component_info=component_info,
|
|
351
|
+
# ToolCallDelta requires an index; adopt the first one as the chunk index.
|
|
352
|
+
index=tool_call_deltas[0].index,
|
|
353
|
+
tool_calls=tool_call_deltas,
|
|
354
|
+
start=tool_call_deltas[0].tool_name is not None,
|
|
355
|
+
finish_reason=finish_reason,
|
|
356
|
+
meta=meta,
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
content = (delta.content or "") if delta else ""
|
|
360
|
+
# The opening chunk only carries role info (no content), so it isn't a content block.
|
|
361
|
+
role = getattr(delta, "role", None) if delta else None
|
|
362
|
+
resolved_index = None if (delta is None or delta.content is None or role is not None) else 0
|
|
363
|
+
|
|
364
|
+
return StreamingChunk(
|
|
365
|
+
content=content,
|
|
366
|
+
component_info=component_info,
|
|
367
|
+
index=resolved_index,
|
|
368
|
+
start=len(previous_chunks) == 1,
|
|
369
|
+
finish_reason=finish_reason,
|
|
370
|
+
meta=meta,
|
|
371
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: litellm-haystack
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: An integration of LiteLLM AI gateway into the Haystack framework, routing to 100+ LLM providers.
|
|
5
|
+
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/litellm#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
7
|
+
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/litellm
|
|
8
|
+
Author-email: deepset GmbH <info@deepset.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Keywords: ai-gateway,haystack,litellm,llm
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: haystack-ai>=2.24.1
|
|
23
|
+
Requires-Dist: litellm!=1.82.7,!=1.82.8,<2.0,>=1.60.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# litellm-haystack
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/litellm-haystack)
|
|
29
|
+
[](https://pypi.org/project/litellm-haystack)
|
|
30
|
+
|
|
31
|
+
- [Integration page](https://haystack.deepset.ai/integrations/litellm)
|
|
32
|
+
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/litellm/CHANGELOG.md)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
39
|
+
|
|
40
|
+
To run integration tests locally, you need to export the `OPENAI_API_KEY` environment variable.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
haystack_integrations/components/generators/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
haystack_integrations/components/generators/litellm/__init__.py,sha256=hQd8gcnsJ4q7m2Rf7bUJ5aQoSxCoRWywN80H7b7nzDE,252
|
|
3
|
+
haystack_integrations/components/generators/litellm/chat/__init__.py,sha256=VALygJTedw73b2nmHRIZtsuYEpqTkoIS7qgP0MDfJe8,110
|
|
4
|
+
haystack_integrations/components/generators/litellm/chat/chat_generator.py,sha256=MIXdfTBzzcW7YErOSvF3WZAhNmxlq9k-5zs9jA5Ul1Y,14761
|
|
5
|
+
litellm_haystack-1.0.0.dist-info/METADATA,sha256=v83HIdLXJCLsu9Z_VxEDEDjtrk5k0Ao8IzlVyzqF4l4,1963
|
|
6
|
+
litellm_haystack-1.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
7
|
+
litellm_haystack-1.0.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
|
|
8
|
+
litellm_haystack-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
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
|
+
|
|
61
|
+
Copyright [yyyy] [name of copyright owner]
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|