test.indexes.service.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. let Parse = require('parse/node');
  2. Parse.initialize("dev");
  3. Parse.serverURL = "https://dev.fmode.cn/parse";
  4. Parse.masterKey = "devmk";
  5. global.Parse = Parse
  6. const {IndexesService} = require("../indexes.service")
  7. main()
  8. async function main(){
  9. let docs
  10. // 测试接口
  11. docs = await testApiLoad("https://file-cloud.fmode.cn/Svehl6FceL/20240422/063634869.docx","1bcd2a1b5d47fb3f53ff6adc4066c15e")
  12. // docs = await testApiLoad("https://file-cloud.fmode.cn/Svehl6FceL/20240421/112544165.docx")
  13. // 测试网络文件
  14. // docs = await testLoad("https://file-cloud.fmode.cn/Svehl6FceL/20240421/112544165.docx","测试网络docx")
  15. // 测试本地文件
  16. // docs = await testLoad("temp/温清简历.docx")
  17. // docs = await testLoad("temp/姐姐叙述稿件.docx")
  18. // docs = await testLoad("temp/AI自传语伴介绍.pptx")
  19. // docs = await testLoad("temp/AI自传语伴介绍.pdf")
  20. // docs = await testLoad("temp/AI原型稿5:航价比与补能:VS比亚迪唐DM-i.docx")
  21. // docs = await testLoad("temp/使用说明:脑控科技——用智慧引领未来20221128.docx","测试docx")
  22. // docs = await testLoad("temp/案例正文:脑控科技——用智慧引领未来20221128.pdf","测试pdf")
  23. // docs = await testLoad("temp/如影AI直播软件使用说明(v1.1.1).pdf","测试pdf")
  24. // docs = await testLoad("temp/刘雨飏-区块链技术应用-路演版20220803.pptx","测试pptx")
  25. // docs = await testLoad("https://baijiahao.baidu.com/s?id=1747645032390512034&wfr=spider&for=pc","测试webpage")
  26. }
  27. async function testApiLoad(filelink,md5){
  28. console.log(filelink)
  29. // let host = "http://127.0.0.1:7337"
  30. // let host = "https://server.fmode.cn"
  31. let host = "https://test.fmode.cn"
  32. let response = await fetch(host+"/api/aiagent/indexes/loader",{
  33. method:"POST",
  34. headers: {
  35. 'Content-Type': 'application/json' // 设置Content-Type为application/json
  36. },
  37. body: JSON.stringify({ // 将对象转换为JSON字符串
  38. url: filelink,
  39. md5: md5
  40. })
  41. })
  42. let json = await response.json()
  43. console.log(json)
  44. return json
  45. }
  46. async function testLoad(filelink,msg){
  47. let indexes = new IndexesService();
  48. docs = await indexes.load(filelink)
  49. if(docs?.length>0){
  50. docOutput = await indexes.split(docs)
  51. console.log(docOutput)
  52. }
  53. }