mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-08-14 10:04:25 +08:00
修复parts的错误
This commit is contained in:
2
.augment-guidelines
Normal file
2
.augment-guidelines
Normal file
@@ -0,0 +1,2 @@
|
||||
修改代码前记得调用AugmentContextEngine对项目上下文进行了解。
|
||||
需要在虚拟环境启动项目
|
||||
@@ -135,7 +135,7 @@ def _filter_empty_parts(contents: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
|
||||
def _build_payload(model: str, request: GeminiRequest) -> Dict[str, Any]:
|
||||
"""构建请求payload"""
|
||||
request_dict = request.model_dump()
|
||||
request_dict = request.model_dump(by_alias=True, exclude_none=False)
|
||||
if request.generationConfig:
|
||||
if request.generationConfig.maxOutputTokens is None:
|
||||
# 如果未指定最大输出长度,则不传递该字段,解决截断的问题
|
||||
|
||||
@@ -115,7 +115,7 @@ def _get_safety_settings(model: str) -> List[Dict[str, str]]:
|
||||
|
||||
def _build_payload(model: str, request: GeminiRequest) -> Dict[str, Any]:
|
||||
"""构建请求payload"""
|
||||
request_dict = request.model_dump()
|
||||
request_dict = request.model_dump(by_alias=True, exclude_none=False)
|
||||
if request.generationConfig:
|
||||
if request.generationConfig.maxOutputTokens is None:
|
||||
# 如果未指定最大输出长度,则不传递该字段,解决截断的问题
|
||||
|
||||
@@ -69,7 +69,7 @@ class TTSGeminiChatService(GeminiChatService):
|
||||
# 构建TTS专用的payload - 不包含tools和safetySettings
|
||||
from app.service.chat.gemini_chat_service import _filter_empty_parts
|
||||
|
||||
request_dict = request.model_dump()
|
||||
request_dict = request.model_dump(by_alias=True, exclude_none=False)
|
||||
|
||||
# 构建TTS专用的简化payload
|
||||
payload = {
|
||||
@@ -130,7 +130,7 @@ class TTSGeminiChatService(GeminiChatService):
|
||||
error_type="tts-api-error",
|
||||
error_log=error_msg,
|
||||
error_code=status_code,
|
||||
request_msg=request.model_dump()
|
||||
request_msg=request.model_dump(by_alias=True, exclude_none=False)
|
||||
)
|
||||
|
||||
logger.error(f"TTS API call failed: {error_msg}")
|
||||
|
||||
Reference in New Issue
Block a user