From a94512dad42716bf2f1c391fe930605302c173af Mon Sep 17 00:00:00 2001 From: Rotem Dan Date: Fri, 2 Aug 2024 16:45:46 +0300 Subject: [PATCH 1/2] Use native system instructions for Gemini 1.5 models --- .../pipelines/providers/google_manifold_pipeline.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/pipelines/providers/google_manifold_pipeline.py b/examples/pipelines/providers/google_manifold_pipeline.py index d320ea9b..7e90c7d2 100644 --- a/examples/pipelines/providers/google_manifold_pipeline.py +++ b/examples/pipelines/providers/google_manifold_pipeline.py @@ -125,11 +125,14 @@ def pipe( "role": "user" if message["role"] == "user" else "model", "parts": [{"text": message["content"]}] }) - - if system_message: - contents.insert(0, {"role": "user", "parts": [{"text": f"System: {system_message}"}]}) - - model = genai.GenerativeModel(model_name=model_id) + + if "gemini-1.5" in model_id: + model = genai.GenerativeModel(model_name=model_id, system_instruction=system_message) + else: + if system_message: + contents.insert(0, {"role": "user", "parts": [{"text": f"System: {system_message}"}]}) + + model = genai.GenerativeModel(model_name=model_id) generation_config = GenerationConfig( temperature=body.get("temperature", 0.7), From aabf46c8e9ca230b87681e53d122c25b4c41c94b Mon Sep 17 00:00:00 2001 From: Rotem Dan Date: Fri, 2 Aug 2024 18:48:02 +0300 Subject: [PATCH 2/2] Increment version to 1.3 --- examples/pipelines/providers/google_manifold_pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pipelines/providers/google_manifold_pipeline.py b/examples/pipelines/providers/google_manifold_pipeline.py index 7e90c7d2..fc4bc684 100644 --- a/examples/pipelines/providers/google_manifold_pipeline.py +++ b/examples/pipelines/providers/google_manifold_pipeline.py @@ -2,7 +2,7 @@ title: Google GenAI Manifold Pipeline author: Marc Lopez (refactor by justinh-rahb) date: 2024-06-06 -version: 1.2 +version: 1.3 license: MIT description: A pipeline for generating text using Google's GenAI models in Open-WebUI. requirements: google-generativeai