|
@@ -942,6 +942,40 @@ router.route("/getGraphs").all(async (req, res, next) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+//提取知识图谱
|
|
|
+router.route("/getGraphs2").all(async (req, res, next) => {
|
|
|
+ console.log(req.body);
|
|
|
+
|
|
|
+ //mode的处理
|
|
|
+ if (req.body[0]) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ let documentIds = decodeURIComponent(req.body[0].fileids).split(",");
|
|
|
+
|
|
|
+ // 使用 Promise.all 并通过 map 返回新的 results 数组
|
|
|
+ let results = await Promise.all(documentIds.map(async documentId => {
|
|
|
+ const response = await client.documents.listRelationships({
|
|
|
+ id: documentId,
|
|
|
+ includeVectors: false,
|
|
|
+ limit: 1000, // 修正这里的参数
|
|
|
+ });
|
|
|
+ return response.results;
|
|
|
+ }));
|
|
|
+
|
|
|
+ // 使用 flat() 合并所有数组
|
|
|
+ results = results.flat();
|
|
|
+
|
|
|
+ res.status(200).json({ result: results });
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
//获取实体和关系
|
|
|
router.route("/getEntitiesAndRelationships").all(async (req, res, next) => {
|
|
|
if (req.body[0]) {
|