mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-05-07 05:02:48 +08:00
Fix TTS payload - remove tools and safetySettings for TTS requests
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -258,4 +258,5 @@ $RECYCLE.BIN/
|
||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||
|
||||
tests/
|
||||
default_db
|
||||
default_db
|
||||
.augment-guidelines
|
||||
@@ -66,20 +66,21 @@ class TTSGeminiChatService(GeminiChatService):
|
||||
status_code = None
|
||||
|
||||
try:
|
||||
# 构建TTS专用的payload
|
||||
from app.service.chat.gemini_chat_service import _filter_empty_parts, _build_tools, _get_safety_settings
|
||||
# 构建TTS专用的payload - 不包含tools和safetySettings
|
||||
from app.service.chat.gemini_chat_service import _filter_empty_parts
|
||||
|
||||
request_dict = request.model_dump()
|
||||
|
||||
# 构建基础payload
|
||||
# 构建TTS专用的简化payload
|
||||
payload = {
|
||||
"contents": _filter_empty_parts(request_dict.get("contents", [])),
|
||||
"tools": _build_tools(model, request_dict),
|
||||
"safetySettings": _get_safety_settings(model),
|
||||
"generationConfig": request_dict.get("generationConfig", {}),
|
||||
"systemInstruction": request_dict.get("systemInstruction"),
|
||||
}
|
||||
|
||||
# 只在有systemInstruction时才添加
|
||||
if request_dict.get("systemInstruction"):
|
||||
payload["systemInstruction"] = request_dict.get("systemInstruction")
|
||||
|
||||
# 确保 generationConfig 不为 None
|
||||
if payload["generationConfig"] is None:
|
||||
payload["generationConfig"] = {}
|
||||
|
||||
Reference in New Issue
Block a user