Skip to content

Commit

Permalink
🐛 Bug: Fix the bug in the Gemini API where an empty message was not a…
Browse files Browse the repository at this point in the history
…utomatically added when no role message was passed in.
  • Loading branch information
yym68686 committed Dec 12, 2024
1 parent 608830f commit fbaa40f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ async def dispatch(self, request: Request, call_next):
if parsed_body:
try:
request_model = UnifiedRequest.model_validate(parsed_body).data
if is_debug:
logger.info("request_model: %s", json.dumps(request_model.model_dump(exclude_unset=True), indent=2, ensure_ascii=False))
model = request_model.model
current_info["model"] = model

Expand Down
2 changes: 1 addition & 1 deletion request.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def get_gemini_payload(request, engine, provider):


payload = {
"contents": messages,
"contents": messages or [{"role": "user", "parts": [{"text": "No messages"}]}],
"safetySettings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
Expand Down

0 comments on commit fbaa40f

Please sign in to comment.