From afa29b93c656bd7514a6222fc5119445f22ed741 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Wed, 20 Aug 2025 10:35:52 +0800 Subject: [PATCH] 'commit' --- ...oubaoShiTu.py => T2_GenerateFenJingTou.py} | 12 +----- dsLightRag/JiMeng/T3_JmImg2Video.py | 42 +++---------------- 2 files changed, 8 insertions(+), 46 deletions(-) rename dsLightRag/JiMeng/{T2_DoubaoShiTu.py => T2_GenerateFenJingTou.py} (86%) diff --git a/dsLightRag/JiMeng/T2_DoubaoShiTu.py b/dsLightRag/JiMeng/T2_GenerateFenJingTou.py similarity index 86% rename from dsLightRag/JiMeng/T2_DoubaoShiTu.py rename to dsLightRag/JiMeng/T2_GenerateFenJingTou.py index 28b9a1c8..e5dafd16 100644 --- a/dsLightRag/JiMeng/T2_DoubaoShiTu.py +++ b/dsLightRag/JiMeng/T2_GenerateFenJingTou.py @@ -1,4 +1,3 @@ -import os import json import requests @@ -37,25 +36,18 @@ payload = { # 发送POST请求 try: - response = requests.post(url, headers=headers, data=json.dumps(payload), timeout=30) - + response = requests.post(url, headers=headers, data=json.dumps(payload), timeout=60) # 检查响应状态码 response.raise_for_status() - # 解析响应数据 result = response.json() - print('请求成功:') - + # 提取choices[0].message.content的内容 if 'choices' in result and len(result['choices']) > 0: choice = result['choices'][0] if 'message' in choice and 'content' in choice['message']: content = choice['message']['content'] - print('提取的内容:') print(content) - - # 这里可以添加对content的进一步处理逻辑 - # 例如保存到文件、解析表格内容等 else: print('响应中未找到message或content字段') else: diff --git a/dsLightRag/JiMeng/T3_JmImg2Video.py b/dsLightRag/JiMeng/T3_JmImg2Video.py index 56195373..09a5a7c0 100644 --- a/dsLightRag/JiMeng/T3_JmImg2Video.py +++ b/dsLightRag/JiMeng/T3_JmImg2Video.py @@ -40,7 +40,7 @@ class JmImg2Video(JmCommon): def main(): try: - # 玩法参考: https://www.volcengine.com/docs/85621/1544774 + # 参考: https://www.volcengine.com/docs/85621/1544774 image_urls = [ "https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/Backup/Text2Img.jpg" ] @@ -55,41 +55,11 @@ def main(): """ mp4_file_name = "image2video.mp4" - - # 添加重试逻辑,处理API并发限制错误 - submit_result = None - submit_retry_count = 0 - max_submit_retries = 1000 # 最大重试次数 - submit_retry_interval = 3000 # 重试间隔(毫秒) - - while submit_retry_count < max_submit_retries: - try: - submit_result = JmImg2Video.submit_image_to_video_task(image_urls, prompt) - logger.info(f"提交结果: {submit_result}") - - code = submit_result.get("code") - if code == JmErrorCode.API_CONCURRENT_LIMIT[0]: - logger.warning(f"API并发限制,等待{submit_retry_interval}毫秒后重试...") - time.sleep(submit_retry_interval / 1000) - submit_retry_count += 1 - continue - elif not JmErrorCode.is_success(code): - logger.error(f"提交任务失败: 错误码={code}, 错误信息={JmErrorCode.get_message_by_code(code)}") - return - - # 成功获取结果,跳出循环 - break - except Exception as e: - logger.error(f"提交任务异常: {str(e)}", exc_info=True) - submit_retry_count += 1 - if submit_retry_count < max_submit_retries: - logger.warning(f"等待{submit_retry_interval}毫秒后重试...") - time.sleep(submit_retry_interval / 1000) - else: - raise # 达到最大重试次数,抛出异常 - - if submit_retry_count >= max_submit_retries: - logger.error(f"提交任务失败,已达到最大重试次数: {max_submit_retries}") + submit_result = JmImg2Video.submit_image_to_video_task(image_urls, prompt) + logger.info(f"提交结果: {submit_result}") + code = submit_result.get("code") + if not JmErrorCode.is_success(code): + logger.error(f"提交任务失败: 错误码={code}, 错误信息={JmErrorCode.get_message_by_code(code)}") return # 获取任务ID