summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2024-09-29 22:41:27 +0200
committerGitHub <noreply@github.com>2024-09-29 22:41:27 +0200
commit0e32e274ad13f0daea9ce44f125215acf56b3bc1 (patch)
treed68bdf01f9783f0cedbfddf7144ac93b4b99c895 /g4f/Provider
parentMerge pull request #2246 from kqlio67/main (diff)
parentfeat(GeminiPro): add support for system prompt (diff)
downloadgpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.tar
gpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.tar.gz
gpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.tar.bz2
gpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.tar.lz
gpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.tar.xz
gpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.tar.zst
gpt4free-0e32e274ad13f0daea9ce44f125215acf56b3bc1.zip
Diffstat (limited to 'g4f/Provider')
-rw-r--r--g4f/Provider/GeminiPro.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/g4f/Provider/GeminiPro.py b/g4f/Provider/GeminiPro.py
index b225c26c..06bf69ee 100644
--- a/g4f/Provider/GeminiPro.py
+++ b/g4f/Provider/GeminiPro.py
@@ -54,6 +54,7 @@ class GeminiPro(AsyncGeneratorProvider, ProviderModelMixin):
"parts": [{"text": message["content"]}]
}
for message in messages
+ if message["role"] != "system"
]
if image is not None:
image = to_bytes(image)
@@ -73,6 +74,13 @@ class GeminiPro(AsyncGeneratorProvider, ProviderModelMixin):
"topK": kwargs.get("top_k"),
}
}
+ system_prompt = "\n".join(
+ message["content"]
+ for message in messages
+ if message["role"] == "system"
+ )
+ if system_prompt:
+ data["system_instruction"] = {"parts": {"text": system_prompt}}
async with session.post(url, params=params, json=data) as response:
if not response.ok:
data = await response.json()