|
@@ -2,206 +2,263 @@ package fastgpt
|
|
|
|
|
|
/**
|
|
|
以下为知识库相关
|
|
|
+================================================================
|
|
|
*/
|
|
|
|
|
|
-//var info DatasetReq
|
|
|
-//info.ParentID = "66cc44d725aea7116ded5281"
|
|
|
-//info.Name = "dataset-测试数据(huaguo)"
|
|
|
-//info.Intro = "测试数据(huaguo)"
|
|
|
-//info.AgentModel = "gpt-3.5-turbo"
|
|
|
-//info.VectorModel = "text-embedding-ada-002"
|
|
|
-//
|
|
|
-//var dataset *DatasetResp
|
|
|
-//dataset, err := CreateDataset(&info)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-// return
|
|
|
-//}
|
|
|
-//fmt.Printf("%v", dataset)
|
|
|
-//fmt.Println(dataset.Code, dataset.StatusText, dataset.Message, dataset.Data)
|
|
|
-
|
|
|
-//resp, err := DeleteDataset("66cc43e125aea7116ded514f")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("code=%v, data=%v, message=%v, statusText=%v", resp.Code, resp.Data, resp.Message, resp.StatusText)
|
|
|
-
|
|
|
-//resp, err := GetDatasetDetail("66cc44d725aea7116ded5281")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("code=%v, data=%v, message=%v, statusText=%v", resp.Code, resp.Data, resp.Message, resp.StatusText)
|
|
|
-
|
|
|
-//resp, err := GetDatasetList("66cc44d725aea7116ded5281")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("%v", resp)
|
|
|
-
|
|
|
-//resp, err := GetCollectionDetail("66cc458925aea7116ded53bc")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("code=%v, data=%v", resp.Code, resp.Data)
|
|
|
+/**
|
|
|
+// 创建数据集
|
|
|
+var info DatasetReq
|
|
|
+info.ParentID = "66cc44d725aea7116ded5281"
|
|
|
+info.Name = "dataset-测试数据(huaguo)"
|
|
|
+info.Intro = "测试数据(huaguo)"
|
|
|
+info.AgentModel = "gpt-3.5-turbo"
|
|
|
+info.VectorModel = "text-embedding-ada-002"
|
|
|
+
|
|
|
+var dataset *DatasetResp
|
|
|
+dataset, err := CreateDataset(&info)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+ return
|
|
|
+}
|
|
|
+fmt.Printf("%v", dataset)
|
|
|
+fmt.Println(dataset.Code, dataset.StatusText, dataset.Message, dataset.Data)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 删除数据集
|
|
|
+resp, err := DeleteDataset("66cc43e125aea7116ded514f")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("code=%v, data=%v, message=%v, statusText=%v", resp.Code, resp.Data, resp.Message, resp.StatusText)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 获取数据集详情
|
|
|
+resp, err := GetDatasetDetail("66cc44d725aea7116ded5281")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("code=%v, data=%v, message=%v, statusText=%v", resp.Code, resp.Data, resp.Message, resp.StatusText)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 获取数据集列表
|
|
|
+resp, err := GetDatasetList("66cc44d725aea7116ded5281")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("%v", resp)
|
|
|
+*/
|
|
|
|
|
|
/**
|
|
|
以下为集合相关
|
|
|
+================================================================
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 获取集合详情
|
|
|
+resp, err := GetCollectionDetail("66cc458925aea7116ded53bc")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("code=%v, data=%v", resp.Code, resp.Data)
|
|
|
*/
|
|
|
|
|
|
-//var params GetCollectionListReq
|
|
|
-//params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
-//params.PageNum = 1
|
|
|
-//params.PageSize = 20
|
|
|
-//resp, err := GetCollectionList(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("code=%v, data=%v", resp.Code, resp.Data)
|
|
|
-
|
|
|
-//var params CreateCollectionReq
|
|
|
-//params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
-//params.Name = "空集合v3"
|
|
|
-//params.Type = "folder"
|
|
|
-//resp, err := CreateEmptyCollection(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("%v", resp)
|
|
|
-
|
|
|
-//var params CreateTextCollectionReq
|
|
|
-//params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
-//params.Name = "文本测试训练v5"
|
|
|
-//params.Text = " 《毒战》改编自杜琪峰执导的同名电影,讲述为了抓捕韩国最大规模贩毒组织的神秘大BOSS李先生,警察元浩与李先生手下成员乐联手破案的故事。 "
|
|
|
-//params.TrainingType = "qa"
|
|
|
-//params.ChunkSize = 8000
|
|
|
-//params.ChunkSplitter = ""
|
|
|
-//params.QaPrompt = "11"
|
|
|
-//resp, err := CreateTextCollection(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("%v", resp)
|
|
|
-
|
|
|
-//var params CreateLinkCollectionReq
|
|
|
-//params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
-//params.Name = "链接测试训练v5"
|
|
|
-//params.Link = "https://doc.in/docs/course/quick-start/"
|
|
|
-//params.TrainingType = "chunk"
|
|
|
-//params.ChunkSize = 512
|
|
|
-//params.ChunkSplitter = ""
|
|
|
-//params.QaPrompt = ""
|
|
|
-//metadata := make(map[string]string)
|
|
|
-//metadata["webPageSelector"] = ".docs-content"
|
|
|
-//params.Metadata = metadata
|
|
|
-//resp, err := CreateLinkCollection(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("collectionId=%v", resp.Data.CollectionID)
|
|
|
-
|
|
|
-//data := make(map[string]string, 8)
|
|
|
-//filePath := "/tmp/movie.txt"
|
|
|
-//data["datasetId"] = "66cc458925aea7116ded53ba"
|
|
|
-//data["trainingType"] = "chunk"
|
|
|
-//data["chunkSize"] = "512"
|
|
|
-//data["chunkSplitter"] = ""
|
|
|
-//data["qaPrompt"] = ""
|
|
|
-//resp, err := CreateFileCollection(&data, filePath)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("%v", resp)
|
|
|
-
|
|
|
-//var params UpdateCollectionReq
|
|
|
-//params.ID = "66cd6c0025aea7116dedb313"
|
|
|
-//params.Name = "链接集合V6"
|
|
|
-//resp, err := UpdateCollection(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
-
|
|
|
-//resp, err := DeleteCollection("66cd6c0025aea7116dedb313")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
+/**
|
|
|
+// 获取集合列表
|
|
|
+var params GetCollectionListReq
|
|
|
+params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
+params.PageNum = 1
|
|
|
+params.PageSize = 20
|
|
|
+resp, err := GetCollectionList(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("code=%v, data=%v", resp.Code, resp.Data)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 创建空集合
|
|
|
+var params CreateCollectionReq
|
|
|
+params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
+params.Name = "空集合v3"
|
|
|
+params.Type = "folder"
|
|
|
+resp, err := CreateEmptyCollection(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 创建文本集合
|
|
|
+var params CreateTextCollectionReq
|
|
|
+params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
+params.Name = "文本测试训练v5"
|
|
|
+params.Text = " 《毒战》改编自杜琪峰执导的同名电影,讲述为了抓捕韩国最大规模贩毒组织的神秘大BOSS李先生,警察元浩与李先生手下成员乐联手破案的故事。 "
|
|
|
+params.TrainingType = "qa"
|
|
|
+params.ChunkSize = 8000
|
|
|
+params.ChunkSplitter = ""
|
|
|
+params.QaPrompt = "11"
|
|
|
+resp, err := CreateTextCollection(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 创建链接集合
|
|
|
+var params CreateLinkCollectionReq
|
|
|
+params.DatasetId = "66cc458925aea7116ded53ba"
|
|
|
+params.Name = "链接测试训练v5"
|
|
|
+params.Link = "https://doc.in/docs/course/quick-start/"
|
|
|
+params.TrainingType = "chunk"
|
|
|
+params.ChunkSize = 512
|
|
|
+params.ChunkSplitter = ""
|
|
|
+params.QaPrompt = ""
|
|
|
+metadata := make(map[string]string)
|
|
|
+metadata["webPageSelector"] = ".docs-content"
|
|
|
+params.Metadata = metadata
|
|
|
+resp, err := CreateLinkCollection(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("collectionId=%v", resp.Data.CollectionID)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 创建文件集合
|
|
|
+data := make(map[string]string, 8)
|
|
|
+filePath := "/tmp/movie.txt"
|
|
|
+data["datasetId"] = "66cc458925aea7116ded53ba"
|
|
|
+data["trainingType"] = "chunk"
|
|
|
+data["chunkSize"] = "512"
|
|
|
+data["chunkSplitter"] = ""
|
|
|
+data["qaPrompt"] = ""
|
|
|
+resp, err := CreateFileCollection(&data, filePath)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 更新集合
|
|
|
+var params UpdateCollectionReq
|
|
|
+params.ID = "66cd6c0025aea7116dedb313"
|
|
|
+params.Name = "链接集合V6"
|
|
|
+resp, err := UpdateCollection(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 删除集合
|
|
|
+resp, err := DeleteCollection("66cd6c0025aea7116dedb313")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
|
|
|
/**
|
|
|
以下为数据相关
|
|
|
+================================================================
|
|
|
*/
|
|
|
|
|
|
-//resp, err := GetDataDetail("66cd773b25aea7116dedc017")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
-
|
|
|
-//var params GetDataListReq
|
|
|
-//params.PageSize = 10
|
|
|
-//params.PageNum = 1
|
|
|
-//params.CollectionId = "66cd773b25aea7116dedc01a"
|
|
|
-//resp, err := GetDataList(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
-
|
|
|
-//var params CreateBulkDataReq
|
|
|
-//params.CollectionID = "66cd773b25aea7116dedc01a"
|
|
|
-//params.TrainingMode = "chunk"
|
|
|
-//params.Data = []DataQuestion{
|
|
|
-// {
|
|
|
-// Q: "你是谁?",
|
|
|
-// A: "我是FastGPT助手",
|
|
|
-// },
|
|
|
-// {
|
|
|
-// Q: "你会什么?",
|
|
|
-// A: "我什么都会",
|
|
|
-// Indexes: []Index{
|
|
|
-// {Text: "自定义索引1"},
|
|
|
-// {Text: "自定义索引2"},
|
|
|
-// },
|
|
|
-// },
|
|
|
-//}
|
|
|
-//resp, err := CreateBulkData(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err.Error())
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
-
|
|
|
-//var params UpdateDataReq
|
|
|
-//params.ID = "66cd7e1925aea7116dedc64b"
|
|
|
-//params.Q = "你是谁3?"
|
|
|
-//params.A = "我是FastGPT助手3"
|
|
|
-//params.Indexes = []Index{
|
|
|
-// {Text: "自定义索引1", DataId: "66cd7e1925aea7116dedc64b", DefaultIndex: true},
|
|
|
-// {Text: "自定义索引2", DataId: "66cd7e1925aea7116dedc64b", DefaultIndex: false},
|
|
|
-//}
|
|
|
-//resp, err := UpdateData(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err)
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
-
|
|
|
-//resp, err := DeleteData("66cd7e1925aea7116dedc651")
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err)
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
+/**
|
|
|
+// 获取数据详情
|
|
|
+resp, err := GetDataDetail("66cd773b25aea7116dedc017")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 获取数据列表
|
|
|
+var params GetDataListReq
|
|
|
+params.PageSize = 10
|
|
|
+params.PageNum = 1
|
|
|
+params.CollectionId = "66cd773b25aea7116dedc01a"
|
|
|
+resp, err := GetDataList(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 批量创建数据
|
|
|
+var params CreateBulkDataReq
|
|
|
+params.CollectionID = "66cd773b25aea7116dedc01a"
|
|
|
+params.TrainingMode = "chunk"
|
|
|
+params.Data = []DataQuestion{
|
|
|
+ {
|
|
|
+ Q: "你是谁?",
|
|
|
+ A: "我是FastGPT助手",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Q: "你会什么?",
|
|
|
+ A: "我什么都会",
|
|
|
+ Indexes: []Index{
|
|
|
+ {Text: "自定义索引1"},
|
|
|
+ {Text: "自定义索引2"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|
|
|
+resp, err := CreateBulkData(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err.Error())
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 更新数据
|
|
|
+var params UpdateDataReq
|
|
|
+params.ID = "66cd7e1925aea7116dedc64b"
|
|
|
+params.Q = "你是谁3?"
|
|
|
+params.A = "我是FastGPT助手3"
|
|
|
+params.Indexes = []Index{
|
|
|
+ {Text: "自定义索引1", DataId: "66cd7e1925aea7116dedc64b", DefaultIndex: true},
|
|
|
+ {Text: "自定义索引2", DataId: "66cd7e1925aea7116dedc64b", DefaultIndex: false},
|
|
|
+}
|
|
|
+resp, err := UpdateData(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err)
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
+
|
|
|
+/**
|
|
|
+// 删除数据
|
|
|
+resp, err := DeleteData("66cd7e1925aea7116dedc651")
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err)
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|
|
|
|
|
|
/**
|
|
|
以下为搜索相关
|
|
|
*/
|
|
|
|
|
|
-//var params SearchReq
|
|
|
-//params.DatasetID = "66cc458925aea7116ded53ba"
|
|
|
-//params.Text = "毒战"
|
|
|
-//params.Limit = 20
|
|
|
-//params.SearchMode = "fullTextRecall"
|
|
|
-//params.UsingReRank = true
|
|
|
-//resp, err := SearchText(¶ms)
|
|
|
-//if err != nil {
|
|
|
-// fmt.Printf("%v", err)
|
|
|
-//}
|
|
|
-//fmt.Printf("resp=%v", resp)
|
|
|
+/**
|
|
|
+// 搜索数据
|
|
|
+var params SearchReq
|
|
|
+params.DatasetID = "66cc458925aea7116ded53ba"
|
|
|
+params.Text = "毒战"
|
|
|
+params.Limit = 20
|
|
|
+params.SearchMode = "fullTextRecall"
|
|
|
+params.UsingReRank = true
|
|
|
+resp, err := SearchText(¶ms)
|
|
|
+if err != nil {
|
|
|
+ fmt.Printf("%v", err)
|
|
|
+}
|
|
|
+fmt.Printf("resp=%v", resp)
|
|
|
+*/
|