From a741388447dfc6763d435639175e90cfb0b2b334 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 19 Jan 2025 22:21:50 +0000 Subject: [PATCH] fix: system message --- application/llm/google_ai.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/application/llm/google_ai.py b/application/llm/google_ai.py index e9188987c..9ebc0a5e3 100644 --- a/application/llm/google_ai.py +++ b/application/llm/google_ai.py @@ -71,6 +71,9 @@ def _raw_gen( if formatting == "openai": messages = self._clean_messages_google(messages) config = types.GenerateContentConfig() + if messages[0].role == "system": + config.system_instruction = messages[0].parts[0].text + messages = messages[1:] if tools: cleaned_tools = self._clean_tools_format(tools) @@ -101,6 +104,9 @@ def _raw_gen_stream( if formatting == "openai": cleaned_messages = self._clean_messages_google(messages) config = types.GenerateContentConfig() + if messages[0].role == "system": + config.system_instruction = messages[0].parts[0].text + messages = messages[1:] if tools: cleaned_tools = self._clean_tools_format(tools)