Skip to content

Commit

Permalink
Merge pull request #194 from rotemdan/use-native-system-message-for-g…
Browse files Browse the repository at this point in the history
…emini-1.5

Use native system instructions for Gemini 1.5 models
  • Loading branch information
justinh-rahb authored Aug 2, 2024
2 parents f920f7e + aabf46c commit caa5421
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions examples/pipelines/providers/google_manifold_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -127,11 +127,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),
Expand Down

0 comments on commit caa5421

Please sign in to comment.