diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2024-09-29 22:41:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-29 22:41:27 +0200 |
commit | 0e32e274ad13f0daea9ce44f125215acf56b3bc1 (patch) | |
tree | d68bdf01f9783f0cedbfddf7144ac93b4b99c895 | |
parent | Merge pull request #2246 from kqlio67/main (diff) | |
parent | feat(GeminiPro): add support for system prompt (diff) | |
download | gpt4free-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 |
-rw-r--r-- | g4f/Provider/GeminiPro.py | 8 |
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() |