auto-sync: 2026-05-21 00:19:19
This commit is contained in:
@@ -117,13 +117,27 @@ async def _generate_title(description: str) -> str | None:
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
# 用智谱 Flash(快速廉价)
|
import yaml
|
||||||
client = OpenAI(
|
# 从 moziplus 配置读 LLM 凭据
|
||||||
base_url="https://open.bigmodel.cn/api/paas/v4",
|
cfg_path = Path(__file__).parent.parent.parent / "config" / "default.yaml"
|
||||||
api_key="97552d53aea7486aa0e5140ec0295fe7.DPpgbVoQWZiNrJ1p",
|
base_url = "https://open.bigmodel.cn/api/paas/v4"
|
||||||
)
|
api_key = ""
|
||||||
|
model = "glm-4-flash"
|
||||||
|
if cfg_path.exists():
|
||||||
|
with open(cfg_path) as f:
|
||||||
|
cfg = yaml.safe_load(f)
|
||||||
|
routing = cfg.get("daemon", {}).get("routing", {})
|
||||||
|
if routing.get("api_base"):
|
||||||
|
base_url = routing["api_base"]
|
||||||
|
if routing.get("api_key"):
|
||||||
|
api_key = routing["api_key"]
|
||||||
|
if routing.get("model"):
|
||||||
|
model = routing["model"]
|
||||||
|
if not api_key:
|
||||||
|
return None # 没配 API key 就跳过
|
||||||
|
client = OpenAI(base_url=base_url, api_key=api_key)
|
||||||
resp = client.chat.completions.create(
|
resp = client.chat.completions.create(
|
||||||
model="glm-4-flash",
|
model=model,
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": "你是一个任务标题生成器。根据用户的需求描述,生成一个简洁的中文标题(5-15字),只输出标题,不要任何其他内容。"},
|
{"role": "system", "content": "你是一个任务标题生成器。根据用户的需求描述,生成一个简洁的中文标题(5-15字),只输出标题,不要任何其他内容。"},
|
||||||
{"role": "user", "content": description[:500]},
|
{"role": "user", "content": description[:500]},
|
||||||
|
|||||||
Reference in New Issue
Block a user