diff --git a/dsLightRag/JiMeng/Kit/__pycache__/FenJingTouGenerator.cpython-310.pyc b/dsLightRag/JiMeng/Kit/__pycache__/FenJingTouGenerator.cpython-310.pyc new file mode 100644 index 00000000..83eb012c Binary files /dev/null and b/dsLightRag/JiMeng/Kit/__pycache__/FenJingTouGenerator.cpython-310.pyc differ diff --git a/dsLightRag/Routes/JiMengRoute.py b/dsLightRag/Routes/JiMengRoute.py index cad42929..839af5cb 100644 --- a/dsLightRag/Routes/JiMengRoute.py +++ b/dsLightRag/Routes/JiMengRoute.py @@ -7,6 +7,7 @@ from openai import AsyncOpenAI from Config import Config from JiMeng.Kit.JmTxt2ImgUtil import JmTxt2Img +from JiMeng.Kit.FenJingTouGenerator import FenJingTouGenerator # 导入分镜头生成器 # 创建路由路由器 router = APIRouter(prefix="/api/jimeng", tags=["即梦"]) @@ -48,3 +49,41 @@ async def prompt_input(request: fastapi.Request): logger.error(f"图片生成失败: {str(e)}") raise HTTPException(status_code=500, detail=f"图片生成失败: {str(e)}") + +@router.post("/generate_fenjingtou") +async def generate_fenjingtou(request: fastapi.Request): + try: + data = await request.json() + image_url = data.get("image_url") + prompt_text = data.get("prompt_text") + + if not image_url: + raise HTTPException(status_code=400, detail="缺少图片地址参数") + if not prompt_text: + raise HTTPException(status_code=400, detail="缺少提示词参数") + + logger.info(f"收到分镜头生成请求,图片地址: {image_url},提示词: {prompt_text}") + + # 创建分镜头生成器实例并调用方法 + generator = FenJingTouGenerator() + fenjingtou_content = generator.generate_fen_jing_tou(image_url, prompt_text) + + if not fenjingtou_content: + raise HTTPException(status_code=500, detail="分镜头脚本生成失败") + + logger.info(f"分镜头脚本生成成功") + + return { + "code": 200, + "message": "成功", + "data": { + "fenjingtou_content": fenjingtou_content + } + } + except HTTPException as e: + logger.error(f"请求参数错误: {str(e.detail)}") + raise e + except Exception as e: + logger.error(f"分镜头脚本生成失败: {str(e)}") + raise HTTPException(status_code=500, detail=f"分镜头脚本生成失败: {str(e)}") + diff --git a/dsLightRag/Routes/__pycache__/JiMengRoute.cpython-310.pyc b/dsLightRag/Routes/__pycache__/JiMengRoute.cpython-310.pyc index 6a16ad1f..7cc3e6c6 100644 Binary files a/dsLightRag/Routes/__pycache__/JiMengRoute.cpython-310.pyc and b/dsLightRag/Routes/__pycache__/JiMengRoute.cpython-310.pyc differ diff --git a/dsLightRag/static/JiMeng/image_preview.html b/dsLightRag/static/JiMeng/image_preview.html index cb452d8f..9c7f0352 100644 --- a/dsLightRag/static/JiMeng/image_preview.html +++ b/dsLightRag/static/JiMeng/image_preview.html @@ -128,19 +128,71 @@ flex-direction: column; align-items: center; } + /* 新增样式 */ + .section { + border-radius: 8px; + padding: 25px; + margin-bottom: 30px; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); + } + .image-section { + background-color: #f8f9fa; + } + .prompt-section { + background-color: #ffffff; + border: 1px solid #e9ecef; + } + .section-title { + font-size: 20px; + margin-bottom: 20px; + padding-bottom: 10px; + border-bottom: 1px solid #e9ecef; + color: #2c3e50; + } + .btn-group-image { + display: flex; + justify-content: center; + margin-top: 20px; + gap: 15px; + } + .btn-group-fen { + display: flex; + justify-content: flex-end; + margin-top: 15px; + }
请调整提示词,然后点击"生成分镜头"按钮:
+ +