mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-05-07 06:13:09 +08:00
feat: 添加对 image-generation 模型的支持
在 gemini_chat_service 和 openai_chat_service 中添加对 "-image-generation" 后缀模型的支持 确保 image-generation 模型与 image 模型有相同的处理逻辑
This commit is contained in:
@@ -71,7 +71,7 @@ def _build_payload(model: str, request: GeminiRequest) -> Dict[str, Any]:
|
||||
"systemInstruction": request_dict.get("systemInstruction", "")
|
||||
}
|
||||
|
||||
if model.endswith("-image"):
|
||||
if model.endswith("-image") or model.endswith("-image-generation"):
|
||||
payload.pop("systemInstruction")
|
||||
payload["generationConfig"]["responseModalities"] = ["Text","Image"]
|
||||
return payload
|
||||
|
||||
@@ -35,7 +35,7 @@ def _build_tools(
|
||||
|
||||
if (
|
||||
settings.TOOLS_CODE_EXECUTION_ENABLED
|
||||
and not (model.endswith("-search") or "-thinking" in model or model.endswith("-image"))
|
||||
and not (model.endswith("-search") or "-thinking" in model or model.endswith("-image") or model.endswith("-image-generation"))
|
||||
and not _has_image_parts(messages)
|
||||
):
|
||||
tools.append({"code_execution": {}})
|
||||
@@ -110,7 +110,7 @@ def _build_payload(
|
||||
"tools": _build_tools(request, messages),
|
||||
"safetySettings": _get_safety_settings(request.model),
|
||||
}
|
||||
if request.model.endswith("-image"):
|
||||
if request.model.endswith("-image") or request.model.endswith("-image-generation"):
|
||||
payload["generationConfig"]["responseModalities"] = ["Text","Image"]
|
||||
|
||||
if (
|
||||
@@ -119,6 +119,7 @@ def _build_payload(
|
||||
and instruction.get("role") == "system"
|
||||
and instruction.get("parts")
|
||||
and not request.model.endswith("-image")
|
||||
and not request.model.endswith("-image-generation")
|
||||
):
|
||||
payload["systemInstruction"] = instruction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user