google-genai-haystack 7.2.0__tar.gz → 7.2.1__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 (39) hide show
  1. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/CHANGELOG.md +7 -0
  2. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/PKG-INFO +1 -1
  3. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/generators/google_genai/chat/utils.py +22 -4
  4. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_chat_generator_utils.py +74 -0
  5. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/.gitignore +0 -0
  6. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/LICENSE.txt +0 -0
  7. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/README.md +0 -0
  8. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/examples/chatgenerator_example.py +0 -0
  9. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/pydoc/config_docusaurus.yml +0 -0
  10. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/pyproject.toml +0 -0
  11. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/common/google_genai/__init__.py +0 -0
  12. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/common/google_genai/utils.py +0 -0
  13. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/common/py.typed +0 -0
  14. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/embedders/google_genai/__init__.py +0 -0
  15. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/embedders/google_genai/document_embedder.py +0 -0
  16. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/embedders/google_genai/multimodal_document_embedder.py +0 -0
  17. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/embedders/google_genai/text_embedder.py +0 -0
  18. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/embedders/py.typed +0 -0
  19. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/generators/google_genai/__init__.py +0 -0
  20. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/generators/google_genai/chat/chat_generator.py +0 -0
  21. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/generators/google_genai/chat/interactions_chat_generator.py +0 -0
  22. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/generators/google_genai/chat/interactions_utils.py +0 -0
  23. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/components/generators/py.typed +0 -0
  24. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/token_counters/google_genai/__init__.py +0 -0
  25. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/token_counters/google_genai/token_counter.py +0 -0
  26. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/src/haystack_integrations/token_counters/py.typed +0 -0
  27. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/conftest.py +0 -0
  28. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_chat_generator.py +0 -0
  29. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_document_embedder.py +0 -0
  30. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_files/apple.jpg +0 -0
  31. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_files/banana.png +0 -0
  32. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_files/sample_docx.docx +0 -0
  33. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_files/sample_pdf_3.pdf +0 -0
  34. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_interactions_chat_generator.py +0 -0
  35. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_interactions_chat_generator_utils.py +0 -0
  36. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_multimodal_document_embedder.py +0 -0
  37. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_text_embedder.py +0 -0
  38. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_token_counter.py +0 -0
  39. {google_genai_haystack-7.2.0 → google_genai_haystack-7.2.1}/tests/test_utils.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/google_genai-v7.2.0] - 2026-11-06
4
+
5
+ ### 🚀 Features
6
+
7
+ - *(google_genai)* Add `GoogleGenAIInteractionsChatGenerator` for the Gemini Interactions API (#4199)
8
+
9
+
3
10
  ## [integrations/google_genai-v7.1.0] - 2026-11-02
4
11
 
5
12
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: google-genai-haystack
3
- Version: 7.2.0
3
+ Version: 7.2.1
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
@@ -259,10 +259,13 @@ def _convert_message_to_google_genai_format(message: ChatMessage) -> types.Conte
259
259
  thought_signatures = message.meta.get("thought_signatures", []) if message.meta else []
260
260
 
261
261
  # If we have thought signatures, we need to reconstruct the exact part structure
262
- # from the previous assistant response to maintain multi-turn thinking context
262
+ # from the previous assistant response to maintain multi-turn thinking context.
263
+ # Gemini attaches a thought signature to the *first* function call of a parallel
264
+ # batch only, so unsigned tool calls / text must still be appended afterward.
263
265
  if thought_signatures and message.is_from(ChatRole.ASSISTANT):
264
266
  # Track which tool calls we've used (to handle multiple tool calls)
265
267
  tool_call_index = 0
268
+ included_non_thought_text = False
266
269
 
267
270
  # Reconstruct parts with their original thought signatures
268
271
  for sig_info in thought_signatures:
@@ -279,6 +282,7 @@ def _convert_message_to_google_genai_format(message: ChatMessage) -> types.Conte
279
282
  else:
280
283
  # Regular text part
281
284
  part_dict["text"] = message.text or ""
285
+ included_non_thought_text = True
282
286
 
283
287
  if sig_info.get("has_function_call"):
284
288
  # Find the corresponding tool call by index
@@ -295,6 +299,20 @@ def _convert_message_to_google_genai_format(message: ChatMessage) -> types.Conte
295
299
 
296
300
  parts.append(types.Part(**part_dict))
297
301
 
302
+ # Append parallel tool calls that had no thought signature of their own.
303
+ for tool_call in message.tool_calls[tool_call_index:]:
304
+ parts.append(
305
+ types.Part(
306
+ function_call=types.FunctionCall(
307
+ id=tool_call.id, name=tool_call.tool_name, args=tool_call.arguments
308
+ )
309
+ )
310
+ )
311
+
312
+ # Append unsigned text that was not covered by a signed text part.
313
+ if message.text and message.text.strip() and not included_non_thought_text:
314
+ parts.append(types.Part(text=message.text))
315
+
298
316
  # If we reconstructed from signatures, we're done
299
317
  if parts:
300
318
  role = "model" # Assistant messages with signatures are always from the model
@@ -763,9 +781,9 @@ def _aggregate_streaming_chunks_with_reasoning(chunks: list[StreamingChunk]) ->
763
781
  if chunk.meta and "thought_signature_deltas" in chunk.meta:
764
782
  signature_deltas = chunk.meta["thought_signature_deltas"]
765
783
  if isinstance(signature_deltas, list):
766
- # Aggregate thought signatures - they should come from the final chunks
767
- # We'll keep the last set of signatures as they represent the complete state
768
- thought_signatures = signature_deltas
784
+ # Accumulate across chunks: parallel tool-call signatures can arrive
785
+ # in earlier chunks, and replacing would drop them.
786
+ thought_signatures.extend(signature_deltas)
769
787
 
770
788
  # Extract token usage metadata (from the last chunk that has it)
771
789
  if chunk.meta and "usage" in chunk.meta:
@@ -705,6 +705,44 @@ class TestStreamingChunkConversion:
705
705
  assert "thought_signatures" in result.meta
706
706
  assert result.meta["thought_signatures"][0]["signature"] == "sig_xyz"
707
707
 
708
+ def test_aggregate_streaming_chunks_accumulates_thought_signatures_across_chunks(self):
709
+ """Signature deltas from earlier chunks must not be overwritten by later ones."""
710
+ model = "gemini-2.5-flash"
711
+ component_info = ComponentInfo.from_component(GoogleGenAIChatGenerator(model=model))
712
+ parts = [
713
+ types.Part(
714
+ text="Checking the weather.",
715
+ thought=True,
716
+ thought_signature=b"reasoning_signature",
717
+ ),
718
+ types.Part(
719
+ function_call=types.FunctionCall(name="get_weather", args={"city": "Paris"}),
720
+ thought_signature=b"tool_signature",
721
+ ),
722
+ ]
723
+ chunks = [
724
+ _convert_google_chunk_to_streaming_chunk(
725
+ chunk=types.GenerateContentResponse(
726
+ candidates=[types.Candidate(content=types.Content(role="model", parts=[part]))]
727
+ ),
728
+ index=index,
729
+ component_info=component_info,
730
+ model=model,
731
+ )
732
+ for index, part in enumerate(parts)
733
+ ]
734
+
735
+ result = _aggregate_streaming_chunks_with_reasoning(chunks)
736
+
737
+ assert result.reasoning.reasoning_text == "Checking the weather."
738
+ assert len(result.tool_calls) == 1
739
+ assert result.tool_calls[0].tool_name == "get_weather"
740
+ assert result.tool_calls[0].arguments == {"city": "Paris"}
741
+ assert [base64.b64decode(signature["signature"]) for signature in result.meta["thought_signatures"]] == [
742
+ b"reasoning_signature",
743
+ b"tool_signature",
744
+ ]
745
+
708
746
  def test_convert_google_chunk_to_streaming_chunk_with_cached_tokens(self, monkeypatch):
709
747
  """cached_content_token_count from usage_metadata is included in the streaming chunk's usage."""
710
748
  monkeypatch.setenv("GOOGLE_API_KEY", "test-api-key")
@@ -978,6 +1016,42 @@ class TestConvertMessageToGoogleGenAI:
978
1016
  assert google_content.parts[1].function_call.args == {"city": "Paris"}
979
1017
  assert google_content.parts[1].thought_signature == b"encrypted_mock_thought_signature_2"
980
1018
 
1019
+ def test_convert_message_keeps_parallel_tool_calls_without_thought_signatures(self):
1020
+ """Gemini signs only the first parallel function call; unsigned siblings must still be replayed."""
1021
+ paris = ToolCall(id="call_paris", tool_name="get_weather", arguments={"city": "Paris"})
1022
+ london = ToolCall(id="call_london", tool_name="get_weather", arguments={"city": "London"})
1023
+ thought_signatures = [
1024
+ {
1025
+ "part_index": 0,
1026
+ "signature": base64.b64encode(b"sig_on_first_only").decode("utf-8"),
1027
+ "has_text": False,
1028
+ "has_function_call": True,
1029
+ "is_thought": False,
1030
+ },
1031
+ ]
1032
+
1033
+ message = ChatMessage.from_assistant(
1034
+ text="Checking both cities",
1035
+ tool_calls=[paris, london],
1036
+ meta={"thought_signatures": thought_signatures},
1037
+ )
1038
+
1039
+ google_content = _convert_message_to_google_genai_format(message)
1040
+
1041
+ assert google_content.role == "model"
1042
+ assert len(google_content.parts) == 3
1043
+
1044
+ assert google_content.parts[0].function_call.name == "get_weather"
1045
+ assert google_content.parts[0].function_call.args == {"city": "Paris"}
1046
+ assert google_content.parts[0].thought_signature == b"sig_on_first_only"
1047
+
1048
+ assert google_content.parts[1].function_call.name == "get_weather"
1049
+ assert google_content.parts[1].function_call.args == {"city": "London"}
1050
+ assert not google_content.parts[1].thought_signature
1051
+
1052
+ assert google_content.parts[2].text == "Checking both cities"
1053
+ assert not google_content.parts[2].thought_signature
1054
+
981
1055
  def test_thought_signature_bytes_round_trip(self, monkeypatch):
982
1056
  """Raw (non UTF-8) thought signature bytes are stored as base64 strings and restored as bytes."""
983
1057
  monkeypatch.setenv("GOOGLE_API_KEY", "test-api-key")