Add Cloud Tour Libo knowledge graph platform

This commit is contained in:
2026-07-30 10:08:04 +08:00
parent 9e05b09a38
commit bae5197d62
103 changed files with 14036 additions and 160 deletions

View File

@@ -1573,7 +1573,7 @@ async def get_user_auth(username: str) -> dict | None:
FROM {s}.users u
LEFT JOIN {s}.user_roles ur ON ur.user_id = u.id
WHERE u.username=%s
GROUP BY u.id""",
GROUP BY u.id, u.username, u.full_name, u.hashed_password, u.status""",
(username,),
)
return await cur.fetchone()
@@ -1627,7 +1627,7 @@ async def update_user(user_id: int, data: dict, role_keys: list[str] | None) ->
COALESCE(array_agg(ur.role_key)
FILTER (WHERE ur.role_key IS NOT NULL), '{{}}') AS roles
FROM {s}.users u LEFT JOIN {s}.user_roles ur ON ur.user_id=u.id
WHERE u.id=%s GROUP BY u.id""",
WHERE u.id=%s GROUP BY u.id, u.username, u.full_name, u.phone, u.status""",
(user_id,),
)
row = await cur.fetchone()
@@ -1896,6 +1896,19 @@ def _default_agent(label: str, enabled: bool = True) -> dict:
DEFAULT_AGENT_CONFIG: dict = {
"global": {"base_url": "", "model": "deepseek-chat", "api_key": "", "timeout": 30},
"api_access": {
"api_keys": settings.ingest_api_keys,
"default_graph": "baixinghui_travel_agency",
"default_use_llm": True,
"default_llm_fusion": True,
"qa_llm": {
"base_url": "",
"model": "deepseek-chat",
"api_key": "",
"timeout": 30,
"max_tokens": 1600,
},
},
"thresholds": {
"audit_hit": 0.7,
"audit_gap": 0.4,
@@ -1986,6 +1999,13 @@ async def get_agent_settings() -> dict:
cfg = row["config"]
merged = {**DEFAULT_AGENT_CONFIG, **cfg}
merged["global"] = {**DEFAULT_AGENT_CONFIG["global"], **cfg.get("global", {})}
saved_api_access = cfg.get("api_access", {}) or {}
api_access = {**DEFAULT_AGENT_CONFIG["api_access"], **saved_api_access}
api_access["qa_llm"] = {
**DEFAULT_AGENT_CONFIG["api_access"]["qa_llm"],
**(saved_api_access.get("qa_llm") or {}),
}
merged["api_access"] = api_access
merged["thresholds"] = {**DEFAULT_AGENT_CONFIG["thresholds"], **cfg.get("thresholds", {})}
# deep-merge each agent so newly added per-agent fields always appear
saved_agents = cfg.get("agents", {})
@@ -2033,12 +2053,17 @@ async def save_agent_settings(config: dict) -> dict:
async with get_conn() as conn:
async with conn.cursor() as cur:
await cur.execute(
f"""INSERT INTO {s}.agent_settings (settings_key, config, updated_at)
VALUES ('agent', %s, now())
ON CONFLICT (settings_key)
DO UPDATE SET config=EXCLUDED.config, updated_at=now()""",
f"""UPDATE {s}.agent_settings
SET config=%s, updated_at=now()
WHERE settings_key='agent'""",
(json.dumps(config),),
)
if cur.rowcount == 0:
await cur.execute(
f"""INSERT INTO {s}.agent_settings (settings_key, config, updated_at)
VALUES ('agent', %s, now())""",
(json.dumps(config),),
)
await conn.commit()
return config