usage.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. package fastgpt
  2. /**
  3. 以下为知识库相关
  4. */
  5. //var info DatasetReq
  6. //info.ParentID = "66cc44d725aea7116ded5281"
  7. //info.Name = "dataset-测试数据(huaguo)"
  8. //info.Intro = "测试数据(huaguo)"
  9. //info.AgentModel = "gpt-3.5-turbo"
  10. //info.VectorModel = "text-embedding-ada-002"
  11. //
  12. //var dataset *DatasetResp
  13. //dataset, err := CreateDataset(&info)
  14. //if err != nil {
  15. // fmt.Printf("%v", err.Error())
  16. // return
  17. //}
  18. //fmt.Printf("%v", dataset)
  19. //fmt.Println(dataset.Code, dataset.StatusText, dataset.Message, dataset.Data)
  20. //resp, err := DeleteDataset("66cc43e125aea7116ded514f")
  21. //if err != nil {
  22. // fmt.Printf("%v", err.Error())
  23. //}
  24. //fmt.Printf("code=%v, data=%v, message=%v, statusText=%v", resp.Code, resp.Data, resp.Message, resp.StatusText)
  25. //resp, err := GetDatasetDetail("66cc44d725aea7116ded5281")
  26. //if err != nil {
  27. // fmt.Printf("%v", err.Error())
  28. //}
  29. //fmt.Printf("code=%v, data=%v, message=%v, statusText=%v", resp.Code, resp.Data, resp.Message, resp.StatusText)
  30. //resp, err := GetDatasetList("66cc44d725aea7116ded5281")
  31. //if err != nil {
  32. // fmt.Printf("%v", err.Error())
  33. //}
  34. //fmt.Printf("%v", resp)
  35. //resp, err := GetCollectionDetail("66cc458925aea7116ded53bc")
  36. //if err != nil {
  37. // fmt.Printf("%v", err.Error())
  38. //}
  39. //fmt.Printf("code=%v, data=%v", resp.Code, resp.Data)
  40. /**
  41. 以下为集合相关
  42. */
  43. //var params GetCollectionListReq
  44. //params.DatasetId = "66cc458925aea7116ded53ba"
  45. //params.PageNum = 1
  46. //params.PageSize = 20
  47. //resp, err := GetCollectionList(&params)
  48. //if err != nil {
  49. // fmt.Printf("%v", err.Error())
  50. //}
  51. //fmt.Printf("code=%v, data=%v", resp.Code, resp.Data)
  52. //var params CreateCollectionReq
  53. //params.DatasetId = "66cc458925aea7116ded53ba"
  54. //params.Name = "空集合v3"
  55. //params.Type = "folder"
  56. //resp, err := CreateEmptyCollection(&params)
  57. //if err != nil {
  58. // fmt.Printf("%v", err.Error())
  59. //}
  60. //fmt.Printf("%v", resp)
  61. //var params CreateTextCollectionReq
  62. //params.DatasetId = "66cc458925aea7116ded53ba"
  63. //params.Name = "文本测试训练v5"
  64. //params.Text = " 《毒战》改编自杜琪峰执导的同名电影,讲述为了抓捕韩国最大规模贩毒组织的神秘大BOSS李先生,警察元浩与李先生手下成员乐联手破案的故事。 "
  65. //params.TrainingType = "qa"
  66. //params.ChunkSize = 8000
  67. //params.ChunkSplitter = ""
  68. //params.QaPrompt = "11"
  69. //resp, err := CreateTextCollection(&params)
  70. //if err != nil {
  71. // fmt.Printf("%v", err.Error())
  72. //}
  73. //fmt.Printf("%v", resp)
  74. //var params CreateLinkCollectionReq
  75. //params.DatasetId = "66cc458925aea7116ded53ba"
  76. //params.Name = "链接测试训练v5"
  77. //params.Link = "https://doc.in/docs/course/quick-start/"
  78. //params.TrainingType = "chunk"
  79. //params.ChunkSize = 512
  80. //params.ChunkSplitter = ""
  81. //params.QaPrompt = ""
  82. //metadata := make(map[string]string)
  83. //metadata["webPageSelector"] = ".docs-content"
  84. //params.Metadata = metadata
  85. //resp, err := CreateLinkCollection(&params)
  86. //if err != nil {
  87. // fmt.Printf("%v", err.Error())
  88. //}
  89. //fmt.Printf("collectionId=%v", resp.Data.CollectionID)
  90. //data := make(map[string]string, 8)
  91. //filePath := "/tmp/movie.txt"
  92. //data["datasetId"] = "66cc458925aea7116ded53ba"
  93. //data["trainingType"] = "chunk"
  94. //data["chunkSize"] = "512"
  95. //data["chunkSplitter"] = ""
  96. //data["qaPrompt"] = ""
  97. //resp, err := CreateFileCollection(&data, filePath)
  98. //if err != nil {
  99. // fmt.Printf("%v", err.Error())
  100. //}
  101. //fmt.Printf("%v", resp)
  102. //var params UpdateCollectionReq
  103. //params.ID = "66cd6c0025aea7116dedb313"
  104. //params.Name = "链接集合V6"
  105. //resp, err := UpdateCollection(&params)
  106. //if err != nil {
  107. // fmt.Printf("%v", err.Error())
  108. //}
  109. //fmt.Printf("resp=%v", resp)
  110. //resp, err := DeleteCollection("66cd6c0025aea7116dedb313")
  111. //if err != nil {
  112. // fmt.Printf("%v", err.Error())
  113. //}
  114. //fmt.Printf("resp=%v", resp)
  115. /**
  116. 以下为数据相关
  117. */
  118. //resp, err := GetDataDetail("66cd773b25aea7116dedc017")
  119. //if err != nil {
  120. // fmt.Printf("%v", err.Error())
  121. //}
  122. //fmt.Printf("resp=%v", resp)
  123. //var params GetDataListReq
  124. //params.PageSize = 10
  125. //params.PageNum = 1
  126. //params.CollectionId = "66cd773b25aea7116dedc01a"
  127. //resp, err := GetDataList(&params)
  128. //if err != nil {
  129. // fmt.Printf("%v", err.Error())
  130. //}
  131. //fmt.Printf("resp=%v", resp)
  132. //var params CreateBulkDataReq
  133. //params.CollectionID = "66cd773b25aea7116dedc01a"
  134. //params.TrainingMode = "chunk"
  135. //params.Data = []DataQuestion{
  136. // {
  137. // Q: "你是谁?",
  138. // A: "我是FastGPT助手",
  139. // },
  140. // {
  141. // Q: "你会什么?",
  142. // A: "我什么都会",
  143. // Indexes: []Index{
  144. // {Text: "自定义索引1"},
  145. // {Text: "自定义索引2"},
  146. // },
  147. // },
  148. //}
  149. //resp, err := CreateBulkData(&params)
  150. //if err != nil {
  151. // fmt.Printf("%v", err.Error())
  152. //}
  153. //fmt.Printf("resp=%v", resp)
  154. //var params UpdateDataReq
  155. //params.ID = "66cd7e1925aea7116dedc64b"
  156. //params.Q = "你是谁3?"
  157. //params.A = "我是FastGPT助手3"
  158. //params.Indexes = []Index{
  159. // {Text: "自定义索引1", DataId: "66cd7e1925aea7116dedc64b", DefaultIndex: true},
  160. // {Text: "自定义索引2", DataId: "66cd7e1925aea7116dedc64b", DefaultIndex: false},
  161. //}
  162. //resp, err := UpdateData(&params)
  163. //if err != nil {
  164. // fmt.Printf("%v", err)
  165. //}
  166. //fmt.Printf("resp=%v", resp)
  167. //resp, err := DeleteData("66cd7e1925aea7116dedc651")
  168. //if err != nil {
  169. // fmt.Printf("%v", err)
  170. //}
  171. //fmt.Printf("resp=%v", resp)
  172. /**
  173. 以下为搜索相关
  174. */
  175. //var params SearchReq
  176. //params.DatasetID = "66cc458925aea7116ded53ba"
  177. //params.Text = "毒战"
  178. //params.Limit = 20
  179. //params.SearchMode = "fullTextRecall"
  180. //params.UsingReRank = true
  181. //resp, err := SearchText(&params)
  182. //if err != nil {
  183. // fmt.Printf("%v", err)
  184. //}
  185. //fmt.Printf("resp=%v", resp)