llmage/wwwroot/check_pricing_data.dspy

43 lines
1.6 KiB
Plaintext

llmid = params_kw.get('llmid', '')
if not llmid:
return json.dumps({
"widgettype": "Text",
"options": {"text": "❌ 定价数据: 缺少llmid参数", "i18n": False}
}, ensure_ascii=False)
async with get_sor_context(request._run_ns, 'llmage') as sor:
maps = await sor.sqlExe(
"select * from llm_api_map where llmid=${llmid}$", {'llmid': llmid})
ppids = [m.ppid for m in maps if m.ppid] if maps else []
if not ppids:
text = "❌ 定价数据: 无定价项目"
else:
ppid = ppids[0]
try:
async with get_sor_context(request._run_ns, 'pricing') as psor:
pregs = await psor.sqlExe(
"select * from pricing_program where id=${ppid}$", {'ppid': ppid})
if not pregs:
text = "❌ 定价数据: 依赖定价项目未通过"
else:
# 检查 pricing_program_timing 表
try:
timings = await psor.sqlExe(
"select count(*) as cnt from pricing_program_timing where ppid=${ppid}$", {'ppid': ppid})
cnt = timings[0].cnt if timings else 0
if cnt > 0:
text = f"✅ 定价数据(pricing_program_timing): {cnt}条记录"
else:
text = "❌ 定价数据: pricing_program_timing 无记录"
except Exception as e:
text = f"❌ 定价数据: {e}"
except Exception as e:
text = f"❌ 定价数据: {e}"
return json.dumps({
"widgettype": "Text",
"options": {"text": text, "i18n": False}
}, ensure_ascii=False)