瀏覽代碼

feat: new routes retrive

haitao 3 月之前
父節點
當前提交
baa42d2464

+ 1 - 1
rag-server/api/agent/retrive/routes.js

@@ -15,7 +15,7 @@ const cosineSimilarityQuery = `
         FROM "Document"
         WHERE ($2 IS NULL OR story = $2)
     ) AS subquery
-    ORDER BY similarity
+    ORDER BY similarity DESC
     LIMIT 20;
 `;
 

+ 4 - 0
rag-server/dev-server.js

@@ -1,8 +1,12 @@
 const express = require('express');
 const path = require('path');
 const ParseServer = require('parse-server').ParseServer;
+const cors = require('cors');
 
 const app = express();
+// 使用 CORS 中间件
+app.use(cors()); // 允许所有来源
+
 const api = new ParseServer({
   databaseURI: 'postgresql://dev:666@dev.fmode.cn:5432/dev',
   appId: 'dev',

+ 1 - 0
rag-server/logs/parse-server.info.2024-12-17

@@ -13,3 +13,4 @@
 {"level":"warn","message":"DeprecationWarning: The Parse Server option 'encodeParseObjectInCloudFunction' default will change to 'true' in a future version.","timestamp":"2024-12-17T01:58:42.552Z"}
 {"level":"warn","message":"DeprecationWarning: The Parse Server option 'encodeParseObjectInCloudFunction' default will change to 'true' in a future version.","timestamp":"2024-12-17T01:59:26.544Z"}
 {"level":"warn","message":"DeprecationWarning: The Parse Server option 'encodeParseObjectInCloudFunction' default will change to 'true' in a future version.","timestamp":"2024-12-17T02:00:13.328Z"}
+{"level":"warn","message":"DeprecationWarning: The Parse Server option 'encodeParseObjectInCloudFunction' default will change to 'true' in a future version.","timestamp":"2024-12-17T02:11:03.102Z"}

+ 1 - 1
src/lib/ncloud.ts

@@ -398,7 +398,7 @@ export class CloudApi{
             reqOpts.json = true;
         }
         let host = `http://dev.fmode.cn:1337`
-        host = `http://127.0.0.1:1337`
+        // host = `http://127.0.0.1:1337`
         let url = `${host}/api/`+path
         console.log(url,reqOpts)
         const response = await fetch(url,reqOpts);

+ 0 - 1
src/modules/story/page-hangzhou/page-hangzhou.component.html

@@ -50,7 +50,6 @@
     </ion-item>
     @if(searchDocList?.length){
       @for(doc of searchDocList;track doc){
-
         <ion-item>
           相似度:{{doc.similarity}} 内容:{{doc.pageContent}}
         </ion-item>

+ 4 - 1
src/modules/story/page-hangzhou/page-hangzhou.component.ts

@@ -24,7 +24,9 @@ export class PageHangzhouComponent  implements OnInit {
   }
   constructor() { }
 
-  ngOnInit() {}
+  ngOnInit() {
+    this.loader(this.fileList[0]);
+  }
 
   /**
    * 文档加载、分割、向量存储
@@ -88,6 +90,7 @@ export class PageHangzhouComponent  implements OnInit {
       vector512:vector512
     })
     console.log(result)
+    this.searchDocList = result?.data || result;
   }
 
 }