google-genai-haystack 7.2.1__tar.gz → 7.2.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.
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/CHANGELOG.md +7 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/PKG-INFO +1 -1
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/chat_generator.py +10 -8
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_chat_generator.py +59 -11
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/.gitignore +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/LICENSE.txt +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/README.md +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/examples/chatgenerator_example.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/pydoc/config_docusaurus.yml +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/pyproject.toml +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/common/google_genai/__init__.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/common/google_genai/utils.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/common/py.typed +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/__init__.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/document_embedder.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/multimodal_document_embedder.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/google_genai/text_embedder.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/embedders/py.typed +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/__init__.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/interactions_chat_generator.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/interactions_utils.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/google_genai/chat/utils.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/components/generators/py.typed +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/token_counters/google_genai/__init__.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/token_counters/google_genai/token_counter.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/src/haystack_integrations/token_counters/py.typed +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/conftest.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_chat_generator_utils.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_document_embedder.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_files/apple.jpg +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_files/banana.png +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_files/sample_docx.docx +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_files/sample_pdf_3.pdf +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_interactions_chat_generator.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_interactions_chat_generator_utils.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_multimodal_document_embedder.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_text_embedder.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_token_counter.py +0 -0
- {google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: google-genai-haystack
|
|
3
|
-
Version: 7.2.
|
|
3
|
+
Version: 7.2.2
|
|
4
4
|
Summary: Use models like Gemini via Google Gen AI SDK
|
|
5
5
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/google_genai#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
@@ -458,11 +458,12 @@ class GoogleGenAIChatGenerator:
|
|
|
458
458
|
keys set only at initialization are kept. Supports `thinking_budget` for Gemini 2.5 series
|
|
459
459
|
thinking configuration.
|
|
460
460
|
:param safety_settings: Safety settings for content filtering. If provided, it will override the
|
|
461
|
-
default settings.
|
|
461
|
+
default settings. Pass an empty list to send no safety settings for this call.
|
|
462
462
|
:param streaming_callback: A callback function that is called when a new token is
|
|
463
463
|
received from the stream.
|
|
464
464
|
:param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
|
|
465
|
-
If provided, it will override the tools set during initialization.
|
|
465
|
+
If provided, it will override the tools set during initialization. Pass an empty list to disable tools for
|
|
466
|
+
this call.
|
|
466
467
|
:returns: A dictionary with the following keys:
|
|
467
468
|
- `replies`: A list containing the generated ChatMessage responses.
|
|
468
469
|
|
|
@@ -476,8 +477,8 @@ class GoogleGenAIChatGenerator:
|
|
|
476
477
|
messages = _normalize_messages(messages)
|
|
477
478
|
# Merge generation_kwargs with instance defaults; other configs fall back to instance defaults
|
|
478
479
|
generation_kwargs = {**self._generation_kwargs, **(generation_kwargs or {})}
|
|
479
|
-
safety_settings = safety_settings
|
|
480
|
-
tools = tools
|
|
480
|
+
safety_settings = safety_settings if safety_settings is not None else self._safety_settings
|
|
481
|
+
tools = tools if tools is not None else self._tools
|
|
481
482
|
|
|
482
483
|
# Process thinking configuration and response format
|
|
483
484
|
generation_kwargs = _process_thinking_config(generation_kwargs)
|
|
@@ -576,11 +577,12 @@ class GoogleGenAIChatGenerator:
|
|
|
576
577
|
thinking configuration.
|
|
577
578
|
See https://ai.google.dev/gemini-api/docs/thinking for possible values.
|
|
578
579
|
:param safety_settings: Safety settings for content filtering. If provided, it will override the
|
|
579
|
-
default settings.
|
|
580
|
+
default settings. Pass an empty list to send no safety settings for this call.
|
|
580
581
|
:param streaming_callback: A callback function that is called when a new token is
|
|
581
582
|
received from the stream.
|
|
582
583
|
:param tools: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
|
|
583
|
-
If provided, it will override the tools set during initialization.
|
|
584
|
+
If provided, it will override the tools set during initialization. Pass an empty list to disable tools for
|
|
585
|
+
this call.
|
|
584
586
|
:returns: A dictionary with the following keys:
|
|
585
587
|
- `replies`: A list containing the generated ChatMessage responses.
|
|
586
588
|
|
|
@@ -594,8 +596,8 @@ class GoogleGenAIChatGenerator:
|
|
|
594
596
|
messages = _normalize_messages(messages)
|
|
595
597
|
# Merge generation_kwargs with instance defaults; other configs fall back to instance defaults
|
|
596
598
|
generation_kwargs = {**self._generation_kwargs, **(generation_kwargs or {})}
|
|
597
|
-
safety_settings = safety_settings
|
|
598
|
-
tools = tools
|
|
599
|
+
safety_settings = safety_settings if safety_settings is not None else self._safety_settings
|
|
600
|
+
tools = tools if tools is not None else self._tools
|
|
599
601
|
|
|
600
602
|
# Process thinking configuration and response format
|
|
601
603
|
generation_kwargs = _process_thinking_config(generation_kwargs)
|
|
@@ -459,7 +459,7 @@ class TestGoogleGenAIChatGeneratorRun:
|
|
|
459
459
|
assert results["replies"][0].tool_calls[0].tool_name == "weather"
|
|
460
460
|
|
|
461
461
|
def test_run_streaming_parallel_tool_calls_in_separate_chunks(self):
|
|
462
|
-
component = GoogleGenAIChatGenerator(model="gemini-3-flash
|
|
462
|
+
component = GoogleGenAIChatGenerator(model="gemini-3.8-flash")
|
|
463
463
|
component._client = MagicMock()
|
|
464
464
|
component._client.models.generate_content_stream = Mock(return_value=iter(_parallel_call_stream_chunks()))
|
|
465
465
|
|
|
@@ -505,6 +505,19 @@ class TestGoogleGenAIChatGeneratorRun:
|
|
|
505
505
|
config = call_kwargs.kwargs.get("config") or call_kwargs[1].get("config")
|
|
506
506
|
assert config.tools is not None
|
|
507
507
|
|
|
508
|
+
def test_run_with_empty_tools_override(self, mock_response, tools):
|
|
509
|
+
# an empty runtime list must disable the init tools for this call, not fall back to them;
|
|
510
|
+
# generation_kwargs keeps a config object in the request so its tools can be inspected
|
|
511
|
+
component = GoogleGenAIChatGenerator(tools=tools, generation_kwargs={"temperature": 0.5})
|
|
512
|
+
component._client = MagicMock()
|
|
513
|
+
component._client.models.generate_content = Mock(return_value=mock_response)
|
|
514
|
+
|
|
515
|
+
component.run([ChatMessage.from_user("Weather in Paris?")])
|
|
516
|
+
assert component._client.models.generate_content.call_args.kwargs["config"].tools is not None
|
|
517
|
+
|
|
518
|
+
component.run([ChatMessage.from_user("Weather in Paris?")], tools=[])
|
|
519
|
+
assert component._client.models.generate_content.call_args.kwargs["config"].tools is None
|
|
520
|
+
|
|
508
521
|
def test_run_with_safety_settings(self, mock_response):
|
|
509
522
|
safety = [{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}]
|
|
510
523
|
component = GoogleGenAIChatGenerator()
|
|
@@ -628,6 +641,45 @@ class TestGoogleGenAIChatGeneratorRun:
|
|
|
628
641
|
assert config.temperature == 0.9
|
|
629
642
|
assert config.max_output_tokens == 100
|
|
630
643
|
|
|
644
|
+
@pytest.mark.asyncio
|
|
645
|
+
async def test_run_async_with_empty_tools_override(self, mock_response, tools):
|
|
646
|
+
component = GoogleGenAIChatGenerator(tools=tools, generation_kwargs={"temperature": 0.5})
|
|
647
|
+
component._async_client = MagicMock()
|
|
648
|
+
component._async_client.models.generate_content = AsyncMock(return_value=mock_response)
|
|
649
|
+
|
|
650
|
+
await component.run_async([ChatMessage.from_user("Weather in Paris?")])
|
|
651
|
+
assert component._async_client.models.generate_content.call_args.kwargs["config"].tools is not None
|
|
652
|
+
|
|
653
|
+
await component.run_async([ChatMessage.from_user("Weather in Paris?")], tools=[])
|
|
654
|
+
assert component._async_client.models.generate_content.call_args.kwargs["config"].tools is None
|
|
655
|
+
|
|
656
|
+
def test_run_with_empty_safety_settings_override(self, mock_response):
|
|
657
|
+
# an empty runtime list must send no safety settings for this call, not fall back to the init ones;
|
|
658
|
+
# generation_kwargs keeps a config object in the request so its safety settings can be inspected
|
|
659
|
+
safety_settings = [{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_LOW_AND_ABOVE"}]
|
|
660
|
+
component = GoogleGenAIChatGenerator(safety_settings=safety_settings, generation_kwargs={"temperature": 0.5})
|
|
661
|
+
component._client = MagicMock()
|
|
662
|
+
component._client.models.generate_content = Mock(return_value=mock_response)
|
|
663
|
+
|
|
664
|
+
component.run([ChatMessage.from_user("Hello")])
|
|
665
|
+
assert component._client.models.generate_content.call_args.kwargs["config"].safety_settings is not None
|
|
666
|
+
|
|
667
|
+
component.run([ChatMessage.from_user("Hello")], safety_settings=[])
|
|
668
|
+
assert component._client.models.generate_content.call_args.kwargs["config"].safety_settings is None
|
|
669
|
+
|
|
670
|
+
@pytest.mark.asyncio
|
|
671
|
+
async def test_run_async_with_empty_safety_settings_override(self, mock_response):
|
|
672
|
+
safety_settings = [{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_LOW_AND_ABOVE"}]
|
|
673
|
+
component = GoogleGenAIChatGenerator(safety_settings=safety_settings, generation_kwargs={"temperature": 0.5})
|
|
674
|
+
component._async_client = MagicMock()
|
|
675
|
+
component._async_client.models.generate_content = AsyncMock(return_value=mock_response)
|
|
676
|
+
|
|
677
|
+
await component.run_async([ChatMessage.from_user("Hello")])
|
|
678
|
+
assert component._async_client.models.generate_content.call_args.kwargs["config"].safety_settings is not None
|
|
679
|
+
|
|
680
|
+
await component.run_async([ChatMessage.from_user("Hello")], safety_settings=[])
|
|
681
|
+
assert component._async_client.models.generate_content.call_args.kwargs["config"].safety_settings is None
|
|
682
|
+
|
|
631
683
|
@pytest.mark.asyncio
|
|
632
684
|
async def test_run_async_streaming(self, mock_streaming_chunk):
|
|
633
685
|
component = GoogleGenAIChatGenerator()
|
|
@@ -680,7 +732,7 @@ class TestGoogleGenAIChatGeneratorRun:
|
|
|
680
732
|
|
|
681
733
|
@pytest.mark.asyncio
|
|
682
734
|
async def test_run_async_streaming_parallel_tool_calls_in_separate_chunks(self):
|
|
683
|
-
component = GoogleGenAIChatGenerator(model="gemini-3-flash
|
|
735
|
+
component = GoogleGenAIChatGenerator(model="gemini-3.8-flash")
|
|
684
736
|
component._async_client = MagicMock()
|
|
685
737
|
|
|
686
738
|
async def mock_stream():
|
|
@@ -928,7 +980,7 @@ class TestGoogleGenAIChatGeneratorInference:
|
|
|
928
980
|
"What's the weather like in Paris and Berlin? Produce a separate tool call for each city."
|
|
929
981
|
)
|
|
930
982
|
]
|
|
931
|
-
component = GoogleGenAIChatGenerator(model="gemini-3-flash
|
|
983
|
+
component = GoogleGenAIChatGenerator(model="gemini-3.8-flash", tools=tools)
|
|
932
984
|
results = component.run(messages=initial_messages)
|
|
933
985
|
|
|
934
986
|
assert len(results["replies"]) == 1
|
|
@@ -972,9 +1024,7 @@ class TestGoogleGenAIChatGeneratorInference:
|
|
|
972
1024
|
"""
|
|
973
1025
|
# We use a model that supports the thinking feature
|
|
974
1026
|
chat_messages = [ChatMessage.from_user("Why is the sky blue? Explain in one sentence.")]
|
|
975
|
-
component = GoogleGenAIChatGenerator(
|
|
976
|
-
model="gemini-3-flash-preview", generation_kwargs={"thinking_level": "low"}
|
|
977
|
-
)
|
|
1027
|
+
component = GoogleGenAIChatGenerator(model="gemini-3.8-flash", generation_kwargs={"thinking_level": "medium"})
|
|
978
1028
|
results = component.run(chat_messages)
|
|
979
1029
|
|
|
980
1030
|
assert len(results["replies"]) == 1
|
|
@@ -999,7 +1049,7 @@ class TestGoogleGenAIChatGeneratorInference:
|
|
|
999
1049
|
"""
|
|
1000
1050
|
# Use a model that supports thinking with tools
|
|
1001
1051
|
component = GoogleGenAIChatGenerator(
|
|
1002
|
-
model="gemini-3-flash
|
|
1052
|
+
model="gemini-3.8-flash",
|
|
1003
1053
|
tools=tools,
|
|
1004
1054
|
generation_kwargs={"thinking_level": "low"}, # Dynamic allocation
|
|
1005
1055
|
)
|
|
@@ -1105,7 +1155,7 @@ class TestGoogleGenAIChatGeneratorInference:
|
|
|
1105
1155
|
)
|
|
1106
1156
|
|
|
1107
1157
|
agent = Agent(
|
|
1108
|
-
chat_generator=GoogleGenAIChatGenerator(model="gemini-3-flash
|
|
1158
|
+
chat_generator=GoogleGenAIChatGenerator(model="gemini-3.8-flash"),
|
|
1109
1159
|
system_prompt="You are an Agent that can retrieve and analyze images and documents.",
|
|
1110
1160
|
tools=[multimodal_retriever_tool],
|
|
1111
1161
|
)
|
|
@@ -1188,9 +1238,7 @@ class TestAsyncGoogleGenAIChatGeneratorInference:
|
|
|
1188
1238
|
Async integration test for the thinking feature.
|
|
1189
1239
|
"""
|
|
1190
1240
|
chat_messages = [ChatMessage.from_user("Why is the sky blue? Explain in one sentence.")]
|
|
1191
|
-
component = GoogleGenAIChatGenerator(
|
|
1192
|
-
model="gemini-3-flash-preview", generation_kwargs={"thinking_level": "low"}
|
|
1193
|
-
)
|
|
1241
|
+
component = GoogleGenAIChatGenerator(model="gemini-3.8-flash", generation_kwargs={"thinking_level": "medium"})
|
|
1194
1242
|
results = await component.run_async(chat_messages)
|
|
1195
1243
|
|
|
1196
1244
|
assert len(results["replies"]) == 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/examples/chatgenerator_example.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_chat_generator_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_files/sample_docx.docx
RENAMED
|
File without changes
|
{google_genai_haystack-7.2.1 → google_genai_haystack-7.2.2}/tests/test_files/sample_pdf_3.pdf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|