Skip to content

Commit

Permalink
Support for system instructions, refs #6
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 10, 2024
1 parent 46c1f72 commit f39156f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions llm_gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ def execute(self, prompt, stream, response, conversation):
{"key": key}
)
gathered = []
body = {
"contents": self.build_messages(prompt, conversation),
"safetySettings": SAFETY_SETTINGS,
}
if prompt.system:
body["systemInstruction"] = {"parts": [{"text": prompt.system}]}
with httpx.stream(
"POST",
url,
timeout=None,
json={
"contents": self.build_messages(prompt, conversation),
"safetySettings": SAFETY_SETTINGS,
},
json=body,
) as http_response:
events = ijson.sendable_list()
coro = ijson.items_coro(events, "item")
Expand Down

0 comments on commit f39156f

Please sign in to comment.