mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
refactor: 移除 Python 后端源码,全面迁移至 Rust gateway 架构
- 删除全部 Python 源码 (src/) 及 Alembic 迁移脚本,归档至 _deprecated_py_src/ - 重构 Rust gateway ai_pipeline: 拆分 planner/finalize 模块,新增 contracts/adaptation 层 - 重组 handlers 模块为 admin/public/proxy/internal/shared 子模块结构 - 新增 executor 模块,引入 Rust 原生数据库迁移 (aether-data/migrations) - 简化 CI/Docker 构建流程,移除 base image 二级构建,统一为单一 app image - 移除 Python 相关基础设施文件 (entrypoint.sh, gunicorn_conf.py, Dockerfile.base)
This commit is contained in:
41
_deprecated_py_src/api/handlers/gemini/image_gen.py
Normal file
41
_deprecated_py_src/api/handlers/gemini/image_gen.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
Gemini 图像生成模型请求适配
|
||||
|
||||
- 图像生成模型不支持 tools / system_instruction,需要移除
|
||||
- responseModalities / responseMimeType 与 imageConfig 冲突,需要移除
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from src.core.video_utils import is_image_gen_model
|
||||
|
||||
__all__ = ["is_image_gen_model", "adapt_request_for_image_gen"]
|
||||
|
||||
|
||||
def adapt_request_for_image_gen(body: dict[str, Any]) -> dict[str, Any]:
|
||||
"""为图像生成模型清理不兼容字段"""
|
||||
# 移除图像生成不支持的顶层字段
|
||||
for key in ("tools", "tool_config", "toolConfig", "system_instruction", "systemInstruction"):
|
||||
if key in body:
|
||||
body.pop(key)
|
||||
|
||||
# 处理 generationConfig
|
||||
gc_key = "generationConfig" if "generationConfig" in body else "generation_config"
|
||||
gc = body.get(gc_key)
|
||||
if not isinstance(gc, dict):
|
||||
gc = {}
|
||||
body[gc_key] = gc
|
||||
|
||||
# 移除与图像生成冲突的字段
|
||||
for key in (
|
||||
"responseMimeType",
|
||||
"response_mime_type",
|
||||
"responseModalities",
|
||||
"response_modalities",
|
||||
):
|
||||
gc.pop(key, None)
|
||||
|
||||
# 设置输出模态
|
||||
gc["responseModalities"] = ["TEXT", "IMAGE"]
|
||||
|
||||
return body
|
||||
Reference in New Issue
Block a user