@hupan56/wlkj 3.1.10 → 3.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -198,7 +198,7 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
198
198
|
}, "required": ["module"]})
|
|
199
199
|
def _t_get_workflow(self, args):
|
|
200
200
|
from domain.kg.kg_capabilities import workflow_query
|
|
201
|
-
from domain.kg.storage.kg_duckdb import
|
|
201
|
+
from domain.kg.storage.kg_duckdb import get_db_readonly
|
|
202
202
|
q = (args.get("module") or '').strip()
|
|
203
203
|
if not q:
|
|
204
204
|
return "请提供模块名。可选: assets/cost/hr/maintenance/operation/qualityAndSafety/veh/settings/dashboard/flow/systems/monitor/quasafe"
|
|
@@ -207,7 +207,9 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
207
207
|
_hint = _require_kgdb()
|
|
208
208
|
if _hint:
|
|
209
209
|
return _hint
|
|
210
|
-
con =
|
|
210
|
+
con = get_db_readonly()
|
|
211
|
+
if con is None:
|
|
212
|
+
return "知识图谱暂不可用 (kg.duckdb 连接失败), 稍后重试或联系管理员。"
|
|
211
213
|
try:
|
|
212
214
|
return workflow_query(con, q)
|
|
213
215
|
finally:
|
|
@@ -222,7 +224,7 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
222
224
|
}, "required": ["symbol"]})
|
|
223
225
|
def _t_multi_hop(self, args):
|
|
224
226
|
from domain.kg.kg_capabilities import hop_query
|
|
225
|
-
from domain.kg.storage.kg_duckdb import
|
|
227
|
+
from domain.kg.storage.kg_duckdb import get_db_readonly, multi_hop
|
|
226
228
|
sym = (args.get("symbol") or '').strip()
|
|
227
229
|
if not sym:
|
|
228
230
|
return "请提供起点符号 (entity_id / 端点 / 函数名 / 中文别名)"
|
|
@@ -234,7 +236,9 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
234
236
|
_hint = _require_kgdb()
|
|
235
237
|
if _hint:
|
|
236
238
|
return _hint
|
|
237
|
-
con =
|
|
239
|
+
con = get_db_readonly()
|
|
240
|
+
if con is None:
|
|
241
|
+
return "知识图谱暂不可用 (kg.duckdb 连接失败), 稍后重试或联系管理员。"
|
|
238
242
|
try:
|
|
239
243
|
return hop_query(con, sym, depth, multi_hop_fn=multi_hop)
|
|
240
244
|
finally:
|
|
@@ -259,12 +263,14 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
259
263
|
"field": {"type": "string", "description": "字段名(英文field或中文标题)"},
|
|
260
264
|
}, "required": ["field"]})
|
|
261
265
|
def _t_search_field(self, args):
|
|
262
|
-
from domain.kg.storage.kg_duckdb import
|
|
266
|
+
from domain.kg.storage.kg_duckdb import get_db_readonly
|
|
263
267
|
field = (args.get("field") or '').strip()
|
|
264
268
|
_hint = _require_kgdb()
|
|
265
269
|
if _hint:
|
|
266
270
|
return _hint
|
|
267
|
-
con =
|
|
271
|
+
con = get_db_readonly()
|
|
272
|
+
if con is None:
|
|
273
|
+
return "知识图谱暂不可用 (kg.duckdb 连接失败), 稍后重试或联系管理员。"
|
|
268
274
|
try:
|
|
269
275
|
rows = con.execute(
|
|
270
276
|
"SELECT field, title, count, sample_files FROM fields "
|
|
@@ -286,12 +292,14 @@ class KnowledgeGraphMCPServer(BaseMCPServer):
|
|
|
286
292
|
"platform": {"type": "string", "enum": ["web", "app"], "description": "平台过滤。可选"},
|
|
287
293
|
}})
|
|
288
294
|
def _t_list_modules(self, args):
|
|
289
|
-
from domain.kg.storage.kg_duckdb import
|
|
295
|
+
from domain.kg.storage.kg_duckdb import get_db_readonly
|
|
290
296
|
platform = args.get("platform", "")
|
|
291
297
|
_hint = _require_kgdb()
|
|
292
298
|
if _hint:
|
|
293
299
|
return _hint
|
|
294
|
-
con =
|
|
300
|
+
con = get_db_readonly()
|
|
301
|
+
if con is None:
|
|
302
|
+
return "知识图谱暂不可用 (kg.duckdb 连接失败), 稍后重试或联系管理员。"
|
|
295
303
|
try:
|
|
296
304
|
if platform == 'web':
|
|
297
305
|
rows = con.execute("SELECT dir, cn, project FROM modules WHERE project LIKE '%fywl%' ORDER BY dir").fetchall()
|