package com.fs.fastgptApi;

import com.fs.common.core.domain.R;
import com.fs.fastgptApi.param.ChatParam;
import com.fs.fastgptApi.service.DataSetCollectionService;
import com.fs.fastgptApi.service.Impl.ChatServiceImpl;
import com.fs.fastgptApi.service.Impl.DataSetCollectionServiceImpl;
import com.fs.fastgptApi.service.Impl.DataSetDataServiceImpl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class test {

    public static void main(String[] args) throws IOException {

        DataSetCollectionService service=new DataSetCollectionServiceImpl();
//        DataSetDataService setDataService=new DataSetDataServiceImpl();
//
//        SearchTestParam param=new SearchTestParam();
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//        param.setText("为什么没有值呢?");
//        SearchTestResult searchTestResult = setDataService.searchTest(param);
//        System.out.println(searchTestResult);
//        KnowledgeBaseResult knowledgeBaseResult = service.deleteCollection("66f65450a112750dd7c7d056");
//        System.out.println(knowledgeBaseResult);
//        UpdateCollectionByIdParam param=new UpdateCollectionByIdParam();
//        param.setId("66f8f1116d4b94fbb4f5d833");
//        param.setName("测试文本集合1");
//        KnowledgeBaseResult knowledgeBaseResult = service.updateCollectionInfoById(param);
//        System.out.println(knowledgeBaseResult);
//      CreateTextCollectionParam param=new CreateTextCollectionParam();
//        param.setText("这是一个测试文本");
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//        param.setName("测试文本集合");
//        param.setTrainingType("chunk");
//        param.setChunkSize(6000);
//        param.setQaPrompt("11");
//        CreateTextCollectionResult textCollection = service.createTextCollection(param);
//        System.out.println(textCollection);

//
//        CreateLinkCollectionParam param=new CreateLinkCollectionParam();
//        param.setLink("https://www.baidu.com");
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//        param.setTrainingType("chunk");
//        param.setChunkSize(6000);
//        param.setQaPrompt("11");
//
//        CreateLinkCollectionResult linkCollection = service.createLinkCollection(param);
//        System.out.println(linkCollection);
//        try {
//            File file = new File("C:\\Users\\Administrator\\Desktop\\特丧失用.txt");
//
//            UploadFileParam   param=new UploadFileParam();
//
//            param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//            param.setTrainingType("chunk");
//            param.setChunkSize(8000);
//
//            // 调用 createFileCollection 并获取结果
//            CreateFileCollectionResult fileCollection = service.createFileCollection(file,param);
//
//            // 输出 fileCollection 的结果
//            System.out.println(fileCollection);
//        } catch (IOException e) {
//            e.printStackTrace(); // 处理 IO 异常
//        } catch (Exception e) {
//            e.printStackTrace(); // 处理其他异常
//        }
//
//        GetCollectionListParam param=new GetCollectionListParam();
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//        param.setPageSize(30);
//        param.setPageNum(1);
//        GetCollectionListResult collectionList = service.getCollectionList(param,"mygpt-bCdZPw7jxMY5MjuGnG3jcQClAtlm0LrcF0AqGjX2SG1VuyRVWWxO");
//        System.out.println(collectionList);

//        GetCollectionDetailResult collectionDetail = service.getCollectionDetail("66f8f0cd6d4b94fbb4f5d73d","mygpt-bCdZPw7jxMY5MjuGnG3jcQClAtlm0LrcF0AqGjX2SG1VuyRVWWxO");
//        System.out.println("集合列表:"+collectionDetail);

//
        DataSetDataServiceImpl dataService=new DataSetDataServiceImpl();
////
//        UpdateCollectionDataParam param=new UpdateCollectionDataParam();
////
//        param.setDataId("66f8f24f6d4b94fbb4f5db74");
////        param.setId("66f8f24f6d4b94fbb4f5db74");
//        param.setQ("再改一22次为什么没有值呢？");
//        param.setA("再改一22次我也不知道，你说的啥？");
//        KnowledgeBaseResult knowledgeBaseResult = dataService.updateCollectionData(param);
//        System.out.println(knowledgeBaseResult);

//        KnowledgeBaseResult knowledgeBaseResult = dataService.deleteCollectionData("66f657a1a112750dd7c7d14d");
//        System.out.println(knowledgeBaseResult);

//        GetCollectionDataListParam dataListParam=new GetCollectionDataListParam();
//        dataListParam.setCollectionId("66f64e70a112750dd7c7cf37");
//        GetCollectionDataListResult collectionDataList = dataService.getCollectionDataList(dataListParam);
//        System.out.println("集合里的数据列表:"+collectionDataList);

//        GetCollectionDataDetailResult collectionDataDetail = dataService.getCollectionDataDetail("66f657a1a112750dd7c7d14d");
//        System.out.println(collectionDataDetail);

//        AddDataToCollectionBatchParam param=new AddDataToCollectionBatchParam();
//
//        param.setCollectionId("66f8f0716d4b94fbb4f5d646");
//        param.setTrainingType("chunk");
//
//        List<AddDataToCollectionBatchParam.DataItem> data=new ArrayList<>();
//        AddDataToCollectionBatchParam.DataItem dataItem=new AddDataToCollectionBatchParam.DataItem();
//        dataItem.setQ("chunkchunk文本集合用来干嘛？？");
//        dataItem.setA("chunk我也不知道，你查查百度 https://www.bilibili.com/ ");
//
//        data.add(dataItem);
//
//        AddDataToCollectionBatchParam.DataItem dataItem2=new AddDataToCollectionBatchParam.DataItem();
//        dataItem2.setQ("chunk文本可以访问哔哩哔哩吗？");
//        dataItem2.setA("chunk可以的你看看看看看https://www.bilibili.com/~");
//        data.add(dataItem2);
//
//        param.setData(data);
//
//        AddDataToCollectionBatchResult addDataToCollectionBatchResult = dataService.addDataToCollectionBatch(param);
//        System.out.println(addDataToCollectionBatchResult);

//

//
//        CreateCollectionParam param=new CreateCollectionParam();
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//        param.setName("测试的空的集合");
//        param.setType("virtual");
//
//        KnowledgeBaseResult emptyCollection = service.createEmptyCollection(param);
//        System.out.println(emptyCollection);
//

        ChatServiceImpl ChatService=new ChatServiceImpl();

        ChatParam param=new ChatParam();
//        param.setChatId(UUID.randomUUID().toString().replaceAll("-",""));
        param.setChatId("123456");
        param.setStream(false);
        param.setDetail(true);
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");


        ChatParam.Variables variables=new ChatParam.Variables();
        variables.setUid("asdfadsfasfd2323");
        variables.setName("张三");

        param.setVariables(variables);


        List<ChatParam.Message> messageList=new ArrayList<ChatParam.Message>();

        ChatParam.Message message1=new ChatParam.Message();
            message1.setRole("user");
//            message1.setDataId("66f8ef2f6d4b94fbb4f5d40d");
//            message1.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
            message1.setContent("为什么没有值呢？");
            messageList.add(message1);
        param.setMessages(messageList);

        R r = ChatService.initiatingTakeChat(param,"http://154.8.194.176:3000/api","mygpt-uf1zatbvwH1at4wNEjgBejZrwpoBnZWNP4rxT1dsrKJcfg6o1GvC62Aj47");
//        R r = ChatService.initiatingTakeChat(param,"http://154.8.194.176:3000/api","mygpt-jLLTnqhkUZXMITmgS21JXRNSIkDO0zA4jzUg2on9Bw7ojXzz8BIi");
        System.out.println(r);



//        DataSetServiceImpl knowledgeBaseService=new DataSetServiceImpl();
////
//////获取知识库列表
//        GetKnowledgeBaseListResult knowledgeBaseList = knowledgeBaseService.getKnowledgeBaseList(new GetKnowledgeBaseListParam());
//        System.out.println(knowledgeBaseList);

//        CreateTrainingUsageParam param=new CreateTrainingUsageParam();;
//        param.setDatasetId("66f8ef2f6d4b94fbb4f5d40d");
//        param.setName("文档训练-fastgpt.docx");
//
//        CreateTrainingUsageResult trainingUsage = knowledgeBaseService.createTrainingUsage(param);
//        System.out.println(trainingUsage);

//        CreateKnowledgeBaseParam param=new CreateKnowledgeBaseParam();
//        param.setName("测试知识库sgw");
//        param.setType("dataset");
//        param.setIntro("测试一下这个行不行得痛");
//        param.setVectorModel("dmeta-embedding-zh");
//        param.setAvatar("https://cos.his.cdwjyyh.com/fs/20240909/e4128f1ec01344e28d034ee303994504.png");
//
//
//        KnowledgeBaseResult knowledgeBase = knowledgeBaseService.createKnowledgeBase(param);
//        System.out.println(knowledgeBase);

//        KnowledgeBaseResult knowledgeBaseResult = knowledgeBaseService.deleteKnowledgeBase("66f66e50a112750dd7c7d586");
//        System.out.println(knowledgeBaseResult);

//        GetKnowledgeBaseListResult knowledgeBaseList = knowledgeBaseService.getKnowledgeBaseList(new GetKnowledgeBaseListParam());
//        System.out.println(knowledgeBaseList);

//        GetKnowledgeBaseDetailResult knowledgeBaseDetail = knowledgeBaseService.getKnowledgeBaseDetail("66f4ffbba112750dd7c7aab5");
//        KnowledgeBaseResult result = knowledgeBaseService.deleteKnowledgeBase("66f4ffbba112750dd7c7aab5");
//        System.out.println(result);


//        ShareLinkAuthServiceImpl shareLinkAuthService=new ShareLinkAuthServiceImpl();
//
//        ChatShareAuthInitParam param=new ChatShareAuthInitParam();
//        param.setToken("mygpt-jLLTnqhkUZXMITmgS21JXRNSIkDO0zA4jzUg2on9Bw7ojXzz8BIi");
//        ShareLinkAuthResult shareLinkAuthResult = shareLinkAuthService.chatShareAuthInit(param);
//        System.out.println(shareLinkAuthResult);

    }



}
