ollama-haystack 2.4.1__tar.gz → 2.4.2__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.
Files changed (22) hide show
  1. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/CHANGELOG.md +11 -93
  2. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/PKG-INFO +1 -1
  3. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/generators/ollama/chat/chat_generator.py +9 -3
  4. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/tests/test_chat_generator.py +16 -0
  5. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/.gitignore +0 -0
  6. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/LICENSE.txt +0 -0
  7. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/README.md +0 -0
  8. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/examples/chat_generator_example.py +0 -0
  9. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/examples/embedders_example.py +0 -0
  10. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/examples/generator_example.py +0 -0
  11. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/pydoc/config.yml +0 -0
  12. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/pyproject.toml +0 -0
  13. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/embedders/ollama/__init__.py +0 -0
  14. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/embedders/ollama/document_embedder.py +0 -0
  15. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/embedders/ollama/text_embedder.py +0 -0
  16. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/generators/ollama/__init__.py +0 -0
  17. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/generators/ollama/chat/__init__.py +0 -0
  18. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/src/haystack_integrations/components/generators/ollama/generator.py +0 -0
  19. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/tests/__init__.py +0 -0
  20. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/tests/test_document_embedder.py +0 -0
  21. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/tests/test_generator.py +0 -0
  22. {ollama_haystack-2.4.1 → ollama_haystack-2.4.2}/tests/test_text_embedder.py +0 -0
@@ -1,286 +1,204 @@
1
1
  # Changelog
2
2
 
3
- ## [integrations/ollama-v2.4.0] - 2025-04-04
4
-
3
+ ## [integrations/ollama-v2.4.1] - 2025-04-10
5
4
 
6
5
  ### 🚀 Features
7
6
 
7
+ - Add `streaming_callback` to run methods of OllamaGenerator and OllamaChatGenerator (#1636)
8
8
 
9
- - Adapt Ollama metadata to OpenAI format; support Ollama in Langfuse (#1577)
9
+ ### 🧹 Chores
10
10
 
11
+ - Update ChatGenerators with `deserialize_tools_or_toolset_inplace` (#1623)
11
12
 
12
- ### 🧪 Testing
13
13
 
14
+ ## [integrations/ollama-v2.4.0] - 2025-04-04
14
15
 
15
- - Update tool serialization in tests to include `inputs_from_state` and `outputs_to_state` (#1581)
16
+ ### 🚀 Features
16
17
 
18
+ - Adapt Ollama metadata to OpenAI format; support Ollama in Langfuse (#1577)
17
19
 
18
- ### ⚙️ CI
20
+ ### 🧪 Testing
19
21
 
22
+ - Update tool serialization in tests to include `inputs_from_state` and `outputs_to_state` (#1581)
20
23
 
21
- - Review testing workflows (#1541)
24
+ ### ⚙️ CI
22
25
 
26
+ - Review testing workflows (#1541)
23
27
 
24
28
  ### 🧹 Chores
25
29
 
26
-
27
30
  - Remove Python 3.8 support (#1421)
28
31
 
29
-
30
32
  ### 🌀 Miscellaneous
31
33
 
32
-
33
-
34
34
  - Chore: remove `jsonschema` dependency from `default` environment (#1368)
35
-
36
35
  - Test: Update tests to check for `outputs_to_string` in Tool when running haystack-ai>=2.12 (#1585)
37
36
 
38
37
  ## [integrations/ollama-v2.3.0] - 2025-01-29
39
38
 
40
-
41
39
  ### 🚀 Features
42
40
 
43
-
44
41
  - Add `response_format` param to `OllamaChatGenerator` (#1326)
45
42
 
46
43
 
47
-
48
44
  ## [integrations/ollama-v2.2.0] - 2025-01-16
49
45
 
50
-
51
46
  ### 🚀 Features
52
47
 
53
-
54
48
  - Ollama - add support for tools (#1294)
55
49
 
56
50
 
57
-
58
51
  ## [integrations/ollama-v2.1.2] - 2024-12-18
59
52
 
60
-
61
53
  ### 🐛 Bug Fixes
62
54
 
63
-
64
55
  - Make Ollama Chat Generator compatible with new ChatMessage (#1256)
65
56
 
66
57
 
67
-
68
58
  ## [integrations/ollama-v2.1.1] - 2024-12-10
69
59
 
70
-
71
60
  ### 🌀 Miscellaneous
72
61
 
73
-
74
-
75
62
  - Chore: use `text` instead of `content` for `ChatMessage` in Ollama (#1239)
76
63
 
77
64
  ## [integrations/ollama-v2.1.0] - 2024-11-28
78
65
 
79
-
80
66
  ### 🚀 Features
81
67
 
82
-
83
68
  - `OllamaDocumentEmbedder` - allow batching embeddings (#1224)
84
69
 
85
-
86
70
  ### 🌀 Miscellaneous
87
71
 
88
-
89
72
  - Chore: update changelog for `ollama-haystack==2.0.0` (#1214)
90
-
91
73
  - Chore: use class methods to create `ChatMessage` (#1222)
92
74
 
93
75
  ## [integrations/ollama-v2.0.0] - 2024-11-22
94
76
 
95
-
96
77
  ### 🐛 Bug Fixes
97
78
 
98
-
99
79
  - Adapt to Ollama client 0.4.0 (#1209)
100
80
 
101
-
102
81
  ### ⚙️ CI
103
82
 
104
-
105
83
  - Adopt uv as installer (#1142)
106
84
 
107
85
 
108
-
109
86
  ## [integrations/ollama-v1.1.0] - 2024-10-11
110
87
 
111
-
112
88
  ### 🚀 Features
113
89
 
114
-
115
90
  - Add `keep_alive` parameter to Ollama Generators (#1131)
116
91
 
117
-
118
92
  ### 🧹 Chores
119
93
 
120
-
121
94
  - Update ruff linting scripts and settings (#1105)
122
95
 
123
96
 
124
-
125
97
  ## [integrations/ollama-v1.0.1] - 2024-09-26
126
98
 
127
-
128
99
  ### 🐛 Bug Fixes
129
100
 
130
-
131
101
  - Ollama Chat Generator - add missing `to_dict` and `from_dict` methods (#1110)
132
102
 
133
103
 
134
-
135
104
  ## [integrations/ollama-v1.0.0] - 2024-09-07
136
105
 
137
-
138
106
  ### 🐛 Bug Fixes
139
107
 
140
-
141
108
  - Chat roles for model responses in chat generators (#1030)
142
109
 
143
-
144
110
  ### 🚜 Refactor
145
111
 
146
-
147
112
  - [**breaking**] Use ollama python library instead of calling the API with `requests` (#1059)
148
113
 
149
-
150
114
  ### 🧪 Testing
151
115
 
152
-
153
116
  - Do not retry tests in `hatch run test` command (#954)
154
117
 
155
-
156
118
  ### ⚙️ CI
157
119
 
158
-
159
120
  - Retry tests to reduce flakyness (#836)
160
121
 
161
-
162
122
  ### 🧹 Chores
163
123
 
164
-
165
124
  - Update ruff invocation to include check parameter (#853)
166
125
 
167
-
168
126
  ### 🌀 Miscellaneous
169
127
 
170
-
171
-
172
128
  - Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
173
-
174
129
  - Chore: ollama - ruff update, don't ruff tests (#985)
175
130
 
176
131
  ## [integrations/ollama-v0.0.7] - 2024-05-31
177
132
 
178
-
179
133
  ### 🚀 Features
180
134
 
181
-
182
135
  - Add streaming support to OllamaChatGenerator (#757)
183
136
 
184
-
185
137
  ### 🌀 Miscellaneous
186
138
 
187
-
188
139
  - Chore: add license classifiers (#680)
189
-
190
140
  - Chore: change the pydoc renderer class (#718)
191
141
 
192
142
  ## [integrations/ollama-v0.0.6] - 2024-04-18
193
143
 
194
-
195
144
  ### 📚 Documentation
196
145
 
197
-
198
146
  - Disable-class-def (#556)
199
147
 
200
-
201
148
  ### 🧹 Chores
202
149
 
203
-
204
150
  - Update docstrings (#499)
205
151
 
206
-
207
152
  ### 🌀 Miscellaneous
208
153
 
209
-
210
154
  - Update API docs adding embedders (#494)
211
-
212
155
  - Change testing workflow (#551)
213
-
214
156
  - Remove references to Python 3.7 (#601)
215
-
216
157
  - Add ollama embedder example (#669)
217
-
218
158
  - Fix: change ollama output name to 'meta' (#670)
219
159
 
220
160
  ## [integrations/ollama-v0.0.5] - 2024-02-28
221
161
 
222
-
223
162
  ### 🐛 Bug Fixes
224
163
 
225
-
226
164
  - Fix order of API docs (#447)
227
165
 
228
-
229
166
  ### 📚 Documentation
230
167
 
231
-
232
168
  - Update category slug (#442)
233
169
 
234
-
235
170
  ### 🧹 Chores
236
171
 
237
-
238
172
  - Use `serialize_callable` instead of `serialize_callback_handler` in Ollama (#461)
239
173
 
240
-
241
174
  ### 🌀 Miscellaneous
242
175
 
243
-
244
176
  - Ollama document embedder (#400)
245
-
246
177
  - Changed Default Ollama Embedding models to supported model: nomic-embed-text (#490)
247
178
 
248
179
  ## [integrations/ollama-v0.0.4] - 2024-02-12
249
180
 
250
-
251
181
  ### 🌀 Miscellaneous
252
182
 
253
-
254
183
  - Ollama: add license (#219)
255
-
256
184
  - Generate api docs (#332)
257
-
258
185
  - Ollama Text Embedder with new format (#252)
259
-
260
186
  - Support for streaming ollama generator (#280)
261
187
 
262
188
  ## [integrations/ollama-v0.0.3] - 2024-01-16
263
189
 
264
-
265
190
  ### 🌀 Miscellaneous
266
191
 
267
-
268
192
  - Docs: Ollama docstrings update (#171)
269
-
270
193
  - Add example of OllamaGenerator (#170)
271
-
272
194
  - Ollama Chat Generator (#176)
273
-
274
195
  - Ollama: improve test (#191)
275
-
276
196
  - Mount Ollama in haystack_integrations (#216)
277
197
 
278
198
  ## [integrations/ollama-v0.0.1] - 2024-01-03
279
199
 
280
-
281
200
  ### 🌀 Miscellaneous
282
201
 
283
-
284
202
  - Ollama Integration (#132)
285
203
 
286
204
  <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ollama-haystack
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: An integration between the Ollama LLM framework and Haystack
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/ollama#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -271,10 +271,16 @@ class OllamaChatGenerator:
271
271
  if streaming_callback is not None:
272
272
  streaming_callback(chunk_delta)
273
273
 
274
- replies = [ChatMessage.from_assistant("".join([c.content for c in chunks]))]
275
- meta = {key: value for key, value in chunks[0].meta.items() if key != "message"}
274
+ # Create the ChatMessage with the combined content
275
+ combined_text = "".join([c.content for c in chunks])
276
+ reply = ChatMessage.from_assistant(combined_text)
276
277
 
277
- return {"replies": replies, "meta": [meta]}
278
+ # Convert the last chunk's metadata to OpenAI format and attach it to the ChatMessage
279
+ if chunks:
280
+ meta = _convert_ollama_meta_to_openai_format(chunks[-1].meta)
281
+ reply._meta = meta
282
+
283
+ return {"replies": [reply]}
278
284
 
279
285
  @component.output_types(replies=List[ChatMessage])
280
286
  def run(
@@ -418,6 +418,14 @@ class TestOllamaChatGenerator:
418
418
  assert result["replies"][0].text == "first chunk second chunk"
419
419
  assert result["replies"][0].role == "assistant"
420
420
 
421
+ # Verify metadata is properly processed and includes usage information
422
+ assert hasattr(result["replies"][0], "_meta")
423
+ assert result["replies"][0]._meta["done"] is True
424
+ assert "usage" in result["replies"][0]._meta
425
+ assert result["replies"][0]._meta["usage"]["prompt_tokens"] == 26
426
+ assert result["replies"][0]._meta["usage"]["completion_tokens"] == 282
427
+ assert result["replies"][0]._meta["usage"]["total_tokens"] == 308
428
+
421
429
  @patch("haystack_integrations.components.generators.ollama.chat.chat_generator.Client")
422
430
  def test_run_streaming_at_runtime(self, mock_client):
423
431
  streaming_callback_called = False
@@ -463,6 +471,14 @@ class TestOllamaChatGenerator:
463
471
  assert result["replies"][0].text == "first chunk second chunk"
464
472
  assert result["replies"][0].role == "assistant"
465
473
 
474
+ # Verify metadata is properly processed and includes usage information
475
+ assert hasattr(result["replies"][0], "_meta")
476
+ assert result["replies"][0]._meta["done"] is True
477
+ assert "usage" in result["replies"][0]._meta
478
+ assert result["replies"][0]._meta["usage"]["prompt_tokens"] == 26
479
+ assert result["replies"][0]._meta["usage"]["completion_tokens"] == 282
480
+ assert result["replies"][0]._meta["usage"]["total_tokens"] == 308
481
+
466
482
  def test_run_fail_with_tools_and_streaming(self, tools):
467
483
  component = OllamaChatGenerator(tools=tools, streaming_callback=print_streaming_chunk)
468
484