yym68686 commited on
Commit
5eb8cba
·
1 Parent(s): 061e8aa

🐛 Bug: Fix the bug where the lobechat gemini official API cannot use the tool. The reason is that lobechat automatically uses multiple consecutive underscores in the system prompt to name function names, which gemini does not support.

Browse files
Files changed (1) hide show
  1. request.py +2 -0
request.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import json
3
  from models import RequestModel
4
  from utils import c35s, c3s, c3o, c3h, gem, BaseAPI
@@ -150,6 +151,7 @@ async def get_gemini_payload(request, engine, provider):
150
  elif msg.role != "system":
151
  messages.append({"role": msg.role, "parts": content})
152
  elif msg.role == "system":
 
153
  systemInstruction = {"parts": content}
154
 
155
 
 
1
  import os
2
+ import re
3
  import json
4
  from models import RequestModel
5
  from utils import c35s, c3s, c3o, c3h, gem, BaseAPI
 
151
  elif msg.role != "system":
152
  messages.append({"role": msg.role, "parts": content})
153
  elif msg.role == "system":
154
+ content[0]["text"] = re.sub(r"_+", "_", content[0]["text"])
155
  systemInstruction = {"parts": content}
156
 
157