fix(streamlit_app): 修复DeepSeek API密钥验证逻辑
增加对默认API密钥值的检查,当密钥未配置或为默认值时显示警告并使用模拟响应
This commit is contained in:
parent
52c426b241
commit
dbebd707ba
@ -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 """
|
||||
# 个性化关怀方案
|
||||
|
||||
Loading…
Reference in New Issue
Block a user