1
yangbin
2024-08-15 fc38e2635216775a80210d0df109dc6174d66813
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package org.jeecg.modules.ai;
 
import org.jeecg.JeecgSystemApplication;
import org.jeecg.modules.ai.service.IFilePdfInfoService;
import org.jeecg.modules.ai.service.IWebSocketAiService;
import org.jeecg.modules.ai.vo.FilePdfSelectVo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import java.io.File;
 
/**
 * @author clown
 * * @date 2024/7/16
 */
 
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
public class AiTest {
 
    @Autowired
    private IFilePdfInfoService filePdfInfoService;
    @Autowired
    private IWebSocketAiService webSocketAiService;
 
    @Test
    public void selectChatIA() {
        webSocketAiService.selectChatIA();
    }
 
    @Test
    public void filePdf() {
        // 指定文件夹路径
        String directoryPath = "F:\\file";
        // 创建File对象表示文件夹
        File directory = new File(directoryPath);
        // 获取文件夹中所有文件和文件夹
        File[] files = directory.listFiles();
        // 检查文件数组是否为空以及是否存在文件
        if (files != null && files.length > 0) {
            // 遍历文件数组,打印每个文件的名字
            for (File file : files) {
                if (file.isFile()) { // 确保是文件而非文件夹
                    System.out.println(file.getName());
                    filePdfInfoService.uploadFilePdf
                            (new File(directoryPath + "\\" + file.getName()));
                }
            }
        } else {
            System.out.println("文件夹为空或不存在。");
        }
 
    }
 
    @Test
    public void filePdfImg() {
        FilePdfSelectVo vo = new FilePdfSelectVo();
        vo.setPdfContent("刀长");
        vo.setPdfFileId("1821103772084142082");
        filePdfInfoService.findImgPathList(vo);
    }
 
    @Test
    public void sendJsonToHttpsPost() {
      /*  String name = "{\"id\":\"683a65fd-8feb-4446-ad32-714c4785f667\",\"messages\":[{\"role\":\"user\",\"content\":\"给我讲个故事?\"}],\"stream\":true,\"max_tokens\":500}"; // JSON数据
        String url = "https://836u458t54.vicp.fun/chat/test_chat";
        String aiPost =  AiTestUils.sendJsonToHttpsPost(url, name);
        System.out.println(aiPost);*/
 
        String s = "\"data\": {\"id\": \"683a65fd-8feb-4446-ad32-714c4785f667\", \"created\": 1723105518, \"model\": \"YxCareer0.7\", \"choices\": [{\"index\": 0, \"delta\": {\"role\": \"assistant\", \"content\": \"\"}, \"finish_reason\": null}]}";
        System.out.println(s);
 
 
 
    }
 
}