Skip to content

Commit 8779a5f

Browse files
committed
feat: 添加对 image-generation 模型的支持
在 gemini_chat_service 和 openai_chat_service 中添加对 "-image-generation" 后缀模型的支持 确保 image-generation 模型与 image 模型有相同的处理逻辑
1 parent 89f2825 commit 8779a5f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/services/gemini_chat_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _build_payload(model: str, request: GeminiRequest) -> Dict[str, Any]:
7171
"systemInstruction": request_dict.get("systemInstruction", "")
7272
}
7373

74-
if model.endswith("-image"):
74+
if model.endswith("-image") or model.endswith("-image-generation"):
7575
payload.pop("systemInstruction")
7676
payload["generationConfig"]["responseModalities"] = ["Text","Image"]
7777
return payload

app/services/openai_chat_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _build_tools(
3535

3636
if (
3737
settings.TOOLS_CODE_EXECUTION_ENABLED
38-
and not (model.endswith("-search") or "-thinking" in model or model.endswith("-image"))
38+
and not (model.endswith("-search") or "-thinking" in model or model.endswith("-image") or model.endswith("-image-generation"))
3939
and not _has_image_parts(messages)
4040
):
4141
tools.append({"code_execution": {}})
@@ -110,7 +110,7 @@ def _build_payload(
110110
"tools": _build_tools(request, messages),
111111
"safetySettings": _get_safety_settings(request.model),
112112
}
113-
if request.model.endswith("-image"):
113+
if request.model.endswith("-image") or request.model.endswith("-image-generation"):
114114
payload["generationConfig"]["responseModalities"] = ["Text","Image"]
115115

116116
if (
@@ -119,6 +119,7 @@ def _build_payload(
119119
and instruction.get("role") == "system"
120120
and instruction.get("parts")
121121
and not request.model.endswith("-image")
122+
and not request.model.endswith("-image-generation")
122123
):
123124
payload["systemInstruction"] = instruction
124125

0 commit comments

Comments
 (0)