From dbebd707ba881fa25ecdaaff08849fc4a5f197fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=A0=E7=9A=84=E5=A7=93=E5=90=8D?= <你的邮箱@example.com> Date: Fri, 16 Jan 2026 00:17:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(streamlit=5Fapp):=20=E4=BF=AE=E5=A4=8DDeepS?= =?UTF-8?q?eek=20API=E5=AF=86=E9=92=A5=E9=AA=8C=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加对默认API密钥值的检查,当密钥未配置或为默认值时显示警告并使用模拟响应 --- bigwork/src/streamlit_app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bigwork/src/streamlit_app.py b/bigwork/src/streamlit_app.py index c687020..4338fb3 100644 --- a/bigwork/src/streamlit_app.py +++ b/bigwork/src/streamlit_app.py @@ -897,13 +897,15 @@ def call_deepseek_api(prompt, max_tokens=1000, temperature=0.7): try: import os from dotenv import load_dotenv + # 重新加载环境变量,确保使用最新的API密钥 load_dotenv() url = "https://api.deepseek.com/v1/chat/completions" api_key = os.getenv("DEEPSEEK_API_KEY", "") # 使用环境变量 - if not api_key: - st.warning("DeepSeek API密钥未配置,使用模拟响应") + # 检查API密钥是否为空或默认值 + if not api_key or api_key == "your-key-here": + st.warning("DeepSeek API密钥未配置或无效,使用模拟响应") # 返回模拟响应 return """ # 个性化关怀方案