Moonfanz commited on
Commit
3a8851a
·
verified ·
1 Parent(s): c1df335

Upload 4 files

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. func.py +3 -3
app.py CHANGED
@@ -351,7 +351,7 @@ def chat_completions():
351
  'error': {
352
  'message': '你的输入被AI安全过滤器阻止',
353
  'type': 'prompt_blocked_error',
354
- 'details': str(e)
355
  }
356
  }), 400
357
  else:
 
351
  'error': {
352
  'message': '你的输入被AI安全过滤器阻止',
353
  'type': 'prompt_blocked_error',
354
+ 'details': str(e)
355
  }
356
  }), 400
357
  else:
func.py CHANGED
@@ -43,7 +43,7 @@ def process_messages_for_gemini(messages):
43
 
44
  if isinstance(content, str):
45
  if role == 'system':
46
- gemini_history.append({"role": "user", "parts": [content]})
47
  elif role == 'user':
48
  gemini_history.append({"role": "user", "parts": [content]})
49
  elif role == 'assistant':
@@ -89,9 +89,9 @@ def process_messages_for_gemini(messages):
89
  errors.append(f"Invalid file URL format for item: {item}")
90
 
91
  if parts:
92
- if role in ['user', 'system']:
93
  gemini_history.append({"role": "user", "parts": parts})
94
- elif role == 'assistant':
95
  gemini_history.append({"role": "model", "parts": parts})
96
  else:
97
  errors.append(f"Invalid role: {role}")
 
43
 
44
  if isinstance(content, str):
45
  if role == 'system':
46
+ gemini_history.append({"role": "model", "parts": [content]})
47
  elif role == 'user':
48
  gemini_history.append({"role": "user", "parts": [content]})
49
  elif role == 'assistant':
 
89
  errors.append(f"Invalid file URL format for item: {item}")
90
 
91
  if parts:
92
+ if role in ['user']:
93
  gemini_history.append({"role": "user", "parts": parts})
94
+ elif role in ['assistant', 'system']:
95
  gemini_history.append({"role": "model", "parts": parts})
96
  else:
97
  errors.append(f"Invalid role: {role}")