You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

http_api_reference.md 80KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901
  1. ---
  2. sidebar_position: 1
  3. slug: /http_api_reference
  4. ---
  5. # HTTP API Reference
  6. A complete reference for RAGFlow's RESTful API. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](https://ragflow.io/docs/dev/acquire_ragflow_api_key).
  7. ---
  8. ## DATASET MANAGEMENT
  9. ---
  10. ### Create dataset
  11. **POST** `/api/v1/datasets`
  12. Creates a dataset.
  13. #### Request
  14. - Method: POST
  15. - URL: `/api/v1/datasets`
  16. - Headers:
  17. - `'content-Type: application/json'`
  18. - `'Authorization: Bearer <YOUR_API_KEY>'`
  19. - Body:
  20. - `"name"`: `string`
  21. - `"avatar"`: `string`
  22. - `"description"`: `string`
  23. - `"language"`: `string`
  24. - `"embedding_model"`: `string`
  25. - `"permission"`: `string`
  26. - `"chunk_method"`: `string`
  27. - `"parser_config"`: `object`
  28. ##### Request example
  29. ```bash
  30. curl --request POST \
  31. --url http://{address}/api/v1/datasets \
  32. --header 'Content-Type: application/json' \
  33. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  34. --data '{
  35. "name": "test_1"
  36. }'
  37. ```
  38. ##### Request parameters
  39. - `"name"`: (*Body parameter*), `string`, *Required*
  40. The unique name of the dataset to create. It must adhere to the following requirements:
  41. - Permitted characters include:
  42. - English letters (a-z, A-Z)
  43. - Digits (0-9)
  44. - "_" (underscore)
  45. - Must begin with an English letter or underscore.
  46. - Maximum 65,535 characters.
  47. - Case-insensitive.
  48. - `"avatar"`: (*Body parameter*), `string`
  49. Base64 encoding of the avatar.
  50. - `"description"`: (*Body parameter*), `string`
  51. A brief description of the dataset to create.
  52. - `"language"`: (*Body parameter*), `string`
  53. The language setting of the dataset to create. Available options:
  54. - `"English"` (default)
  55. - `"Chinese"`
  56. - `"embedding_model"`: (*Body parameter*), `string`
  57. The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`
  58. - `"permission"`: (*Body parameter*), `string`
  59. Specifies who can access the dataset to create. Available options:
  60. - `"me"`: (Default) Only you can manage the dataset.
  61. - `"team"`: All team members can manage the dataset.
  62. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  63. The chunking method of the dataset to create. Available options:
  64. - `"naive"`: General (default)
  65. - `"manual"`: Manual
  66. - `"qa"`: Q&A
  67. - `"table"`: Table
  68. - `"paper"`: Paper
  69. - `"book"`: Book
  70. - `"laws"`: Laws
  71. - `"presentation"`: Presentation
  72. - `"picture"`: Picture
  73. - `"one"`: One
  74. - `"knowledge_graph"`: Knowledge Graph
  75. Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
  76. - `"email"`: Email
  77. - `"parser_config"`: (*Body parameter*), `object`
  78. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  79. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  80. - `"chunk_token_count"`: Defaults to `128`.
  81. - `"layout_recognize"`: Defaults to `true`.
  82. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  83. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  84. - `"task_page_size"`: Defaults to `12`. For PDF only.
  85. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  86. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  87. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  88. - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
  89. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  90. - `"chunk_token_count"`: Defaults to `128`.
  91. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  92. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  93. #### Response
  94. Success:
  95. ```json
  96. {
  97. "code": 0,
  98. "data": {
  99. "avatar": null,
  100. "chunk_count": 0,
  101. "chunk_method": "naive",
  102. "create_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  103. "create_time": 1729761247434,
  104. "created_by": "69736c5e723611efb51b0242ac120007",
  105. "description": null,
  106. "document_count": 0,
  107. "embedding_model": "BAAI/bge-large-zh-v1.5",
  108. "id": "527fa74891e811ef9c650242ac120006",
  109. "language": "English",
  110. "name": "test_1",
  111. "parser_config": {
  112. "chunk_token_num": 128,
  113. "delimiter": "\\n!?;。;!?",
  114. "html4excel": false,
  115. "layout_recognize": true,
  116. "raptor": {
  117. "user_raptor": false
  118. }
  119. },
  120. "permission": "me",
  121. "similarity_threshold": 0.2,
  122. "status": "1",
  123. "tenant_id": "69736c5e723611efb51b0242ac120007",
  124. "token_num": 0,
  125. "update_date": "Thu, 24 Oct 2024 09:14:07 GMT",
  126. "update_time": 1729761247434,
  127. "vector_similarity_weight": 0.3
  128. }
  129. }
  130. ```
  131. Failure:
  132. ```json
  133. {
  134. "code": 102,
  135. "message": "Duplicated knowledgebase name in creating dataset."
  136. }
  137. ```
  138. ---
  139. ### Delete datasets
  140. **DELETE** `/api/v1/datasets`
  141. Deletes datasets by ID.
  142. #### Request
  143. - Method: DELETE
  144. - URL: `/api/v1/datasets`
  145. - Headers:
  146. - `'content-Type: application/json'`
  147. - `'Authorization: Bearer <YOUR_API_KEY>'`
  148. - Body:
  149. - `"ids"`: `list[string]`
  150. ##### Request example
  151. ```bash
  152. curl --request DELETE \
  153. --url http://{address}/api/v1/datasets \
  154. --header 'Content-Type: application/json' \
  155. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  156. --data '{
  157. "ids": ["test_1", "test_2"]
  158. }'
  159. ```
  160. ##### Request parameters
  161. - `"ids"`: (*Body parameter*), `list[string]`
  162. The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
  163. #### Response
  164. Success:
  165. ```json
  166. {
  167. "code": 0
  168. }
  169. ```
  170. Failure:
  171. ```json
  172. {
  173. "code": 102,
  174. "message": "You don't own the dataset."
  175. }
  176. ```
  177. ---
  178. ### Update dataset
  179. **PUT** `/api/v1/datasets/{dataset_id}`
  180. Updates configurations for a specified dataset.
  181. #### Request
  182. - Method: PUT
  183. - URL: `/api/v1/datasets/{dataset_id}`
  184. - Headers:
  185. - `'content-Type: application/json'`
  186. - `'Authorization: Bearer <YOUR_API_KEY>'`
  187. - Body:
  188. - `"name"`: `string`
  189. - `"embedding_model"`: `string`
  190. - `"chunk_method"`: `enum<string>`
  191. ##### Request example
  192. ```bash
  193. curl --request PUT \
  194. --url http://{address}/api/v1/datasets/{dataset_id} \
  195. --header 'Content-Type: application/json' \
  196. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  197. --data '
  198. {
  199. "name": "updated_dataset"
  200. }'
  201. ```
  202. ##### Request parameters
  203. - `dataset_id`: (*Path parameter*)
  204. The ID of the dataset to update.
  205. - `"name"`: (*Body parameter*), `string`
  206. The revised name of the dataset.
  207. - `"embedding_model"`: (*Body parameter*), `string`
  208. The updated embedding model name.
  209. - Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
  210. - `"chunk_method"`: (*Body parameter*), `enum<string>`
  211. The chunking method for the dataset. Available options:
  212. - `"naive"`: General
  213. - `"manual`: Manual
  214. - `"qa"`: Q&A
  215. - `"table"`: Table
  216. - `"paper"`: Paper
  217. - `"book"`: Book
  218. - `"laws"`: Laws
  219. - `"presentation"`: Presentation
  220. - `"picture"`: Picture
  221. - `"one"`:One
  222. - `"email"`: Email
  223. - `"knowledge_graph"`: Knowledge Graph
  224. Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
  225. #### Response
  226. Success:
  227. ```json
  228. {
  229. "code": 0
  230. }
  231. ```
  232. Failure:
  233. ```json
  234. {
  235. "code": 102,
  236. "message": "Can't change tenant_id."
  237. }
  238. ```
  239. ---
  240. ### List datasets
  241. **GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  242. Lists datasets.
  243. #### Request
  244. - Method: GET
  245. - URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  246. - Headers:
  247. - `'Authorization: Bearer <YOUR_API_KEY>'`
  248. ##### Request example
  249. ```bash
  250. curl --request GET \
  251. --url http://{address}/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  252. --header 'Authorization: Bearer <YOUR_API_KEY>'
  253. ```
  254. ##### Request parameters
  255. - `page`: (*Filter parameter*)
  256. Specifies the page on which the datasets will be displayed. Defaults to `1`.
  257. - `page_size`: (*Filter parameter*)
  258. The number of datasets on each page. Defaults to `30`.
  259. - `orderby`: (*Filter parameter*)
  260. The field by which datasets should be sorted. Available options:
  261. - `create_time` (default)
  262. - `update_time`
  263. - `desc`: (*Filter parameter*)
  264. Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `true`.
  265. - `name`: (*Filter parameter*)
  266. The name of the dataset to retrieve.
  267. - `id`: (*Filter parameter*)
  268. The ID of the dataset to retrieve.
  269. #### Response
  270. Success:
  271. ```json
  272. {
  273. "code": 0,
  274. "data": [
  275. {
  276. "avatar": "",
  277. "chunk_count": 59,
  278. "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
  279. "create_time": 1726276357324,
  280. "created_by": "69736c5e723611efb51b0242ac120007",
  281. "description": null,
  282. "document_count": 1,
  283. "embedding_model": "BAAI/bge-large-zh-v1.5",
  284. "id": "6e211ee0723611efa10a0242ac120007",
  285. "language": "English",
  286. "name": "mysql",
  287. "chunk_method": "knowledge_graph",
  288. "parser_config": {
  289. "chunk_token_num": 8192,
  290. "delimiter": "\\n!?;。;!?",
  291. "entity_types": [
  292. "organization",
  293. "person",
  294. "location",
  295. "event",
  296. "time"
  297. ]
  298. },
  299. "permission": "me",
  300. "similarity_threshold": 0.2,
  301. "status": "1",
  302. "tenant_id": "69736c5e723611efb51b0242ac120007",
  303. "token_num": 12744,
  304. "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
  305. "update_time": 1728533243536,
  306. "vector_similarity_weight": 0.3
  307. }
  308. ]
  309. }
  310. ```
  311. Failure:
  312. ```json
  313. {
  314. "code": 102,
  315. "message": "The dataset doesn't exist"
  316. }
  317. ```
  318. ---
  319. ## FILE MANAGEMENT WITHIN DATASET
  320. ---
  321. ### Upload documents
  322. **POST** `/api/v1/datasets/{dataset_id}/documents`
  323. Uploads documents to a specified dataset.
  324. #### Request
  325. - Method: POST
  326. - URL: `/api/v1/datasets/{dataset_id}/documents`
  327. - Headers:
  328. - `'Content-Type: multipart/form-data'`
  329. - `'Authorization: Bearer <YOUR_API_KEY>'`
  330. - Form:
  331. - `'file=@{FILE_PATH}'`
  332. ##### Request example
  333. ```bash
  334. curl --request POST \
  335. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  336. --header 'Content-Type: multipart/form-data' \
  337. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  338. --form 'file=@./test1.txt' \
  339. --form 'file=@./test2.pdf'
  340. ```
  341. ##### Request parameters
  342. - `dataset_id`: (*Path parameter*)
  343. The ID of the dataset to which the documents will be uploaded.
  344. - `'file'`: (*Body parameter*)
  345. A document to upload.
  346. #### Response
  347. Success:
  348. ```json
  349. {
  350. "code": 0,
  351. "data": [
  352. {
  353. "chunk_method": "naive",
  354. "created_by": "69736c5e723611efb51b0242ac120007",
  355. "dataset_id": "527fa74891e811ef9c650242ac120006",
  356. "id": "b330ec2e91ec11efbc510242ac120004",
  357. "location": "1.txt",
  358. "name": "1.txt",
  359. "parser_config": {
  360. "chunk_token_num": 128,
  361. "delimiter": "\\n!?;。;!?",
  362. "html4excel": false,
  363. "layout_recognize": true,
  364. "raptor": {
  365. "user_raptor": false
  366. }
  367. },
  368. "run": "UNSTART",
  369. "size": 17966,
  370. "thumbnail": "",
  371. "type": "doc"
  372. }
  373. ]
  374. }
  375. ```
  376. Failure:
  377. ```json
  378. {
  379. "code": 101,
  380. "message": "No file part!"
  381. }
  382. ```
  383. ---
  384. ### Update document
  385. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  386. Updates configurations for a specified document.
  387. #### Request
  388. - Method: PUT
  389. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  390. - Headers:
  391. - `'content-Type: application/json'`
  392. - `'Authorization: Bearer <YOUR_API_KEY>'`
  393. - Body:
  394. - `"name"`:`string`
  395. - `"chunk_method"`:`string`
  396. - `"parser_config"`:`object`
  397. ##### Request example
  398. ```bash
  399. curl --request PUT \
  400. --url http://{address}/api/v1/datasets/{dataset_id}/info/{document_id} \
  401. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  402. --header 'Content-Type: application/json' \
  403. --data '
  404. {
  405. "name": "manual.txt",
  406. "chunk_method": "manual",
  407. "parser_config": {"chunk_token_count": 128}
  408. }'
  409. ```
  410. ##### Request parameters
  411. - `dataset_id`: (*Path parameter*)
  412. The ID of the associated dataset.
  413. - `document_id`: (*Path parameter*)
  414. The ID of the document to update.
  415. - `"name"`: (*Body parameter*), `string`
  416. - `"chunk_method"`: (*Body parameter*), `string`
  417. The parsing method to apply to the document:
  418. - `"naive"`: General
  419. - `"manual`: Manual
  420. - `"qa"`: Q&A
  421. - `"table"`: Table
  422. - `"paper"`: Paper
  423. - `"book"`: Book
  424. - `"laws"`: Laws
  425. - `"presentation"`: Presentation
  426. - `"picture"`: Picture
  427. - `"one"`: One
  428. - `"knowledge_graph"`: Knowledge Graph
  429. Ensure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
  430. - `"email"`: Email
  431. - `"parser_config"`: (*Body parameter*), `object`
  432. The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
  433. - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
  434. - `"chunk_token_count"`: Defaults to `128`.
  435. - `"layout_recognize"`: Defaults to `true`.
  436. - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
  437. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  438. - `"task_page_size"`: Defaults to `12`. For PDF only.
  439. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  440. - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
  441. - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
  442. - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
  443. - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
  444. - `"chunk_token_count"`: Defaults to `128`.
  445. - `"delimiter"`: Defaults to `"\n!?。;!?"`.
  446. - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
  447. #### Response
  448. Success:
  449. ```json
  450. {
  451. "code": 0
  452. }
  453. ```
  454. Failure:
  455. ```json
  456. {
  457. "code": 102,
  458. "message": "The dataset does not have the document."
  459. }
  460. ```
  461. ---
  462. ### Download document
  463. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  464. Downloads a document from a specified dataset.
  465. #### Request
  466. - Method: GET
  467. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
  468. - Headers:
  469. - `'Authorization: Bearer <YOUR_API_KEY>'`
  470. - Output:
  471. - `'{PATH_TO_THE_FILE}'`
  472. ##### Request example
  473. ```bash
  474. curl --request GET \
  475. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id} \
  476. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  477. --output ./ragflow.txt
  478. ```
  479. ##### Request parameters
  480. - `dataset_id`: (*Path parameter*)
  481. The associated dataset ID.
  482. - `documents_id`: (*Path parameter*)
  483. The ID of the document to download.
  484. #### Response
  485. Success:
  486. ```json
  487. This is a test to verify the file download feature.
  488. ```
  489. Failure:
  490. ```json
  491. {
  492. "code": 102,
  493. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  494. }
  495. ```
  496. ---
  497. ### List documents
  498. **GET** `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
  499. Lists documents in a specified dataset.
  500. #### Request
  501. - Method: GET
  502. - URL: `/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}`
  503. - Headers:
  504. - `'content-Type: application/json'`
  505. - `'Authorization: Bearer <YOUR_API_KEY>'`
  506. ##### Request example
  507. ```bash
  508. curl --request GET \
  509. --url http://{address}/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name} \
  510. --header 'Authorization: Bearer <YOUR_API_KEY>'
  511. ```
  512. ##### Request parameters
  513. - `dataset_id`: (*Path parameter*)
  514. The associated dataset ID.
  515. - `keywords`: (*Filter parameter*), `string`
  516. The keywords used to match document titles.
  517. - `page`: (*Filter parameter*), `integer`
  518. Specifies the page on which the documents will be displayed. Defaults to `1`.
  519. - `page_size`: (*Filter parameter*), `integer`
  520. The maximum number of documents on each page. Defaults to `30`.
  521. - `orderby`: (*Filter parameter*), `string`
  522. The field by which documents should be sorted. Available options:
  523. - `create_time` (default)
  524. - `update_time`
  525. - `desc`: (*Filter parameter*), `boolean`
  526. Indicates whether the retrieved documents should be sorted in descending order. Defaults to `true`.
  527. - `id`: (*Filter parameter*), `string`
  528. The ID of the document to retrieve.
  529. #### Response
  530. Success:
  531. ```json
  532. {
  533. "code": 0,
  534. "data": {
  535. "docs": [
  536. {
  537. "chunk_count": 0,
  538. "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  539. "create_time": 1728897061948,
  540. "created_by": "69736c5e723611efb51b0242ac120007",
  541. "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
  542. "knowledgebase_id": "7898da028a0511efbf750242ac120005",
  543. "location": "Test_2.txt",
  544. "name": "Test_2.txt",
  545. "parser_config": {
  546. "chunk_token_count": 128,
  547. "delimiter": "\n!?。;!?",
  548. "layout_recognize": true,
  549. "task_page_size": 12
  550. },
  551. "chunk_method": "naive",
  552. "process_begin_at": null,
  553. "process_duation": 0.0,
  554. "progress": 0.0,
  555. "progress_msg": "",
  556. "run": "0",
  557. "size": 7,
  558. "source_type": "local",
  559. "status": "1",
  560. "thumbnail": null,
  561. "token_count": 0,
  562. "type": "doc",
  563. "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
  564. "update_time": 1728897061948
  565. }
  566. ],
  567. "total": 1
  568. }
  569. }
  570. ```
  571. Failure:
  572. ```json
  573. {
  574. "code": 102,
  575. "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
  576. }
  577. ```
  578. ---
  579. ### Delete documents
  580. **DELETE** `/api/v1/datasets/{dataset_id}/documents`
  581. Deletes documents by ID.
  582. #### Request
  583. - Method: DELETE
  584. - URL: `/api/v1/datasets/{dataset_id}/documents`
  585. - Headers:
  586. - `'Content-Type: application/json'`
  587. - `'Authorization: Bearer <YOUR_API_KEY>'`
  588. - Body:
  589. - `"ids"`: `list[string]`
  590. ##### Request example
  591. ```bash
  592. curl --request DELETE \
  593. --url http://{address}/api/v1/datasets/{dataset_id}/documents \
  594. --header 'Content-Type: application/json' \
  595. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  596. --data '
  597. {
  598. "ids": ["id_1","id_2"]
  599. }'
  600. ```
  601. ##### Request parameters
  602. - `dataset_id`: (*Path parameter*)
  603. The associated dataset ID.
  604. - `"ids"`: (*Body parameter*), `list[string]`
  605. The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
  606. #### Response
  607. Success:
  608. ```json
  609. {
  610. "code": 0
  611. }.
  612. ```
  613. Failure:
  614. ```json
  615. {
  616. "code": 102,
  617. "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
  618. }
  619. ```
  620. ---
  621. ### Parse documents
  622. **POST** `/api/v1/datasets/{dataset_id}/chunks`
  623. Parses documents in a specified dataset.
  624. #### Request
  625. - Method: POST
  626. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  627. - Headers:
  628. - `'content-Type: application/json'`
  629. - `'Authorization: Bearer <YOUR_API_KEY>'`
  630. - Body:
  631. - `"document_ids"`: `list[string]`
  632. ##### Request example
  633. ```bash
  634. curl --request POST \
  635. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  636. --header 'Content-Type: application/json' \
  637. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  638. --data '
  639. {
  640. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  641. }'
  642. ```
  643. ##### Request parameters
  644. - `dataset_id`: (*Path parameter*)
  645. The dataset ID.
  646. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  647. The IDs of the documents to parse.
  648. #### Response
  649. Success:
  650. ```json
  651. {
  652. "code": 0
  653. }
  654. ```
  655. Failure:
  656. ```json
  657. {
  658. "code": 102,
  659. "message": "`document_ids` is required"
  660. }
  661. ```
  662. ---
  663. ### Stop parsing documents
  664. **DELETE** `/api/v1/datasets/{dataset_id}/chunks`
  665. Stops parsing specified documents.
  666. #### Request
  667. - Method: DELETE
  668. - URL: `/api/v1/datasets/{dataset_id}/chunks`
  669. - Headers:
  670. - `'content-Type: application/json'`
  671. - `'Authorization: Bearer <YOUR_API_KEY>'`
  672. - Body:
  673. - `"document_ids"`: `list[string]`
  674. ##### Request example
  675. ```bash
  676. curl --request DELETE \
  677. --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
  678. --header 'Content-Type: application/json' \
  679. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  680. --data '
  681. {
  682. "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
  683. }'
  684. ```
  685. ##### Request parameters
  686. - `dataset_id`: (*Path parameter*)
  687. The associated dataset ID.
  688. - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
  689. The IDs of the documents for which the parsing should be stopped.
  690. #### Response
  691. Success:
  692. ```json
  693. {
  694. "code": 0
  695. }
  696. ```
  697. Failure:
  698. ```json
  699. {
  700. "code": 102,
  701. "message": "`document_ids` is required"
  702. }
  703. ```
  704. ---
  705. ### Add chunk
  706. **POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  707. Adds a chunk to a specified document in a specified dataset.
  708. #### Request
  709. - Method: POST
  710. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  711. - Headers:
  712. - `'content-Type: application/json'`
  713. - `'Authorization: Bearer <YOUR_API_KEY>'`
  714. - Body:
  715. - `"content"`: `string`
  716. - `"important_keywords"`: `list[string]`
  717. ##### Request example
  718. ```bash
  719. curl --request POST \
  720. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  721. --header 'Content-Type: application/json' \
  722. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  723. --data '
  724. {
  725. "content": "<CHUNK_CONTENT_HERE>"
  726. }'
  727. ```
  728. ##### Request parameters
  729. - `dataset_id`: (*Path parameter*)
  730. The associated dataset ID.
  731. - `document_ids`: (*Path parameter*)
  732. The associated document ID.
  733. - `"content"`: (*Body parameter*), `string`, *Required*
  734. The text content of the chunk.
  735. - `"important_keywords`(*Body parameter*), `list[string]`
  736. The key terms or phrases to tag with the chunk.
  737. #### Response
  738. Success:
  739. ```json
  740. {
  741. "code": 0,
  742. "data": {
  743. "chunk": {
  744. "content": "ragflow content",
  745. "create_time": "2024-10-16 08:05:04",
  746. "create_timestamp": 1729065904.581025,
  747. "dataset_id": [
  748. "c7ee74067a2c11efb21c0242ac120006"
  749. ],
  750. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  751. "id": "d78435d142bd5cf6704da62c778795c5",
  752. "important_keywords": []
  753. }
  754. }
  755. }
  756. ```
  757. Failure:
  758. ```json
  759. {
  760. "code": 102,
  761. "message": "`content` is required"
  762. }
  763. ```
  764. ---
  765. ### List chunks
  766. **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}`
  767. Lists chunks in a specified document.
  768. #### Request
  769. - Method: GET
  770. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id}`
  771. - Headers:
  772. - `'Authorization: Bearer <YOUR_API_KEY>'`
  773. ##### Request example
  774. ```bash
  775. curl --request GET \
  776. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id} \
  777. --header 'Authorization: Bearer <YOUR_API_KEY>'
  778. ```
  779. ##### Request parameters
  780. - `dataset_id`: (*Path parameter*)
  781. The associated dataset ID.
  782. - `document_ids`: (*Path parameter*)
  783. The associated document ID.
  784. - `keywords`(*Filter parameter*), `string`
  785. The keywords used to match chunk content.
  786. - `page`(*Filter parameter*), `integer`
  787. Specifies the page on which the chunks will be displayed. Defaults to `1`.
  788. - `page_size`(*Filter parameter*), `integer`
  789. The maximum number of chunks on each page. Defaults to `1024`.
  790. - `id`(*Filter parameter*), `string`
  791. The ID of the chunk to retrieve.
  792. #### Response
  793. Success:
  794. ```json
  795. {
  796. "code": 0,
  797. "data": {
  798. "chunks": [
  799. {
  800. "available_int": 1,
  801. "content": "This is a test content.",
  802. "docnm_kwd": "1.txt",
  803. "document_id": "b330ec2e91ec11efbc510242ac120004",
  804. "id": "b48c170e90f70af998485c1065490726",
  805. "image_id": "",
  806. "important_keywords": "",
  807. "positions": [
  808. ""
  809. ]
  810. }
  811. ],
  812. "doc": {
  813. "chunk_count": 1,
  814. "chunk_method": "naive",
  815. "create_date": "Thu, 24 Oct 2024 09:45:27 GMT",
  816. "create_time": 1729763127646,
  817. "created_by": "69736c5e723611efb51b0242ac120007",
  818. "dataset_id": "527fa74891e811ef9c650242ac120006",
  819. "id": "b330ec2e91ec11efbc510242ac120004",
  820. "location": "1.txt",
  821. "name": "1.txt",
  822. "parser_config": {
  823. "chunk_token_num": 128,
  824. "delimiter": "\\n!?;。;!?",
  825. "html4excel": false,
  826. "layout_recognize": true,
  827. "raptor": {
  828. "user_raptor": false
  829. }
  830. },
  831. "process_begin_at": "Thu, 24 Oct 2024 09:56:44 GMT",
  832. "process_duation": 0.54213,
  833. "progress": 0.0,
  834. "progress_msg": "Task dispatched...",
  835. "run": "2",
  836. "size": 17966,
  837. "source_type": "local",
  838. "status": "1",
  839. "thumbnail": "",
  840. "token_count": 8,
  841. "type": "doc",
  842. "update_date": "Thu, 24 Oct 2024 11:03:15 GMT",
  843. "update_time": 1729767795721
  844. },
  845. "total": 1
  846. }
  847. }
  848. ```
  849. Failure:
  850. ```json
  851. {
  852. "code": 102,
  853. "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
  854. }
  855. ```
  856. ---
  857. ### Delete chunks
  858. **DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  859. Deletes chunks by ID.
  860. #### Request
  861. - Method: DELETE
  862. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
  863. - Headers:
  864. - `'content-Type: application/json'`
  865. - `'Authorization: Bearer <YOUR_API_KEY>'`
  866. - Body:
  867. - `"chunk_ids"`: `list[string]`
  868. ##### Request example
  869. ```bash
  870. curl --request DELETE \
  871. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
  872. --header 'Content-Type: application/json' \
  873. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  874. --data '
  875. {
  876. "chunk_ids": ["test_1", "test_2"]
  877. }'
  878. ```
  879. ##### Request parameters
  880. - `dataset_id`: (*Path parameter*)
  881. The associated dataset ID.
  882. - `document_ids`: (*Path parameter*)
  883. The associated document ID.
  884. - `"chunk_ids"`: (*Body parameter*), `list[string]`
  885. The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
  886. #### Response
  887. Success:
  888. ```json
  889. {
  890. "code": 0
  891. }
  892. ```
  893. Failure:
  894. ```json
  895. {
  896. "code": 102,
  897. "message": "`chunk_ids` is required"
  898. }
  899. ```
  900. ---
  901. ### Update chunk
  902. **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  903. Updates content or configurations for a specified chunk.
  904. #### Request
  905. - Method: PUT
  906. - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
  907. - Headers:
  908. - `'content-Type: application/json'`
  909. - `'Authorization: Bearer <YOUR_API_KEY>'`
  910. - Body:
  911. - `"content"`: `string`
  912. - `"important_keywords"`: `list[string]`
  913. - `"available"`: `boolean`
  914. ##### Request example
  915. ```bash
  916. curl --request PUT \
  917. --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} \
  918. --header 'Content-Type: application/json' \
  919. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  920. --data '
  921. {
  922. "content": "ragflow123",
  923. "important_keywords": []
  924. }'
  925. ```
  926. ##### Request parameters
  927. - `dataset_id`: (*Path parameter*)
  928. The associated dataset ID.
  929. - `document_ids`: (*Path parameter*)
  930. The associated document ID.
  931. - `chunk_id`: (*Path parameter*)
  932. The ID of the chunk to update.
  933. - `"content"`: (*Body parameter*), `string`
  934. The text content of the chunk.
  935. - `"important_keywords"`: (*Body parameter*), `list[string]`
  936. A list of key terms or phrases to tag with the chunk.
  937. - `"available"`: (*Body parameter*) `boolean`
  938. The chunk's availability status in the dataset. Value options:
  939. - `true`: Available (default)
  940. - `false`: Unavailable
  941. #### Response
  942. Success:
  943. ```json
  944. {
  945. "code": 0
  946. }
  947. ```
  948. Failure:
  949. ```json
  950. {
  951. "code": 102,
  952. "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
  953. }
  954. ```
  955. ---
  956. ### Retrieve chunks
  957. **POST** `/api/v1/retrieval`
  958. Retrieves chunks from specified datasets.
  959. #### Request
  960. - Method: POST
  961. - URL: `/api/v1/retrieval`
  962. - Headers:
  963. - `'content-Type: application/json'`
  964. - `'Authorization: Bearer <YOUR_API_KEY>'`
  965. - Body:
  966. - `"question"`: `string`
  967. - `"dataset_ids"`: `list[string]`
  968. - `"document_ids"`: `list[string]`
  969. - `"page"`: `integer`
  970. - `"page_size"`: `integer`
  971. - `"similarity_threshold"`: `float`
  972. - `"vector_similarity_weight"`: `float`
  973. - `"top_k"`: `integer`
  974. - `"rerank_id"`: `string`
  975. - `"keyword"`: `boolean`
  976. - `"highlight"`: `boolean`
  977. ##### Request example
  978. ```bash
  979. curl --request POST \
  980. --url http://{address}/api/v1/retrieval \
  981. --header 'Content-Type: application/json' \
  982. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  983. --data '
  984. {
  985. "question": "What is advantage of ragflow?",
  986. "dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
  987. "document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
  988. }'
  989. ```
  990. ##### Request parameter
  991. - `"question"`: (*Body parameter*), `string`, *Required*
  992. The user query or query keywords.
  993. - `"dataset_ids"`: (*Body parameter*) `list[string]`
  994. The IDs of the datasets to search. If you do not set this argument, ensure that you set `"document_ids"`.
  995. - `"document_ids"`: (*Body parameter*), `list[string]`
  996. The IDs of the documents to search. Ensure that all selected documents use the same embedding model. Otherwise, an error will occur. If you do not set this argument, ensure that you set `"dataset_ids"`.
  997. - `"page"`: (*Body parameter*), `integer`
  998. Specifies the page on which the chunks will be displayed. Defaults to `1`.
  999. - `"page_size"`: (*Body parameter*)
  1000. The maximum number of chunks on each page. Defaults to `30`.
  1001. - `"similarity_threshold"`: (*Body parameter*)
  1002. The minimum similarity score. Defaults to `0.2`.
  1003. - `"vector_similarity_weight"`: (*Body parameter*), `float`
  1004. The weight of vector cosine similarity. Defaults to `0.3`. If x represents the weight of vector cosine similarity, then (1 - x) is the term similarity weight.
  1005. - `"top_k"`: (*Body parameter*), `integer`
  1006. The number of chunks engaged in vector cosine computaton. Defaults to `1024`.
  1007. - `"rerank_id"`: (*Body parameter*), `integer`
  1008. The ID of the rerank model.
  1009. - `"keyword"`: (*Body parameter*), `boolean`
  1010. Indicates whether to enable keyword-based matching:
  1011. - `true`: Enable keyword-based matching.
  1012. - `false`: Disable keyword-based matching (default).
  1013. - `"highlight"`: (*Body parameter*), `boolean`
  1014. Specifies whether to enable highlighting of matched terms in the results:
  1015. - `true`: Enable highlighting of matched terms.
  1016. - `false`: Disable highlighting of matched terms (default).
  1017. #### Response
  1018. Success:
  1019. ```json
  1020. {
  1021. "code": 0,
  1022. "data": {
  1023. "chunks": [
  1024. {
  1025. "content": "ragflow content",
  1026. "content_ltks": "ragflow content",
  1027. "document_id": "5c5999ec7be811ef9cab0242ac120005",
  1028. "document_keyword": "1.txt",
  1029. "highlight": "<em>ragflow</em> content",
  1030. "id": "d78435d142bd5cf6704da62c778795c5",
  1031. "image_id": "",
  1032. "important_keywords": [
  1033. ""
  1034. ],
  1035. "kb_id": "c7ee74067a2c11efb21c0242ac120006",
  1036. "positions": [
  1037. ""
  1038. ],
  1039. "similarity": 0.9669436601210759,
  1040. "term_similarity": 1.0,
  1041. "vector_similarity": 0.8898122004035864
  1042. }
  1043. ],
  1044. "doc_aggs": [
  1045. {
  1046. "count": 1,
  1047. "doc_id": "5c5999ec7be811ef9cab0242ac120005",
  1048. "doc_name": "1.txt"
  1049. }
  1050. ],
  1051. "total": 1
  1052. }
  1053. }
  1054. ```
  1055. Failure:
  1056. ```json
  1057. {
  1058. "code": 102,
  1059. "message": "`datasets` is required."
  1060. }
  1061. ```
  1062. ---
  1063. ## CHAT ASSISTANT MANAGEMENT
  1064. ---
  1065. ### Create chat assistant
  1066. **POST** `/api/v1/chats`
  1067. Creates a chat assistant.
  1068. #### Request
  1069. - Method: POST
  1070. - URL: `/api/v1/chats`
  1071. - Headers:
  1072. - `'content-Type: application/json'`
  1073. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1074. - Body:
  1075. - `"name"`: `string`
  1076. - `"avatar"`: `string`
  1077. - `"dataset_ids"`: `list[string]`
  1078. - `"llm"`: `object`
  1079. - `"prompt"`: `object`
  1080. ##### Request example
  1081. ```shell
  1082. curl --request POST \
  1083. --url http://{address}/api/v1/chats \
  1084. --header 'Content-Type: application/json' \
  1085. --header 'Authorization: Bearer <YOUR_API_KEY>'
  1086. --data '{
  1087. "dataset_ids": ["0b2cbc8c877f11ef89070242ac120005"],
  1088. "name":"new_chat_1"
  1089. }'
  1090. ```
  1091. ##### Request parameters
  1092. - `"name"`: (*Body parameter*), `string`, *Required*
  1093. The name of the chat assistant.
  1094. - `"avatar"`: (*Body parameter*), `string`
  1095. Base64 encoding of the avatar.
  1096. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1097. The IDs of the associated datasets.
  1098. - `"llm"`: (*Body parameter*), `object`
  1099. The LLM settings for the chat assistant to create. If it is not explicitly set, a JSON object with the following values will be generated as the default. An `llm` JSON object contains the following attributes:
  1100. - `"model_name"`, `string`
  1101. The chat model name. If not set, the user's default chat model will be used.
  1102. - `"temperature"`: `float`
  1103. Controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses. Defaults to `0.1`.
  1104. - `"top_p"`: `float`
  1105. Also known as “nucleus sampling”, this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones. Defaults to `0.3`
  1106. - `"presence_penalty"`: `float`
  1107. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1108. - `"frequency penalty"`: `float`
  1109. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1110. - `"max_token"`: `integer`
  1111. The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
  1112. - `"prompt"`: (*Body parameter*), `object`
  1113. Instructions for the LLM to follow. If it is not explicitly set, a JSON object with the following values will be generated as the default. A `prompt` JSON object contains the following attributes:
  1114. - `"similarity_threshold"`: `float` RAGFlow employs either a combination of weighted keyword similarity and weighted vector cosine similarity, or a combination of weighted keyword similarity and weighted reranking score during retrieval. This argument sets the threshold for similarities between the user query and chunks. If a similarity score falls below this threshold, the corresponding chunk will be excluded from the results. The default value is `0.2`.
  1115. - `"keywords_similarity_weight"`: `float` This argument sets the weight of keyword similarity in the hybrid similarity score with vector cosine similarity or reranking model similarity. By adjusting this weight, you can control the influence of keyword similarity in relation to other similarity measures. The default value is `0.7`.
  1116. - `"top_n"`: `int` This argument specifies the number of top chunks with similarity scores above the `similarity_threshold` that are fed to the LLM. The LLM will *only* access these 'top N' chunks. The default value is `8`.
  1117. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1118. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1119. - All the variables in 'System' should be curly bracketed.
  1120. - The default value is `[{"key": "knowledge", "optional": true}]`.
  1121. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1122. - `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
  1123. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1124. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1125. - `"prompt"`: `string` The prompt content.
  1126. #### Response
  1127. Success:
  1128. ```json
  1129. {
  1130. "code": 0,
  1131. "data": {
  1132. "avatar": "",
  1133. "create_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1134. "create_time": 1729768709023,
  1135. "dataset_ids": [
  1136. "527fa74891e811ef9c650242ac120006"
  1137. ],
  1138. "description": "A helpful Assistant",
  1139. "do_refer": "1",
  1140. "id": "b1f2f15691f911ef81180242ac120003",
  1141. "language": "English",
  1142. "llm": {
  1143. "frequency_penalty": 0.7,
  1144. "max_tokens": 512,
  1145. "model_name": "qwen-plus@Tongyi-Qianwen",
  1146. "presence_penalty": 0.4,
  1147. "temperature": 0.1,
  1148. "top_p": 0.3
  1149. },
  1150. "name": "12234",
  1151. "prompt": {
  1152. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1153. "keywords_similarity_weight": 0.3,
  1154. "opener": "Hi! I'm your assistant, what can I do for you?",
  1155. "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n ",
  1156. "rerank_model": "",
  1157. "similarity_threshold": 0.2,
  1158. "top_n": 6,
  1159. "variables": [
  1160. {
  1161. "key": "knowledge",
  1162. "optional": false
  1163. }
  1164. ]
  1165. },
  1166. "prompt_type": "simple",
  1167. "status": "1",
  1168. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1169. "top_k": 1024,
  1170. "update_date": "Thu, 24 Oct 2024 11:18:29 GMT",
  1171. "update_time": 1729768709023
  1172. }
  1173. }
  1174. ```
  1175. Failure:
  1176. ```json
  1177. {
  1178. "code": 102,
  1179. "message": "Duplicated chat name in creating dataset."
  1180. }
  1181. ```
  1182. ---
  1183. ### Update chat assistant
  1184. **PUT** `/api/v1/chats/{chat_id}`
  1185. Updates configurations for a specified chat assistant.
  1186. #### Request
  1187. - Method: PUT
  1188. - URL: `/api/v1/chats/{chat_id}`
  1189. - Headers:
  1190. - `'content-Type: application/json'`
  1191. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1192. - Body:
  1193. - `"name"`: `string`
  1194. - `"avatar"`: `string`
  1195. - `"dataset_ids"`: `list[string]`
  1196. - `"llm"`: `object`
  1197. - `"prompt"`: `object`
  1198. ##### Request example
  1199. ```bash
  1200. curl --request PUT \
  1201. --url http://{address}/api/v1/chats/{chat_id} \
  1202. --header 'Content-Type: application/json' \
  1203. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1204. --data '
  1205. {
  1206. "name":"Test"
  1207. }'
  1208. ```
  1209. #### Parameters
  1210. - `chat_id`: (*Path parameter*)
  1211. The ID of the chat assistant to update.
  1212. - `"name"`: (*Body parameter*), `string`, *Required*
  1213. The revised name of the chat assistant.
  1214. - `"avatar"`: (*Body parameter*), `string`
  1215. Base64 encoding of the avatar.
  1216. - `"dataset_ids"`: (*Body parameter*), `list[string]`
  1217. The IDs of the associated datasets.
  1218. - `"llm"`: (*Body parameter*), `object`
  1219. The LLM settings for the chat assistant to create. If it is not explicitly set, a dictionary with the following values will be generated as the default. An `llm` object contains the following attributes:
  1220. - `"model_name"`, `string`
  1221. The chat model name. If not set, the user's default chat model will be used.
  1222. - `"temperature"`: `float`
  1223. Controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses. Defaults to `0.1`.
  1224. - `"top_p"`: `float`
  1225. Also known as “nucleus sampling”, this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones. Defaults to `0.3`
  1226. - `"presence_penalty"`: `float`
  1227. This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
  1228. - `"frequency penalty"`: `float`
  1229. Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
  1230. - `"max_token"`: `integer`
  1231. The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to `512`. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
  1232. - `"prompt"`: (*Body parameter*), `object`
  1233. Instructions for the LLM to follow. A `prompt` object contains the following attributes:
  1234. - `"similarity_threshold"`: `float` RAGFlow employs either a combination of weighted keyword similarity and weighted vector cosine similarity, or a combination of weighted keyword similarity and weighted rerank score during retrieval. This argument sets the threshold for similarities between the user query and chunks. If a similarity score falls below this threshold, the corresponding chunk will be excluded from the results. The default value is `0.2`.
  1235. - `"keywords_similarity_weight"`: `float` This argument sets the weight of keyword similarity in the hybrid similarity score with vector cosine similarity or reranking model similarity. By adjusting this weight, you can control the influence of keyword similarity in relation to other similarity measures. The default value is `0.7`.
  1236. - `"top_n"`: `int` This argument specifies the number of top chunks with similarity scores above the `similarity_threshold` that are fed to the LLM. The LLM will *only* access these 'top N' chunks. The default value is `8`.
  1237. - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
  1238. - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
  1239. - All the variables in 'System' should be curly bracketed.
  1240. - The default value is `[{"key": "knowledge", "optional": true}]`
  1241. - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
  1242. - `"empty_response"`: `string` If nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank.
  1243. - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
  1244. - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
  1245. - `"prompt"`: `string` The prompt content.
  1246. #### Response
  1247. Success:
  1248. ```json
  1249. {
  1250. "code": 0
  1251. }
  1252. ```
  1253. Failure:
  1254. ```json
  1255. {
  1256. "code": 102,
  1257. "message": "Duplicated chat name in updating dataset."
  1258. }
  1259. ```
  1260. ---
  1261. ### Delete chat assistants
  1262. **DELETE** `/api/v1/chats`
  1263. Deletes chat assistants by ID.
  1264. #### Request
  1265. - Method: DELETE
  1266. - URL: `/api/v1/chats`
  1267. - Headers:
  1268. - `'content-Type: application/json'`
  1269. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1270. - Body:
  1271. - `"ids"`: `list[string]`
  1272. ##### Request example
  1273. ```bash
  1274. curl --request DELETE \
  1275. --url http://{address}/api/v1/chats \
  1276. --header 'Content-Type: application/json' \
  1277. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1278. --data '
  1279. {
  1280. "ids": ["test_1", "test_2"]
  1281. }'
  1282. ```
  1283. ##### Request parameters
  1284. - `"ids"`: (*Body parameter*), `list[string]`
  1285. The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
  1286. #### Response
  1287. Success:
  1288. ```json
  1289. {
  1290. "code": 0
  1291. }
  1292. ```
  1293. Failure:
  1294. ```json
  1295. {
  1296. "code": 102,
  1297. "message": "ids are required"
  1298. }
  1299. ```
  1300. ---
  1301. ### List chat assistants
  1302. **GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}`
  1303. Lists chat assistants.
  1304. #### Request
  1305. - Method: GET
  1306. - URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
  1307. - Headers:
  1308. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1309. ##### Request example
  1310. ```bash
  1311. curl --request GET \
  1312. --url http://{address}/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
  1313. --header 'Authorization: Bearer <YOUR_API_KEY>'
  1314. ```
  1315. ##### Request parameters
  1316. - `page`: (*Filter parameter*), `integer`
  1317. Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
  1318. - `page_size`: (*Filter parameter*), `integer`
  1319. The number of chat assistants on each page. Defaults to `30`.
  1320. - `orderby`: (*Filter parameter*), `string`
  1321. The attribute by which the results are sorted. Available options:
  1322. - `create_time` (default)
  1323. - `update_time`
  1324. - `desc`: (*Filter parameter*), `boolean`
  1325. Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `true`.
  1326. - `id`: (*Filter parameter*), `string`
  1327. The ID of the chat assistant to retrieve.
  1328. - `name`: (*Filter parameter*), `string`
  1329. The name of the chat assistant to retrieve.
  1330. #### Response
  1331. Success:
  1332. ```json
  1333. {
  1334. "code": 0,
  1335. "data": [
  1336. {
  1337. "avatar": "",
  1338. "create_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  1339. "create_time": 1729232406637,
  1340. "description": "A helpful Assistant",
  1341. "do_refer": "1",
  1342. "id": "04d0d8e28d1911efa3630242ac120006",
  1343. "dataset_ids": ["527fa74891e811ef9c650242ac120006"],
  1344. "language": "English",
  1345. "llm": {
  1346. "frequency_penalty": 0.7,
  1347. "max_tokens": 512,
  1348. "model_name": "qwen-plus@Tongyi-Qianwen",
  1349. "presence_penalty": 0.4,
  1350. "temperature": 0.1,
  1351. "top_p": 0.3
  1352. },
  1353. "name": "13243",
  1354. "prompt": {
  1355. "empty_response": "Sorry! No relevant content was found in the knowledge base!",
  1356. "keywords_similarity_weight": 0.3,
  1357. "opener": "Hi! I'm your assistant, what can I do for you?",
  1358. "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence \"The answer you are looking for is not found in the knowledge base!\" Answers need to consider chat history.\n",
  1359. "rerank_model": "",
  1360. "similarity_threshold": 0.2,
  1361. "top_n": 6,
  1362. "variables": [
  1363. {
  1364. "key": "knowledge",
  1365. "optional": false
  1366. }
  1367. ]
  1368. },
  1369. "prompt_type": "simple",
  1370. "status": "1",
  1371. "tenant_id": "69736c5e723611efb51b0242ac120007",
  1372. "top_k": 1024,
  1373. "update_date": "Fri, 18 Oct 2024 06:20:06 GMT",
  1374. "update_time": 1729232406638
  1375. }
  1376. ]
  1377. }
  1378. ```
  1379. Failure:
  1380. ```json
  1381. {
  1382. "code": 102,
  1383. "message": "The chat doesn't exist"
  1384. }
  1385. ```
  1386. ---
  1387. ## SESSION MANAGEMENT
  1388. ---
  1389. ### Create session with chat assistant
  1390. **POST** `/api/v1/chats/{chat_id}/sessions`
  1391. Creates a session with a chat assistant.
  1392. #### Request
  1393. - Method: POST
  1394. - URL: `/api/v1/chats/{chat_id}/sessions`
  1395. - Headers:
  1396. - `'content-Type: application/json'`
  1397. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1398. - Body:
  1399. - `"name"`: `string`
  1400. ##### Request example
  1401. ```bash
  1402. curl --request POST \
  1403. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  1404. --header 'Content-Type: application/json' \
  1405. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1406. --data '
  1407. {
  1408. "name": "new session"
  1409. }'
  1410. ```
  1411. ##### Request parameters
  1412. - `chat_id`: (*Path parameter*)
  1413. The ID of the associated chat assistant.
  1414. - `"name"`: (*Body parameter*), `string`
  1415. The name of the chat session to create.
  1416. #### Response
  1417. Success:
  1418. ```json
  1419. {
  1420. "code": 0,
  1421. "data": {
  1422. "chat_id": "2ca4b22e878011ef88fe0242ac120005",
  1423. "create_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1424. "create_time": 1728636374571,
  1425. "id": "4606b4ec87ad11efbc4f0242ac120006",
  1426. "messages": [
  1427. {
  1428. "content": "Hi! I am your assistant,can I help you?",
  1429. "role": "assistant"
  1430. }
  1431. ],
  1432. "name": "new session",
  1433. "update_date": "Fri, 11 Oct 2024 08:46:14 GMT",
  1434. "update_time": 1728636374571
  1435. }
  1436. }
  1437. ```
  1438. Failure:
  1439. ```json
  1440. {
  1441. "code": 102,
  1442. "message": "Name cannot be empty."
  1443. }
  1444. ```
  1445. ---
  1446. ### Update chat assistant's session
  1447. **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
  1448. Updates a session of a specified chat assistant.
  1449. #### Request
  1450. - Method: PUT
  1451. - URL: `/api/v1/chats/{chat_id}/sessions/{session_id}`
  1452. - Headers:
  1453. - `'content-Type: application/json'`
  1454. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1455. - Body:
  1456. - `"name`: `string`
  1457. ##### Request example
  1458. ```bash
  1459. curl --request PUT \
  1460. --url http://{address}/api/v1/chats/{chat_id}/sessions/{session_id} \
  1461. --header 'Content-Type: application/json' \
  1462. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1463. --data '
  1464. {
  1465. "name": "<REVISED_SESSION_NAME_HERE>"
  1466. }'
  1467. ```
  1468. ##### Request Parameter
  1469. - `chat_id`: (*Path parameter*)
  1470. The ID of the associated chat assistant.
  1471. - `session_id`: (*Path parameter*)
  1472. The ID of the session to update.
  1473. - `"name"`: (*Body Parameter*), `string`
  1474. The revised name of the session.
  1475. #### Response
  1476. Success:
  1477. ```json
  1478. {
  1479. "code": 0
  1480. }
  1481. ```
  1482. Failure:
  1483. ```json
  1484. {
  1485. "code": 102,
  1486. "message": "Name cannot be empty."
  1487. }
  1488. ```
  1489. ---
  1490. ### List chat assistant's sessions
  1491. **GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
  1492. Lists sessions associated with a specified chat assistant.
  1493. #### Request
  1494. - Method: GET
  1495. - URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
  1496. - Headers:
  1497. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1498. ##### Request example
  1499. ```bash
  1500. curl --request GET \
  1501. --url http://{address}/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id} \
  1502. --header 'Authorization: Bearer <YOUR_API_KEY>'
  1503. ```
  1504. ##### Request Parameters
  1505. - `chat_id`: (*Path parameter*)
  1506. The ID of the associated chat assistant.
  1507. - `page`: (*Filter parameter*), `integer`
  1508. Specifies the page on which the sessions will be displayed. Defaults to `1`.
  1509. - `page_size`: (*Filter parameter*), `integer`
  1510. The number of sessions on each page. Defaults to `30`.
  1511. - `orderby`: (*Filter parameter*), `string`
  1512. The field by which sessions should be sorted. Available options:
  1513. - `create_time` (default)
  1514. - `update_time`
  1515. - `desc`: (*Filter parameter*), `boolean`
  1516. Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
  1517. - `name`: (*Filter parameter*) `string`
  1518. The name of the chat session to retrieve.
  1519. - `id`: (*Filter parameter*), `string`
  1520. The ID of the chat session to retrieve.
  1521. #### Response
  1522. Success:
  1523. ```json
  1524. {
  1525. "code": 0,
  1526. "data": [
  1527. {
  1528. "chat": "2ca4b22e878011ef88fe0242ac120005",
  1529. "create_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1530. "create_time": 1728636403974,
  1531. "id": "578d541e87ad11ef96b90242ac120006",
  1532. "messages": [
  1533. {
  1534. "content": "Hi! I am your assistant,can I help you?",
  1535. "role": "assistant"
  1536. }
  1537. ],
  1538. "name": "new session",
  1539. "update_date": "Fri, 11 Oct 2024 08:46:43 GMT",
  1540. "update_time": 1728636403974
  1541. }
  1542. ]
  1543. }
  1544. ```
  1545. Failure:
  1546. ```json
  1547. {
  1548. "code": 102,
  1549. "message": "The session doesn't exist"
  1550. }
  1551. ```
  1552. ---
  1553. ### Delete chat assistant's sessions
  1554. **DELETE** `/api/v1/chats/{chat_id}/sessions`
  1555. Deletes sessions of a chat assistant by ID.
  1556. #### Request
  1557. - Method: DELETE
  1558. - URL: `/api/v1/chats/{chat_id}/sessions`
  1559. - Headers:
  1560. - `'content-Type: application/json'`
  1561. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1562. - Body:
  1563. - `"ids"`: `list[string]`
  1564. ##### Request example
  1565. ```bash
  1566. curl --request DELETE \
  1567. --url http://{address}/api/v1/chats/{chat_id}/sessions \
  1568. --header 'Content-Type: application/json' \
  1569. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1570. --data '
  1571. {
  1572. "ids": ["test_1", "test_2"]
  1573. }'
  1574. ```
  1575. ##### Request Parameters
  1576. - `chat_id`: (*Path parameter*)
  1577. The ID of the associated chat assistant.
  1578. - `"ids"`: (*Body Parameter*), `list[string]`
  1579. The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
  1580. #### Response
  1581. Success:
  1582. ```json
  1583. {
  1584. "code": 0
  1585. }
  1586. ```
  1587. Failure:
  1588. ```json
  1589. {
  1590. "code": 102,
  1591. "message": "The chat doesn't own the session"
  1592. }
  1593. ```
  1594. ---
  1595. ### Converse with chat assistant
  1596. **POST** `/api/v1/chats/{chat_id}/completions`
  1597. Asks a specified chat assistant a question to start an AI-powered conversation.
  1598. :::tip NOTE
  1599. - In streaming mode, not all responses include a reference, as this depends on the system's judgement.
  1600. - In streaming mode, the last message is an empty message:
  1601. ```json
  1602. data:
  1603. {
  1604. "code": 0,
  1605. "data": true
  1606. }
  1607. ```
  1608. :::
  1609. #### Request
  1610. - Method: POST
  1611. - URL: `/api/v1/chats/{chat_id}/completions`
  1612. - Headers:
  1613. - `'content-Type: application/json'`
  1614. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1615. - Body:
  1616. - `"question"`: `string`
  1617. - `"stream"`: `boolean`
  1618. - `"session_id"`: `string`
  1619. ##### Request example
  1620. ```bash
  1621. curl --request POST \
  1622. --url http://{address}/api/v1/chats/{chat_id}/completions \
  1623. --header 'Content-Type: application/json' \
  1624. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1625. --data-binary '
  1626. {
  1627. }'
  1628. ```
  1629. ```bash
  1630. curl --request POST \
  1631. --url http://{address}/api/v1/chats/{chat_id}/completions \
  1632. --header 'Content-Type: application/json' \
  1633. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1634. --data-binary '
  1635. {
  1636. "question": "Who are you",
  1637. "stream": true,
  1638. "session_id":"9fa7691cb85c11ef9c5f0242ac120005"
  1639. }'
  1640. ```
  1641. ##### Request Parameters
  1642. - `chat_id`: (*Path parameter*)
  1643. The ID of the associated chat assistant.
  1644. - `"question"`: (*Body Parameter*), `string`, *Required*
  1645. The question to start an AI-powered conversation.
  1646. - `"stream"`: (*Body Parameter*), `boolean`
  1647. Indicates whether to output responses in a streaming way:
  1648. - `true`: Enable streaming (default).
  1649. - `false`: Disable streaming.
  1650. - `"session_id"`: (*Body Parameter*)
  1651. The ID of session. If it is not provided, a new session will be generated.
  1652. #### Response
  1653. Success without `session_id`:
  1654. ```json
  1655. data:{
  1656. "code": 0,
  1657. "message": "",
  1658. "data": {
  1659. "answer": "Hi! I'm your assistant, what can I do for you?",
  1660. "reference": {},
  1661. "audio_binary": null,
  1662. "id": null,
  1663. "session_id": "b01eed84b85611efa0e90242ac120005"
  1664. }
  1665. }
  1666. data:{
  1667. "code": 0,
  1668. "message": "",
  1669. "data": true
  1670. }
  1671. ```
  1672. Success with `session_id`:
  1673. ```json
  1674. data:{
  1675. "code": 0,
  1676. "data": {
  1677. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a",
  1678. "reference": {},
  1679. "audio_binary": null,
  1680. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1681. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1682. }
  1683. }
  1684. data:{
  1685. "code": 0,
  1686. "data": {
  1687. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base. My responses are based on the information available in the knowledge base and",
  1688. "reference": {},
  1689. "audio_binary": null,
  1690. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1691. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1692. }
  1693. }
  1694. data:{
  1695. "code": 0,
  1696. "data": {
  1697. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base. My responses are based on the information available in the knowledge base and any relevant chat history.",
  1698. "reference": {},
  1699. "audio_binary": null,
  1700. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1701. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1702. }
  1703. }
  1704. data:{
  1705. "code": 0,
  1706. "data": {
  1707. "answer": "I am an intelligent assistant designed to help answer questions by summarizing content from a knowledge base ##0$$. My responses are based on the information available in the knowledge base and any relevant chat history.",
  1708. "reference": {
  1709. "total": 1,
  1710. "chunks": [
  1711. {
  1712. "id": "faf26c791128f2d5e821f822671063bd",
  1713. "content": "xxxxxxxx",
  1714. "document_id": "dd58f58e888511ef89c90242ac120006",
  1715. "document_name": "1.txt",
  1716. "dataset_id": "8e83e57a884611ef9d760242ac120006",
  1717. "image_id": "",
  1718. "similarity": 0.7,
  1719. "vector_similarity": 0.0,
  1720. "term_similarity": 1.0,
  1721. "positions": [
  1722. ""
  1723. ]
  1724. }
  1725. ],
  1726. "doc_aggs": [
  1727. {
  1728. "doc_name": "1.txt",
  1729. "doc_id": "dd58f58e888511ef89c90242ac120006",
  1730. "count": 1
  1731. }
  1732. ]
  1733. },
  1734. "prompt": "xxxxxxxxxxx",
  1735. "id": "a84c5dd4-97b4-4624-8c3b-974012c8000d",
  1736. "session_id": "82b0ab2a9c1911ef9d870242ac120006"
  1737. }
  1738. }
  1739. data:{
  1740. "code": 0,
  1741. "data": true
  1742. }
  1743. ```
  1744. Failure:
  1745. ```json
  1746. {
  1747. "code": 102,
  1748. "message": "Please input your question."
  1749. }
  1750. ```
  1751. ---
  1752. ### Create session with agent
  1753. **POST** `/api/v1/agents/{agent_id}/sessions`
  1754. Creates a session with an agent.
  1755. #### Request
  1756. - Method: POST
  1757. - URL: `/api/v1/agents/{agent_id}/sessions`
  1758. - Headers:
  1759. - `'content-Type: application/json'`
  1760. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1761. - Body:
  1762. ##### Request example
  1763. ```bash
  1764. curl --request POST \
  1765. --url http://{address}/api/v1/agents/{agent_id}/sessions \
  1766. --header 'Content-Type: application/json' \
  1767. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1768. --data '{
  1769. }'
  1770. ```
  1771. ##### Request parameters
  1772. - `agent_id`: (*Path parameter*)
  1773. The ID of the associated agent.
  1774. #### Response
  1775. Success:
  1776. ```json
  1777. {
  1778. "code": 0,
  1779. "data": {
  1780. "agent_id": "b4a39922b76611efaa1a0242ac120006",
  1781. "dsl": {
  1782. "answer": [],
  1783. "components": {
  1784. "Answer:GreenReadersDrum": {
  1785. "downstream": [],
  1786. "obj": {
  1787. "component_name": "Answer",
  1788. "inputs": [],
  1789. "output": null,
  1790. "params": {}
  1791. },
  1792. "upstream": []
  1793. },
  1794. "begin": {
  1795. "downstream": [],
  1796. "obj": {
  1797. "component_name": "Begin",
  1798. "inputs": [],
  1799. "output": {},
  1800. "params": {}
  1801. },
  1802. "upstream": []
  1803. }
  1804. },
  1805. "embed_id": "",
  1806. "graph": {
  1807. "edges": [],
  1808. "nodes": [
  1809. {
  1810. "data": {
  1811. "label": "Begin",
  1812. "name": "begin"
  1813. },
  1814. "dragging": false,
  1815. "height": 44,
  1816. "id": "begin",
  1817. "position": {
  1818. "x": 53.25688640427177,
  1819. "y": 198.37155679786412
  1820. },
  1821. "positionAbsolute": {
  1822. "x": 53.25688640427177,
  1823. "y": 198.37155679786412
  1824. },
  1825. "selected": false,
  1826. "sourcePosition": "left",
  1827. "targetPosition": "right",
  1828. "type": "beginNode",
  1829. "width": 200
  1830. },
  1831. {
  1832. "data": {
  1833. "form": {},
  1834. "label": "Answer",
  1835. "name": "dialog_0"
  1836. },
  1837. "dragging": false,
  1838. "height": 44,
  1839. "id": "Answer:GreenReadersDrum",
  1840. "position": {
  1841. "x": 360.43473114516974,
  1842. "y": 207.29298425089348
  1843. },
  1844. "positionAbsolute": {
  1845. "x": 360.43473114516974,
  1846. "y": 207.29298425089348
  1847. },
  1848. "selected": false,
  1849. "sourcePosition": "right",
  1850. "targetPosition": "left",
  1851. "type": "logicNode",
  1852. "width": 200
  1853. }
  1854. ]
  1855. },
  1856. "history": [],
  1857. "messages": [],
  1858. "path": [
  1859. [
  1860. "begin"
  1861. ],
  1862. []
  1863. ],
  1864. "reference": []
  1865. },
  1866. "id": "2581031eb7a311efb5200242ac120005",
  1867. "message": [
  1868. {
  1869. "content": "Hi! I'm your smart assistant. What can I do for you?",
  1870. "role": "assistant"
  1871. }
  1872. ],
  1873. "source": "agent",
  1874. "user_id": "69736c5e723611efb51b0242ac120007"
  1875. }
  1876. }
  1877. ```
  1878. Failure:
  1879. ```json
  1880. {
  1881. "code": 102,
  1882. "message": "Agent not found."
  1883. }
  1884. ```
  1885. ---
  1886. ### Converse with agent
  1887. **POST** `/api/v1/agents/{agent_id}/completions`
  1888. Asks a specified agent a question to start an AI-powered conversation.
  1889. :::tip NOTE
  1890. - In streaming mode, not all responses include a reference, as this depends on the system's judgement.
  1891. - In streaming mode, the last message is an empty message:
  1892. ```json
  1893. data:
  1894. {
  1895. "code": 0,
  1896. "data": true
  1897. }
  1898. ```
  1899. :::
  1900. #### Request
  1901. - Method: POST
  1902. - URL: `/api/v1/agents/{agent_id}/completions`
  1903. - Headers:
  1904. - `'content-Type: application/json'`
  1905. - `'Authorization: Bearer <YOUR_API_KEY>'`
  1906. - Body:
  1907. - `"question"`: `string`
  1908. - `"stream"`: `boolean`
  1909. - `"session_id"`: `string`
  1910. - other parameters: `string`
  1911. ##### Request example
  1912. ```bash
  1913. curl --request POST \
  1914. --url http://{address}/api/v1/agents/{agent_id}/completions \
  1915. --header 'Content-Type: application/json' \
  1916. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1917. --data-binary '
  1918. {
  1919. }'
  1920. ```
  1921. ```bash
  1922. curl --request POST \
  1923. --url http://{address}/api/v1/agents/{agent_id}/completions \
  1924. --header 'Content-Type: application/json' \
  1925. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1926. --data-binary '
  1927. {
  1928. "question": "Hello",
  1929. "stream": true,
  1930. "session_id": "cb2f385cb86211efa36e0242ac120005"
  1931. }'
  1932. ```
  1933. ```bash
  1934. curl --request POST \
  1935. --url http://{address}/api/v1/agents/{agent_id}/completions \
  1936. --header 'Content-Type: application/json' \
  1937. --header 'Authorization: Bearer <YOUR_API_KEY>' \
  1938. --data-binary '
  1939. {
  1940. "lang":"English"
  1941. "file":"How is the weather tomorrow?"
  1942. }'
  1943. ```
  1944. ##### Request Parameters
  1945. - `agent_id`: (*Path parameter*), `string`
  1946. The ID of the associated agent.
  1947. - `"question"`: (*Body Parameter*), `string`, *Required*
  1948. The question to start an AI-powered conversation.
  1949. - `"stream"`: (*Body Parameter*), `boolean`
  1950. Indicates whether to output responses in a streaming way:
  1951. - `true`: Enable streaming (default).
  1952. - `false`: Disable streaming.
  1953. - `"session_id"`: (*Body Parameter*)
  1954. The ID of the session. If it is not provided, a new session will be generated.
  1955. - Other parameters: (*Body Parameter*)
  1956. The parameters in the begin component.
  1957. #### Response
  1958. success without `session_id` provided and with no parameters in the `begin` component:
  1959. ```json
  1960. data:{
  1961. "code": 0,
  1962. "message": "",
  1963. "data": {
  1964. "answer": "Hi! I'm your smart assistant. What can I do for you?",
  1965. "reference": {},
  1966. "id": "31e6091d-88d4-441b-ac65-eae1c055be7b",
  1967. "session_id": "2987ad3eb85f11efb2a70242ac120005"
  1968. }
  1969. }
  1970. data:{
  1971. "code": 0,
  1972. "message": "",
  1973. "data": true
  1974. }
  1975. ```
  1976. Success with `session_id` provided and with no parameters in the `begin` component:
  1977. ```json
  1978. data:{
  1979. "code": 0,
  1980. "message": "",
  1981. "data": {
  1982. "answer": "",
  1983. "reference": [],
  1984. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  1985. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  1986. }
  1987. }
  1988. data:{
  1989. "code": 0,
  1990. "data": {
  1991. "answer": "Hello",
  1992. "reference": [],
  1993. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  1994. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  1995. }
  1996. }
  1997. data:{
  1998. "code": 0,
  1999. "data": {
  2000. "answer": "Hello!",
  2001. "reference": [],
  2002. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2003. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2004. }
  2005. }
  2006. data:{
  2007. "code": 0,
  2008. "data": {
  2009. "answer": "Hello! How",
  2010. "reference": [],
  2011. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2012. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2013. }
  2014. }
  2015. data:{
  2016. "code": 0,
  2017. "data": {
  2018. "answer": "Hello! How can",
  2019. "reference": [],
  2020. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2021. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2022. }
  2023. }
  2024. data:{
  2025. "code": 0,
  2026. "data": {
  2027. "answer": "Hello! How can I",
  2028. "reference": [],
  2029. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2030. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2031. }
  2032. }
  2033. data:{
  2034. "code": 0,
  2035. "data": {
  2036. "answer": "Hello! How can I assist",
  2037. "reference": [],
  2038. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2039. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2040. }
  2041. }
  2042. data:{
  2043. "code": 0,
  2044. "data": {
  2045. "answer": "Hello! How can I assist you",
  2046. "reference": [],
  2047. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2048. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2049. }
  2050. }
  2051. data:{
  2052. "code": 0,
  2053. "data": {
  2054. "answer": "Hello! How can I assist you today",
  2055. "reference": [],
  2056. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2057. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2058. }
  2059. }
  2060. data:{
  2061. "code": 0,
  2062. "data": {
  2063. "answer": "Hello! How can I assist you today?",
  2064. "reference": [],
  2065. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2066. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2067. }
  2068. }
  2069. data:{
  2070. "code": 0,
  2071. "data": {
  2072. "answer": "Hello! How can I assist you today?",
  2073. "reference": [],
  2074. "id": "7ed5c2e4-aa28-4397-bbed-59664a332aa0",
  2075. "session_id": "ce1b4fa89c1811ef85720242ac120006"
  2076. }
  2077. }
  2078. data:{
  2079. "code": 0,
  2080. "data": true
  2081. }
  2082. ```
  2083. Success with parameters in the `begin` component:
  2084. ```json
  2085. data:{
  2086. "code": 0,
  2087. "message": "",
  2088. "data": {
  2089. "answer": "How",
  2090. "reference": {},
  2091. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2092. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2093. }
  2094. }
  2095. data:{
  2096. "code": 0,
  2097. "message": "",
  2098. "data": {
  2099. "answer": "How is",
  2100. "reference": {},
  2101. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2102. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2103. }
  2104. }
  2105. data:{
  2106. "code": 0,
  2107. "message": "",
  2108. "data": {
  2109. "answer": "How is the",
  2110. "reference": {},
  2111. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2112. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2113. }
  2114. }
  2115. data:{
  2116. "code": 0,
  2117. "message": "",
  2118. "data": {
  2119. "answer": "How is the weather",
  2120. "reference": {},
  2121. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2122. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2123. }
  2124. }
  2125. data:{
  2126. "code": 0,
  2127. "message": "",
  2128. "data": {
  2129. "answer": "How is the weather tomorrow",
  2130. "reference": {},
  2131. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2132. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2133. }
  2134. }
  2135. data:{
  2136. "code": 0,
  2137. "message": "",
  2138. "data": {
  2139. "answer": "How is the weather tomorrow?",
  2140. "reference": {},
  2141. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2142. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2143. }
  2144. }
  2145. data:{
  2146. "code": 0,
  2147. "message": "",
  2148. "data": {
  2149. "answer": "How is the weather tomorrow?",
  2150. "reference": {},
  2151. "id": "0379ac4c-b26b-4a44-8b77-99cebf313fdf",
  2152. "session_id": "4399c7d0b86311efac5b0242ac120005"
  2153. }
  2154. }
  2155. data:{
  2156. "code": 0,
  2157. "message": "",
  2158. "data": true
  2159. }
  2160. ```
  2161. Failure:
  2162. ```json
  2163. {
  2164. "code": 102,
  2165. "message": "`question` is required."
  2166. }
  2167. ```
  2168. ---
  2169. ### List agent sessions
  2170. **GET** `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
  2171. Lists sessions associated with a specified agent.
  2172. #### Request
  2173. - Method: GET
  2174. - URL: `/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}`
  2175. - Headers:
  2176. - `'Authorization: Bearer <YOUR_API_KEY>'`
  2177. ##### Request example
  2178. ```bash
  2179. curl --request GET \
  2180. --url http://{address}/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id} \
  2181. --header 'Authorization: Bearer <YOUR_API_KEY>'
  2182. ```
  2183. ##### Request Parameters
  2184. - `agent_id`: (*Path parameter*)
  2185. The ID of the associated agent.
  2186. - `page`: (*Filter parameter*), `integer`
  2187. Specifies the page on which the sessions will be displayed. Defaults to `1`.
  2188. - `page_size`: (*Filter parameter*), `integer`
  2189. The number of sessions on each page. Defaults to `30`.
  2190. - `orderby`: (*Filter parameter*), `string`
  2191. The field by which sessions should be sorted. Available options:
  2192. - `create_time` (default)
  2193. - `update_time`
  2194. - `desc`: (*Filter parameter*), `boolean`
  2195. Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
  2196. - `id`: (*Filter parameter*), `string`
  2197. The ID of the agent session to retrieve.
  2198. #### Response
  2199. Success:
  2200. ```json
  2201. {
  2202. "code": 0,
  2203. "data": {
  2204. "agent_id": "e9e2b9c2b2f911ef801d0242ac120006",
  2205. "dsl": {
  2206. "answer": [],
  2207. "components": {
  2208. "Answer:OrangeTermsBurn": {
  2209. "downstream": [],
  2210. "obj": {
  2211. "component_name": "Answer",
  2212. "params": {}
  2213. },
  2214. "upstream": []
  2215. },
  2216. "Generate:SocialYearsRemain": {
  2217. "downstream": [],
  2218. "obj": {
  2219. "component_name": "Generate",
  2220. "params": {
  2221. "cite": true,
  2222. "frequency_penalty": 0.7,
  2223. "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
  2224. "max_tokens": 256,
  2225. "message_history_window_size": 12,
  2226. "parameters": [],
  2227. "presence_penalty": 0.4,
  2228. "prompt": "Please summarize the following paragraph. Pay attention to the numbers and do not make things up. The paragraph is as follows:\n{input}\nThis is what you need to summarize.",
  2229. "temperature": 0.1,
  2230. "top_p": 0.3
  2231. }
  2232. },
  2233. "upstream": []
  2234. },
  2235. "begin": {
  2236. "downstream": [],
  2237. "obj": {
  2238. "component_name": "Begin",
  2239. "params": {}
  2240. },
  2241. "upstream": []
  2242. }
  2243. },
  2244. "graph": {
  2245. "edges": [],
  2246. "nodes": [
  2247. {
  2248. "data": {
  2249. "label": "Begin",
  2250. "name": "begin"
  2251. },
  2252. "height": 44,
  2253. "id": "begin",
  2254. "position": {
  2255. "x": 50,
  2256. "y": 200
  2257. },
  2258. "sourcePosition": "left",
  2259. "targetPosition": "right",
  2260. "type": "beginNode",
  2261. "width": 200
  2262. },
  2263. {
  2264. "data": {
  2265. "form": {
  2266. "cite": true,
  2267. "frequencyPenaltyEnabled": true,
  2268. "frequency_penalty": 0.7,
  2269. "llm_id": "gpt-4o___OpenAI-API@OpenAI-API-Compatible",
  2270. "maxTokensEnabled": true,
  2271. "max_tokens": 256,
  2272. "message_history_window_size": 12,
  2273. "parameters": [],
  2274. "presencePenaltyEnabled": true,
  2275. "presence_penalty": 0.4,
  2276. "prompt": "Please summarize the following paragraph. Pay attention to the numbers and do not make things up. The paragraph is as follows:\n{input}\nThis is what you need to summarize.",
  2277. "temperature": 0.1,
  2278. "temperatureEnabled": true,
  2279. "topPEnabled": true,
  2280. "top_p": 0.3
  2281. },
  2282. "label": "Generate",
  2283. "name": "Generate Answer_0"
  2284. },
  2285. "dragging": false,
  2286. "height": 105,
  2287. "id": "Generate:SocialYearsRemain",
  2288. "position": {
  2289. "x": 561.3457829707513,
  2290. "y": 178.7211182312641
  2291. },
  2292. "positionAbsolute": {
  2293. "x": 561.3457829707513,
  2294. "y": 178.7211182312641
  2295. },
  2296. "selected": true,
  2297. "sourcePosition": "right",
  2298. "targetPosition": "left",
  2299. "type": "generateNode",
  2300. "width": 200
  2301. },
  2302. {
  2303. "data": {
  2304. "form": {},
  2305. "label": "Answer",
  2306. "name": "Dialogue_0"
  2307. },
  2308. "height": 44,
  2309. "id": "Answer:OrangeTermsBurn",
  2310. "position": {
  2311. "x": 317.2368194777658,
  2312. "y": 218.30635555445093
  2313. },
  2314. "sourcePosition": "right",
  2315. "targetPosition": "left",
  2316. "type": "logicNode",
  2317. "width": 200
  2318. }
  2319. ]
  2320. },
  2321. "history": [],
  2322. "messages": [],
  2323. "path": [],
  2324. "reference": []
  2325. },
  2326. "id": "792dde22b2fa11ef97550242ac120006",
  2327. "message": [
  2328. {
  2329. "content": "Hi! I'm your smart assistant. What can I do for you?",
  2330. "role": "assistant"
  2331. }
  2332. ],
  2333. "source": "agent",
  2334. "user_id": ""
  2335. }
  2336. }
  2337. ```
  2338. Failure:
  2339. ```json
  2340. {
  2341. "code": 102,
  2342. "message": "You don't own the agent ccd2f856b12311ef94ca0242ac1200052."
  2343. }
  2344. ```
  2345. ---
  2346. ## AGENT MANAGEMENT
  2347. ---
  2348. ### List agents
  2349. **GET** `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
  2350. Lists agents.
  2351. #### Request
  2352. - Method: GET
  2353. - URL: `/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}`
  2354. - Headers:
  2355. - `'Authorization: Bearer <YOUR_API_KEY>'`
  2356. ##### Request example
  2357. ```bash
  2358. curl --request GET \
  2359. --url http://{address}/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id} \
  2360. --header 'Authorization: Bearer <YOUR_API_KEY>'
  2361. ```
  2362. ##### Request parameters
  2363. - `page`: (*Filter parameter*), `integer`
  2364. Specifies the page on which the agents will be displayed. Defaults to `1`.
  2365. - `page_size`: (*Filter parameter*), `integer`
  2366. The number of agents on each page. Defaults to `30`.
  2367. - `orderby`: (*Filter parameter*), `string`
  2368. The attribute by which the results are sorted. Available options:
  2369. - `create_time` (default)
  2370. - `update_time`
  2371. - `desc`: (*Filter parameter*), `boolean`
  2372. Indicates whether the retrieved agents should be sorted in descending order. Defaults to `true`.
  2373. - `id`: (*Filter parameter*), `string`
  2374. The ID of the agent to retrieve.
  2375. - `name`: (*Filter parameter*), `string`
  2376. The name of the agent to retrieve.
  2377. #### Response
  2378. Success:
  2379. ```json
  2380. {
  2381. "code": 0,
  2382. "data": [
  2383. {
  2384. "avatar": null,
  2385. "canvas_type": null,
  2386. "create_date": "Thu, 05 Dec 2024 19:10:36 GMT",
  2387. "create_time": 1733397036424,
  2388. "description": null,
  2389. "dsl": {
  2390. "answer": [],
  2391. "components": {
  2392. "begin": {
  2393. "downstream": [],
  2394. "obj": {
  2395. "component_name": "Begin",
  2396. "params": {}
  2397. },
  2398. "upstream": []
  2399. }
  2400. },
  2401. "graph": {
  2402. "edges": [],
  2403. "nodes": [
  2404. {
  2405. "data": {
  2406. "label": "Begin",
  2407. "name": "begin"
  2408. },
  2409. "height": 44,
  2410. "id": "begin",
  2411. "position": {
  2412. "x": 50,
  2413. "y": 200
  2414. },
  2415. "sourcePosition": "left",
  2416. "targetPosition": "right",
  2417. "type": "beginNode",
  2418. "width": 200
  2419. }
  2420. ]
  2421. },
  2422. "history": [],
  2423. "messages": [],
  2424. "path": [],
  2425. "reference": []
  2426. },
  2427. "id": "8d9ca0e2b2f911ef9ca20242ac120006",
  2428. "title": "123465",
  2429. "update_date": "Thu, 05 Dec 2024 19:10:56 GMT",
  2430. "update_time": 1733397056801,
  2431. "user_id": "69736c5e723611efb51b0242ac120007"
  2432. }
  2433. ]
  2434. }
  2435. ```
  2436. Failure:
  2437. ```json
  2438. {
  2439. "code": 102,
  2440. "message": "The agent doesn't exist."
  2441. }
  2442. ```
  2443. ---