From 50e90a6701df0b9ae4722e41885383608393e075 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Wed, 18 Dec 2024 17:33:55 +0100 Subject: [PATCH 1/2] make Vertex compatible with new ChatMessage --- .../components/generators/google_vertex/chat/gemini.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py b/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py index 2309ca718..b9a1678bf 100644 --- a/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py +++ b/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py @@ -280,11 +280,11 @@ def _get_response(self, response_body: GenerationResponse) -> List[ChatMessage]: # Remove content from metadata metadata.pop("content", None) if part._raw_part.text != "": - replies.append(ChatMessage.from_assistant(content=part._raw_part.text, meta=metadata)) + replies.append(ChatMessage.from_assistant(part._raw_part.text, meta=metadata)) elif part.function_call: metadata["function_call"] = part.function_call new_message = ChatMessage.from_assistant( - content=json.dumps(dict(part.function_call.args)), meta=metadata + json.dumps(dict(part.function_call.args)), meta=metadata ) new_message.name = part.function_call.name replies.append(new_message) From 535aab75111b16db17758f1a062e9d563bcc4152 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Wed, 18 Dec 2024 17:34:58 +0100 Subject: [PATCH 2/2] fmt --- .../components/generators/google_vertex/chat/gemini.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py b/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py index b9a1678bf..845e24f5f 100644 --- a/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py +++ b/integrations/google_vertex/src/haystack_integrations/components/generators/google_vertex/chat/gemini.py @@ -283,9 +283,7 @@ def _get_response(self, response_body: GenerationResponse) -> List[ChatMessage]: replies.append(ChatMessage.from_assistant(part._raw_part.text, meta=metadata)) elif part.function_call: metadata["function_call"] = part.function_call - new_message = ChatMessage.from_assistant( - json.dumps(dict(part.function_call.args)), meta=metadata - ) + new_message = ChatMessage.from_assistant(json.dumps(dict(part.function_call.args)), meta=metadata) new_message.name = part.function_call.name replies.append(new_message) return replies