Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Migrate from Preview to Stable Package for Vertex AI Integration #1038

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from haystack.dataclasses.chat_message import ChatMessage, ChatRole
from haystack.utils import deserialize_callable, serialize_callable
from vertexai import init as vertexai_init
from vertexai.preview.generative_models import (
from vertexai.generative_models import (
Content,
GenerationConfig,
GenerationResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def to_dict(self) -> Dict[str, Any]:
tools=self._tools,
streaming_callback=callback_name,
)

if (tools := data["init_parameters"].get("tools")) is not None:
data["init_parameters"]["tools"] = [Tool.to_dict(t) for t in tools]
if (generation_config := data["init_parameters"].get("generation_config")) is not None:
Expand Down
3 changes: 2 additions & 1 deletion integrations/google_vertex/tests/test_gemini.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest.mock import MagicMock, Mock, patch

from haystack.dataclasses import StreamingChunk
from vertexai.preview.generative_models import (
from vertexai.generative_models import (
FunctionDeclaration,
GenerationConfig,
HarmBlockThreshold,
Expand Down Expand Up @@ -103,6 +103,7 @@ def test_to_dict_with_params(_mock_vertexai_init, _mock_generative_model):
safety_settings=safety_settings,
tools=[tool],
)

assert gemini.to_dict() == {
"type": "haystack_integrations.components.generators.google_vertex.gemini.VertexAIGeminiGenerator",
"init_parameters": {
Expand Down
Loading