From fbb21e4433cfbc024c07be10aae8d735ff41347a Mon Sep 17 00:00:00 2001 From: hanyuqing <1106611654@qq.com> Date: Thu, 25 Dec 2025 08:32:42 +0800 Subject: [PATCH] all --- controller/GraphController.py | 80 +++++-- util/neo4j_utils.py | 7 +- vue/src/App.vue | 2 +- vue/src/api/builder.js | 6 + vue/src/assets/logo1.png | Bin 0 -> 1086 bytes vue/src/components/Menu.vue | 87 +++++--- vue/src/system/GraphBuilder.vue | 178 ++++++++++++++-- vue/src/system/GraphDemo.vue | 451 +++++++++++++++++++++------------------- vue/src/system/Login.vue | 85 +++----- vue/src/system/Profile.vue | 3 +- vue/src/utils/request.js | 2 +- 11 files changed, 564 insertions(+), 337 deletions(-) create mode 100644 vue/src/assets/logo1.png diff --git a/controller/GraphController.py b/controller/GraphController.py index f70c951..7c8032f 100644 --- a/controller/GraphController.py +++ b/controller/GraphController.py @@ -209,31 +209,75 @@ def health(): return {"status": "ok", "drug_cached": redis_get(DRUG_TREE_KEY) is not None} +# @app.post("/api/analyze") +# async def analyze(request): +# # 假设前端传入 JSON: {"text": "病例文本..."} +# body = request.json() +# input_text = body.get("text", "").strip() +# +# if not input_text: +# return jsonify({"error": "缺少 text 字段"}), 400 +# client = httpx.AsyncClient(base_url="http://192.168.50.113:8088") +# # 调用实体关系抽取服务 +# response = await client.post( +# "/extract_entities_and_relations", +# json={"text": input_text} +# ) +# print(response) +# if response.status_code == 200: +# result = response.json() +# return jsonify(result) +# else: +# return jsonify({ +# "error": "实体抽取服务返回错误", +# "status": response.status_code, +# "detail": response.text +# }), response.status_code + + +# 全局 client(可复用) +client = httpx.AsyncClient(base_url="http://192.168.50.113:8088") + @app.post("/api/analyze") async def analyze(request): + body = request.json() + input_text = body.get("text", "").strip() + if not input_text: + return jsonify({"error": "缺少 text 字段"}), 400 try: - # 假设前端传入 JSON: {"text": "病例文本..."} - body = request.json() - input_text = body.get("text", "").strip() - - if not input_text: - return jsonify({"error": "缺少 text 字段"}), 400 - client = httpx.AsyncClient(base_url="http://192.168.50.113:8088") - # 调用实体关系抽取服务 - response = await client.post( + # 直接转发到大模型服务(假设它返回 { "task_id": "xxx" }) + resp = await client.post( "/extract_entities_and_relations", - json={"text": input_text} + json={"text": input_text}, + timeout=1800.0 # 30分钟 ) - print(response) - if response.status_code == 200: - result = response.json() - return jsonify(result) + print(resp) + + if resp.status_code == 202 or resp.status_code == 200: + return Response( + status_code=200, + description=jsonify(resp.json()), + headers={"Content-Type": "text/plain; charset=utf-8"} + ) else: return jsonify({ - "error": "实体抽取服务返回错误", - "status": response.status_code, - "detail": response.text - }), response.status_code + "error": "提交失败", + "detail": resp.text + }), resp.status_code + except Exception as e: + return jsonify({"error": str(e)}), 500 + +@app.get("/api/analyze/status") +async def get_status(): + try: + # 直接转发状态查询到大模型服务 + resp = await client.get( + "/status", + timeout=5.0 + ) + return jsonify(resp.json()), resp.status_code + except httpx.ReadTimeout: + return jsonify({"error": "状态查询超时"}), 500 except Exception as e: return jsonify({"error": str(e)}), 500 \ No newline at end of file diff --git a/util/neo4j_utils.py b/util/neo4j_utils.py index 00ede2c..79b5206 100644 --- a/util/neo4j_utils.py +++ b/util/neo4j_utils.py @@ -320,10 +320,8 @@ class Neo4jUtil: raise RuntimeError( f"查询邻居节点时发生数据库错误: {str(e)}" ) from e # 使用 'from e' 保留原始异常链 - print(raw_results) + neighbors = [] - print("Ssssssssss") - print(len(raw_results)) for row in raw_results: source = dict(row["sourceProps"]) source.update({"id": row["sourceId"], "label": row["sourceLabel"]}) @@ -339,8 +337,7 @@ class Neo4jUtil: "target": target, "relationship": relationship }) - print(relationship) - print(neighbors) + return neighbors # def find_neighbors_with_relationships( # self, diff --git a/vue/src/App.vue b/vue/src/App.vue index aea1aa5..651fe04 100644 --- a/vue/src/App.vue +++ b/vue/src/App.vue @@ -10,10 +10,10 @@ export default { \ No newline at end of file diff --git a/vue/src/api/builder.js b/vue/src/api/builder.js index 627d2d6..2c9f715 100644 --- a/vue/src/api/builder.js +++ b/vue/src/api/builder.js @@ -13,3 +13,9 @@ export function analyze(data) { data }); } +export function getAIStatus() { + return request({ + url: '/api/analyze/status', + method: 'get', + }); +} \ No newline at end of file diff --git a/vue/src/assets/logo1.png b/vue/src/assets/logo1.png new file mode 100644 index 0000000000000000000000000000000000000000..581cd7ad7a0464ffb107701fccf9a3ca15982c7a GIT binary patch literal 1086 zcmV-E1i|}>P)D-nQtxC4$E_&bGdiDA8&K-ZQuTqoA>0L)1Ke^yzhC=x%WiG zPk4kEVt_RB=?^5Bx^PhelmSP8%|J0w{r|DN$-V)5 zG^8kI{EfyZ(p4Gd)?opV)i7>8arsD;A4hhy4MkmK89%42Oq?aQ(DKbv@f6v2f%bN_ zG$aD)4wIf518E}rY9o>DEwXKGAYz4fBKws6J)OivS?J{KHM|!L><)1);QT+Z{V41` z5q?8=WV!XaIdIXoB`nK;K`+&AE7%P=1yEIM6%P-7Bil3vR!o5bFT#bZkhcTQU4j0| zFmW)9e-o)pa^Y49uCDps!&S#O-Vtd&p4hF_FGvSruw+M|>A_MWExMuoM( zo{fXd5s)P8gDNO$Uhxssn49rf0;?E(i zU)^N=rY=VWd@~uwy#e>CVe_y0O7uyB)D-QrVjFz*o&Q0iBcUi;vxwy9%QrNWT(5v` z)2z$-%?1x2LH1gxya(?OfpLRs_xawkv6$vWvyUxe-*V8%%JaxDCI3d*nf{vQz$aQD8JzZj!)p<_JUzFRlhfGe0Uy5h>4H4OeajGm?dOHV|FR zZdfAuQ;BYTUh4`OLqWojzYB8K=^i3jf|5;2gwX?_vI@p8h6CoYe*GSNGz<=u!e@EG zOS=R0MV3N6+df zr8BI`)ctNkYnU@i+rQrrH4j238+1014N2Z~NND9*FS&QxN=;>f zD#@WmdqW#lLM2;Y$OOC7NL;H$_L2=mtZ+$WkJ;bT$w86bVgnH?Y!TTabNFCq%Ei-R zPDN(fTy~~>4{$BF65T}&EaZzt#?NDKFc -
-