yym68686 commited on
Commit
3c06783
·
1 Parent(s): 766167a

gemini adds support for system prompts

Browse files
Files changed (1) hide show
  1. request.py +5 -0
request.py CHANGED
@@ -46,6 +46,7 @@ async def get_gemini_payload(request, engine, provider):
46
  url = url.format(model=model, stream=gemini_stream, api_key=provider['api'])
47
 
48
  messages = []
 
49
  for msg in request.messages:
50
  if msg.role == "assistant":
51
  msg.role = "model"
@@ -63,6 +64,8 @@ async def get_gemini_payload(request, engine, provider):
63
  content = [{"text": msg.content}]
64
  if msg.role != "system":
65
  messages.append({"role": msg.role, "parts": content})
 
 
66
 
67
 
68
  payload = {
@@ -86,6 +89,8 @@ async def get_gemini_payload(request, engine, provider):
86
  }
87
  ]
88
  }
 
 
89
 
90
  miss_fields = [
91
  'model',
 
46
  url = url.format(model=model, stream=gemini_stream, api_key=provider['api'])
47
 
48
  messages = []
49
+ systemInstruction = None
50
  for msg in request.messages:
51
  if msg.role == "assistant":
52
  msg.role = "model"
 
64
  content = [{"text": msg.content}]
65
  if msg.role != "system":
66
  messages.append({"role": msg.role, "parts": content})
67
+ if msg.role == "system":
68
+ systemInstruction = {"parts": content}
69
 
70
 
71
  payload = {
 
89
  }
90
  ]
91
  }
92
+ if systemInstruction:
93
+ payload["systemInstruction"] = systemInstruction
94
 
95
  miss_fields = [
96
  'model',