ollama-haystack 3.2.0__tar.gz → 3.3.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.
Files changed (24) hide show
  1. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/CHANGELOG.md +7 -0
  2. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/PKG-INFO +1 -1
  3. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/pyproject.toml +7 -15
  4. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/src/haystack_integrations/components/embedders/ollama/document_embedder.py +9 -5
  5. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/src/haystack_integrations/components/embedders/ollama/text_embedder.py +7 -3
  6. ollama_haystack-3.3.0/src/haystack_integrations/components/generators/ollama/chat/__init__.py +0 -0
  7. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/src/haystack_integrations/components/generators/ollama/chat/chat_generator.py +9 -8
  8. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/src/haystack_integrations/components/generators/ollama/generator.py +2 -2
  9. ollama_haystack-3.3.0/src/haystack_integrations/components/generators/py.typed +0 -0
  10. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/.gitignore +0 -0
  11. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/LICENSE.txt +0 -0
  12. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/README.md +0 -0
  13. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/examples/chat_generator_example.py +0 -0
  14. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/examples/embedders_example.py +0 -0
  15. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/examples/generator_example.py +0 -0
  16. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/pydoc/config.yml +0 -0
  17. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/src/haystack_integrations/components/embedders/ollama/__init__.py +0 -0
  18. /ollama_haystack-3.2.0/src/haystack_integrations/components/generators/ollama/chat/__init__.py → /ollama_haystack-3.3.0/src/haystack_integrations/components/embedders/py.typed +0 -0
  19. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/src/haystack_integrations/components/generators/ollama/__init__.py +0 -0
  20. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/tests/__init__.py +0 -0
  21. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/tests/test_chat_generator.py +0 -0
  22. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/tests/test_document_embedder.py +0 -0
  23. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/tests/test_generator.py +0 -0
  24. {ollama_haystack-3.2.0 → ollama_haystack-3.3.0}/tests/test_text_embedder.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/ollama-v3.2.0] - 2025-06-10
4
+
5
+ ### 🚀 Features
6
+
7
+ - Add run_async support for OllamaDocumentEmbedder (#1878)
8
+
9
+
3
10
  ## [integrations/ollama-v3.1.0] - 2025-06-10
4
11
 
5
12
  ### 🚀 Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ollama-haystack
3
- Version: 3.2.0
3
+ Version: 3.3.0
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
@@ -71,18 +71,14 @@ integration = 'pytest -m "integration" {args:tests}'
71
71
  all = 'pytest {args:tests}'
72
72
  cov-retry = 'all --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x'
73
73
 
74
- types = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
74
+ types = """mypy -p haystack_integrations.components.embedders.ollama \
75
+ -p haystack_integrations.components.generators.ollama {args}"""
75
76
 
76
- # TODO: remove lint environment once this integration is properly typed
77
- # test environment should be used instead
78
- # https://github.com/deepset-ai/haystack-core-integrations/issues/1771
79
- [tool.hatch.envs.lint]
80
- installer = "uv"
81
- detached = true
82
- dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
83
-
84
- [tool.hatch.envs.lint.scripts]
85
- typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
77
+ [tool.mypy]
78
+ install_types = true
79
+ non_interactive = true
80
+ check_untyped_defs = true
81
+ disallow_incomplete_defs = true
86
82
 
87
83
  [tool.hatch.metadata]
88
84
  allow-direct-references = true
@@ -173,7 +169,3 @@ log_cli = true
173
169
  addopts = ["--import-mode=importlib"]
174
170
  asyncio_mode = "auto"
175
171
  asyncio_default_fixture_loop_scope = "class"
176
-
177
- [[tool.mypy.overrides]]
178
- module = ["haystack.*", "haystack_integrations.*", "pytest.*", "ollama.*", "pydantic.*"]
179
- ignore_missing_imports = true
@@ -1,5 +1,5 @@
1
1
  import asyncio
2
- from typing import Any, Dict, List, Optional
2
+ from typing import Any, Dict, List, Optional, Union
3
3
 
4
4
  from haystack import Document, component
5
5
  from tqdm import tqdm
@@ -114,7 +114,7 @@ class OllamaDocumentEmbedder:
114
114
 
115
115
  def _embed_batch(
116
116
  self, texts_to_embed: List[str], batch_size: int, generation_kwargs: Optional[Dict[str, Any]] = None
117
- ):
117
+ ) -> List[List[float]]:
118
118
  """
119
119
  Internal method to embed a batch of texts.
120
120
  """
@@ -132,7 +132,7 @@ class OllamaDocumentEmbedder:
132
132
 
133
133
  async def _embed_batch_async(
134
134
  self, texts_to_embed: List[str], batch_size: int, generation_kwargs: Optional[Dict[str, Any]] = None
135
- ):
135
+ ) -> List[List[float]]:
136
136
  """
137
137
  Internal method to embed a batch of texts asynchronously.
138
138
  """
@@ -160,7 +160,9 @@ class OllamaDocumentEmbedder:
160
160
  return all_embeddings
161
161
 
162
162
  @component.output_types(documents=List[Document], meta=Dict[str, Any])
163
- def run(self, documents: List[Document], generation_kwargs: Optional[Dict[str, Any]] = None):
163
+ def run(
164
+ self, documents: List[Document], generation_kwargs: Optional[Dict[str, Any]] = None
165
+ ) -> Dict[str, Union[List[Document], Dict[str, Any]]]:
164
166
  """
165
167
  Runs an Ollama Model to compute embeddings of the provided documents.
166
168
 
@@ -193,7 +195,9 @@ class OllamaDocumentEmbedder:
193
195
  return {"documents": documents, "meta": {"model": self.model}}
194
196
 
195
197
  @component.output_types(documents=List[Document], meta=Dict[str, Any])
196
- async def run_async(self, documents: List[Document], generation_kwargs: Optional[Dict[str, Any]] = None):
198
+ async def run_async(
199
+ self, documents: List[Document], generation_kwargs: Optional[Dict[str, Any]] = None
200
+ ) -> Dict[str, Union[List[Document], Dict[str, Any]]]:
197
201
  """
198
202
  Asynchronously run an Ollama Model to compute embeddings of the provided documents.
199
203
 
@@ -1,4 +1,4 @@
1
- from typing import Any, Dict, List, Optional
1
+ from typing import Any, Dict, List, Optional, Union
2
2
 
3
3
  from haystack import component
4
4
 
@@ -49,7 +49,9 @@ class OllamaTextEmbedder:
49
49
  self._async_client = AsyncClient(host=self.url, timeout=self.timeout)
50
50
 
51
51
  @component.output_types(embedding=List[float], meta=Dict[str, Any])
52
- def run(self, text: str, generation_kwargs: Optional[Dict[str, Any]] = None):
52
+ def run(
53
+ self, text: str, generation_kwargs: Optional[Dict[str, Any]] = None
54
+ ) -> Dict[str, Union[List[float], Dict[str, Any]]]:
53
55
  """
54
56
  Runs an Ollama Model to compute embeddings of the provided text.
55
57
 
@@ -69,7 +71,9 @@ class OllamaTextEmbedder:
69
71
  return result
70
72
 
71
73
  @component.output_types(embedding=List[float], meta=Dict[str, Any])
72
- async def run_async(self, text: str, generation_kwargs: Optional[Dict[str, Any]] = None):
74
+ async def run_async(
75
+ self, text: str, generation_kwargs: Optional[Dict[str, Any]] = None
76
+ ) -> Dict[str, Union[List[float], Dict[str, Any]]]:
73
77
  """
74
78
  Asynchronously run an Ollama Model to compute embeddings of the provided text.
75
79
 
@@ -220,7 +220,7 @@ class OllamaChatGenerator:
220
220
  - JSON Schema: The response is formatted as a JSON object
221
221
  that adheres to the specified JSON Schema. (needs Ollama ≥ 0.1.34)
222
222
  """
223
- _check_duplicate_tool_names(tools)
223
+ _check_duplicate_tool_names(list(tools or []))
224
224
 
225
225
  self.model = model
226
226
  self.url = url
@@ -361,10 +361,11 @@ class OllamaChatGenerator:
361
361
  # Compose final reply
362
362
  text = "".join(c.content for c in chunks)
363
363
 
364
- tool_calls = [
365
- ToolCall(tool_name=name_by_id[tool_call_id], arguments=arg_by_id.get(tool_call_id))
366
- for tool_call_id in id_order
367
- ]
364
+ tool_calls = []
365
+ for tool_call_id in id_order:
366
+ arguments = arg_by_id.get(tool_call_id, {})
367
+ assert isinstance(arguments, dict) # final arguments are a dictionary # noqa: S101
368
+ tool_calls.append(ToolCall(tool_name=name_by_id[tool_call_id], arguments=arguments))
368
369
 
369
370
  reply = ChatMessage.from_assistant(
370
371
  text=text,
@@ -381,7 +382,7 @@ class OllamaChatGenerator:
381
382
  tools: Optional[Union[List[Tool], Toolset]] = None,
382
383
  *,
383
384
  streaming_callback: Optional[Callable[[StreamingChunk], None]] = None,
384
- ):
385
+ ) -> Dict[str, List[ChatMessage]]:
385
386
  """
386
387
  Runs an Ollama Model on a given chat history.
387
388
 
@@ -405,7 +406,7 @@ class OllamaChatGenerator:
405
406
  """
406
407
  generation_kwargs = {**self.generation_kwargs, **(generation_kwargs or {})}
407
408
  tools = tools or self.tools
408
- _check_duplicate_tool_names(tools)
409
+ _check_duplicate_tool_names(list(tools or []))
409
410
 
410
411
  # Convert Toolset → list[Tool] for JSON serialization
411
412
  if isinstance(tools, Toolset):
@@ -421,7 +422,7 @@ class OllamaChatGenerator:
421
422
  model=self.model,
422
423
  messages=ollama_messages,
423
424
  tools=ollama_tools,
424
- stream=is_stream,
425
+ stream=is_stream, # type: ignore[call-overload] # Ollama expects Literal[True] or Literal[False], not bool
425
426
  keep_alive=self.keep_alive,
426
427
  options=generation_kwargs,
427
428
  format=self.response_format,
@@ -239,7 +239,7 @@ class OllamaGenerator:
239
239
  generation_kwargs: Optional[Dict[str, Any]] = None,
240
240
  *,
241
241
  streaming_callback: Optional[Callable[[StreamingChunk], None]] = None,
242
- ):
242
+ ) -> Dict[str, List[Any]]:
243
243
  """
244
244
  Runs an Ollama Model on the given prompt.
245
245
 
@@ -263,7 +263,7 @@ class OllamaGenerator:
263
263
  response = self._client.generate(
264
264
  model=self.model,
265
265
  prompt=prompt,
266
- stream=stream,
266
+ stream=stream, # type: ignore[call-overload] # Ollama expects Literal[True] or Literal[False], not bool
267
267
  keep_alive=self.keep_alive,
268
268
  options=generation_kwargs,
269
269
  )