From 4bafd696a102c6c85e4d65114ec85f6c03481037 Mon Sep 17 00:00:00 2001 From: linyqh Date: Sun, 10 Nov 2024 14:26:06 +0800 Subject: [PATCH] =?UTF-8?q?0.3.3=20=E8=A7=A3=E5=86=B3=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webui/components/script_settings.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/webui/components/script_settings.py b/webui/components/script_settings.py index fcc1913..ff8cb1a 100644 --- a/webui/components/script_settings.py +++ b/webui/components/script_settings.py @@ -1,10 +1,12 @@ import os +import ssl import glob import json import time import asyncio import traceback - +from requests.adapters import HTTPAdapter +from urllib3.util.retry import Retry import requests import streamlit as st from loguru import logger @@ -432,12 +434,22 @@ def generate_script(tr, params): 'llm_api_key': text_api_key, 'custom_prompt': st.session_state.get('custom_prompt', '') } - response = requests.post( + session = requests.Session() + retry_strategy = Retry( + total=3, + backoff_factor=1, + status_forcelist=[500, 502, 503, 504] + ) + adapter = HTTPAdapter(max_retries=retry_strategy) + session.mount("https://", adapter) + + response = session.post( f"{config.app.get('narrato_api_url')}/video/config", params=api_params, timeout=30, - verify=False + verify=True # 启用证书验证 ) + custom_prompt = st.session_state.get('custom_prompt', '') processor = ScriptProcessor( model_name=text_model,