v1.3.0: 舆情驱动自动化(定期扫新闻→重要度评分→邮件通知) + 系统设置区(邮件SMTP/大模型接口/监控参数可配, 含测试邮件/测试LLM/立即扫描/通知日志)
This commit is contained in:
+10
-7
@@ -23,18 +23,21 @@ _jobs_lock = threading.Lock()
|
||||
|
||||
# ------------------------------------------------------------------ LLM
|
||||
def llm_chat(messages, max_tokens=None, temperature=None, timeout=None):
|
||||
"""调用 DeepSeek(OpenAI 兼容)。返回最终 content(忽略推理过程)"""
|
||||
"""调用 DeepSeek(OpenAI 兼容)。返回最终 content(忽略推理过程)
|
||||
模型/Key/地址从设置区读取(settings 覆盖 config 默认)"""
|
||||
from settings import llm_config
|
||||
cfg = llm_config()
|
||||
resp = requests.post(
|
||||
f"{LLM_BASE_URL}/chat/completions",
|
||||
headers={"Authorization": f"Bearer {LLM_API_KEY}"},
|
||||
f"{cfg['base_url']}/chat/completions",
|
||||
headers={"Authorization": f"Bearer {cfg['api_key']}"},
|
||||
json={
|
||||
"model": LLM_MODEL,
|
||||
"model": cfg["model"],
|
||||
"messages": messages,
|
||||
"max_tokens": max_tokens or LLM_MAX_TOKENS,
|
||||
"temperature": LLM_TEMPERATURE if temperature is None else temperature,
|
||||
"max_tokens": max_tokens or cfg["max_tokens"],
|
||||
"temperature": cfg["temperature"] if temperature is None else temperature,
|
||||
"stream": False,
|
||||
},
|
||||
timeout=timeout or LLM_TIMEOUT,
|
||||
timeout=timeout or cfg["timeout"],
|
||||
)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
|
||||
Reference in New Issue
Block a user