From 1a144054e6f422ec200cee81045eba4890e0db41 Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Mon, 29 Apr 2024 21:35:30 +0200 Subject: [PATCH] fixed system instruction --- libs/genai/langchain_google_genai/chat_models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/genai/langchain_google_genai/chat_models.py b/libs/genai/langchain_google_genai/chat_models.py index 4acbff0a..bb4f2049 100644 --- a/libs/genai/langchain_google_genai/chat_models.py +++ b/libs/genai/langchain_google_genai/chat_models.py @@ -772,10 +772,14 @@ def _prepare_chat( convert_system_message_to_human=self.convert_system_message_to_human, ) message = history.pop() - if self.client._system_instruction != system_instruction: + if ( + self.client._system_instruction != system_instruction + and not self.convert_system_message_to_human + ): self.client = genai.GenerativeModel( model_name=self.model, system_instruction=system_instruction ) + client = self.client chat = client.start_chat(history=history) return params, chat, message