Skip to content

Commit

Permalink
Merge pull request #2219 from monosans/patch-01
Browse files Browse the repository at this point in the history
feat(GeminiPro): add support for system prompt
  • Loading branch information
xtekky authored Sep 29, 2024
2 parents 0deb0f6 + c2f7248 commit 0e32e27
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions g4f/Provider/GeminiPro.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async def create_async_generator(
"parts": [{"text": message["content"]}]
}
for message in messages
if message["role"] != "system"
]
if image is not None:
image = to_bytes(image)
Expand All @@ -73,6 +74,13 @@ async def create_async_generator(
"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()
Expand Down

0 comments on commit 0e32e27

Please sign in to comment.