balibabu commited on
Commit
e8a6715
·
1 Parent(s): 2343334

feat: Delete http_api_reference.md from api folder #1102 (#3121)

Browse files

### What problem does this PR solve?

feat: Delete http_api_reference.md from api folder #1102

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Dockerfile CHANGED
@@ -48,7 +48,7 @@ RUN --mount=type=cache,id=ragflow_builder_apt,target=/var/cache/apt,sharing=lock
48
  rm -rf /var/lib/apt/lists/*
49
 
50
  COPY web web
51
- COPY api api
52
  RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
53
  cd web && npm i --force && npm run build
54
 
 
48
  rm -rf /var/lib/apt/lists/*
49
 
50
  COPY web web
51
+ COPY docs docs
52
  RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
53
  cd web && npm i --force && npm run build
54
 
Dockerfile.scratch.oc9 CHANGED
@@ -26,6 +26,7 @@ RUN dnf install -y nginx
26
 
27
  ADD ./web ./web
28
  ADD ./api ./api
 
29
  ADD ./conf ./conf
30
  ADD ./deepdoc ./deepdoc
31
  ADD ./rag ./rag
@@ -37,7 +38,7 @@ RUN dnf install -y openmpi openmpi-devel python3-openmpi
37
  ENV C_INCLUDE_PATH /usr/include/openmpi-x86_64:$C_INCLUDE_PATH
38
  ENV LD_LIBRARY_PATH /usr/lib64/openmpi/lib:$LD_LIBRARY_PATH
39
  RUN rm /root/miniconda3/envs/py11/compiler_compat/ld
40
- RUN cd ./web && npm i --force && npm run build
41
  RUN conda run -n py11 pip install $(grep -ivE "mpi4py" ./requirements.txt) # without mpi4py==3.1.5
42
  RUN conda run -n py11 pip install redis
43
 
 
26
 
27
  ADD ./web ./web
28
  ADD ./api ./api
29
+ ADD ./docs ./docs
30
  ADD ./conf ./conf
31
  ADD ./deepdoc ./deepdoc
32
  ADD ./rag ./rag
 
38
  ENV C_INCLUDE_PATH /usr/include/openmpi-x86_64:$C_INCLUDE_PATH
39
  ENV LD_LIBRARY_PATH /usr/lib64/openmpi/lib:$LD_LIBRARY_PATH
40
  RUN rm /root/miniconda3/envs/py11/compiler_compat/ld
41
+ RUN cd ./web && npm i && npm run build
42
  RUN conda run -n py11 pip install $(grep -ivE "mpi4py" ./requirements.txt) # without mpi4py==3.1.5
43
  RUN conda run -n py11 pip install redis
44
 
Dockerfile.slim CHANGED
@@ -47,9 +47,9 @@ RUN --mount=type=cache,id=ragflow_builder_apt,target=/var/cache/apt,sharing=lock
47
  rm -rf /var/lib/apt/lists/*
48
 
49
  COPY web web
50
- COPY api api
51
  RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
52
- cd web && npm i --force && npm run build
53
 
54
  # install dependencies from poetry.lock file
55
  COPY pyproject.toml poetry.toml poetry.lock ./
 
47
  rm -rf /var/lib/apt/lists/*
48
 
49
  COPY web web
50
+ COPY docs docs
51
  RUN --mount=type=cache,id=ragflow_builder_npm,target=/root/.npm,sharing=locked \
52
+ cd web && npm i && npm run build
53
 
54
  # install dependencies from poetry.lock file
55
  COPY pyproject.toml poetry.toml poetry.lock ./
api/http_api_reference.md DELETED
@@ -1,2107 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- slug: /http_api_reference
4
- ---
5
-
6
- # HTTP API Reference
7
-
8
- This document provides a complete reference for RAGFlow's RESTful API. Before proceeding, please ensure you [have your RAGFlow API key ready for authentication](../guides/develop/acquire_ragflow_api_key.md).
9
-
10
- ---
11
-
12
- :::tip API GROUPING
13
- Dataset Management
14
- :::
15
-
16
- ---
17
-
18
- ## Create dataset
19
-
20
- **POST** `/api/v1/datasets`
21
-
22
- Creates a dataset.
23
-
24
- ### Request
25
-
26
- - Method: POST
27
- - URL: `/api/v1/datasets`
28
- - Headers:
29
- - `'content-Type: application/json'`
30
- - `'Authorization: Bearer {YOUR_API_KEY}'`
31
- - Body:
32
- - `"name"`: `string`
33
- - `"avatar"`: `string`
34
- - `"description"`: `string`
35
- - `"language"`: `string`
36
- - `"embedding_model"`: `string`
37
- - `"permission"`: `string`
38
- - `"chunk_method"`: `string`
39
- - `"parser_config"`: `object`
40
-
41
- #### Request example
42
-
43
- ```bash
44
- curl --request POST \
45
- --url http://{address}/api/v1/datasets \
46
- --header 'Content-Type: application/json' \
47
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
48
- --data '{
49
- "name": "test_1"
50
- }'
51
- ```
52
-
53
- #### Request parameters
54
-
55
- - `"name"`: (*Body parameter*), `string`, *Required*
56
- The unique name of the dataset to create. It must adhere to the following requirements:
57
- - Permitted characters include:
58
- - English letters (a-z, A-Z)
59
- - Digits (0-9)
60
- - "_" (underscore)
61
- - Must begin with an English letter or underscore.
62
- - Maximum 65,535 characters.
63
- - Case-insensitive.
64
-
65
- - `"avatar"`: (*Body parameter*), `string`
66
- Base64 encoding of the avatar.
67
-
68
- - `"description"`: (*Body parameter*), `string`
69
- A brief description of the dataset to create.
70
-
71
- - `"language"`: (*Body parameter*), `string`
72
- The language setting of the dataset to create. Available options:
73
- - `"English"` (Default)
74
- - `"Chinese"`
75
-
76
- - `"embedding_model"`: (*Body parameter*), `string`
77
- The name of the embedding model to use. For example: `"BAAI/bge-zh-v1.5"`
78
-
79
- - `"permission"`: (*Body parameter*), `string`
80
- Specifies who can access the dataset to create. You can set it only to `"me"` for now.
81
-
82
- - `"chunk_method"`: (*Body parameter*), `enum<string>`
83
- The chunking method of the dataset to create. Available options:
84
- - `"naive"`: General (default)
85
- - `"manual"`: Manual
86
- - `"qa"`: Q&A
87
- - `"table"`: Table
88
- - `"paper"`: Paper
89
- - `"book"`: Book
90
- - `"laws"`: Laws
91
- - `"presentation"`: Presentation
92
- - `"picture"`: Picture
93
- - `"one"`: One
94
- - `"knowledge_graph"`: Knowledge Graph
95
- - `"email"`: Email
96
-
97
- - `"parser_config"`: (*Body parameter*), `object`
98
- The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
99
- - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
100
- - `"chunk_token_count"`: Defaults to `128`.
101
- - `"layout_recognize"`: Defaults to `true`.
102
- - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
103
- - `"delimiter"`: Defaults to `"\n!?。;!?"`.
104
- - `"task_page_size"`: Defaults to `12`. For PDF only.
105
- - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
106
- - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
107
- - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
108
- - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
109
- - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
110
- - `"chunk_token_count"`: Defaults to `128`.
111
- - `"delimiter"`: Defaults to `"\n!?。;!?"`.
112
- - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
113
-
114
- ### Response
115
-
116
- Success:
117
-
118
- ```json
119
- {
120
- "code": 0,
121
- "data": {
122
- "avatar": null,
123
- "chunk_count": 0,
124
- "chunk_method": "naive",
125
- "create_date": "Thu, 24 Oct 2024 09:14:07 GMT",
126
- "create_time": 1729761247434,
127
- "created_by": "69736c5e723611efb51b0242ac120007",
128
- "description": null,
129
- "document_count": 0,
130
- "embedding_model": "BAAI/bge-large-zh-v1.5",
131
- "id": "527fa74891e811ef9c650242ac120006",
132
- "language": "English",
133
- "name": "test_1",
134
- "parser_config": {
135
- "chunk_token_num": 128,
136
- "delimiter": "\\n!?;。;!?",
137
- "html4excel": false,
138
- "layout_recognize": true,
139
- "raptor": {
140
- "user_raptor": false
141
- }
142
- },
143
- "permission": "me",
144
- "similarity_threshold": 0.2,
145
- "status": "1",
146
- "tenant_id": "69736c5e723611efb51b0242ac120007",
147
- "token_num": 0,
148
- "update_date": "Thu, 24 Oct 2024 09:14:07 GMT",
149
- "update_time": 1729761247434,
150
- "vector_similarity_weight": 0.3
151
- }
152
- }
153
- ```
154
-
155
- Failure:
156
-
157
- ```json
158
- {
159
- "code": 102,
160
- "message": "Duplicated knowledgebase name in creating dataset."
161
- }
162
- ```
163
-
164
- ---
165
-
166
- ## Delete datasets
167
-
168
- **DELETE** `/api/v1/datasets`
169
-
170
- Deletes datasets by ID.
171
-
172
- ### Request
173
-
174
- - Method: DELETE
175
- - URL: `/api/v1/datasets`
176
- - Headers:
177
- - `'content-Type: application/json'`
178
- - `'Authorization: Bearer {YOUR_API_KEY}'`
179
- - Body:
180
- - `"ids"`: `list[string]`
181
-
182
- #### Request example
183
-
184
- ```bash
185
- curl --request DELETE \
186
- --url http://{address}/api/v1/datasets \
187
- --header 'Content-Type: application/json' \
188
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
189
- --data '{"ids": ["test_1", "test_2"]}'
190
- ```
191
-
192
- #### Request parameters
193
-
194
- - `"ids"`: (*Body parameter*), `list[string]`
195
- The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
196
-
197
- ### Response
198
-
199
- Success:
200
-
201
- ```json
202
- {
203
- "code": 0
204
- }
205
- ```
206
-
207
- Failure:
208
-
209
- ```json
210
- {
211
- "code": 102,
212
- "message": "You don't own the dataset."
213
- }
214
- ```
215
-
216
- ---
217
-
218
- ## Update dataset
219
-
220
- **PUT** `/api/v1/datasets/{dataset_id}`
221
-
222
- Updates configurations for a specified dataset.
223
-
224
- ### Request
225
-
226
- - Method: PUT
227
- - URL: `/api/v1/datasets/{dataset_id}`
228
- - Headers:
229
- - `'content-Type: application/json'`
230
- - `'Authorization: Bearer {YOUR_API_KEY}'`
231
- - Body:
232
- - `"name"`: `string`
233
- - `"embedding_model"`: `string`
234
- - `"chunk_method"`: `enum<string>`
235
-
236
- #### Request example
237
-
238
- ```bash
239
- curl --request PUT \
240
- --url http://{address}/api/v1/datasets/{dataset_id} \
241
- --header 'Content-Type: application/json' \
242
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
243
- --data '
244
- {
245
- "name": "updated_dataset",
246
- }'
247
- ```
248
-
249
- #### Request parameters
250
-
251
- - `dataset_id`: (*Path parameter*)
252
- The ID of the dataset to update.
253
- - `"name"`: (*Body parameter*), `string`
254
- The revised name of the dataset.
255
- - `"embedding_model"`: (*Body parameter*), `string`
256
- The updated embedding model name.
257
- - Ensure that `"chunk_count"` is `0` before updating `"embedding_model"`.
258
- - `"chunk_method"`: (*Body parameter*), `enum<string>`
259
- The chunking method for the dataset. Available options:
260
- - `"naive"`: General
261
- - `"manual`: Manual
262
- - `"qa"`: Q&A
263
- - `"table"`: Table
264
- - `"paper"`: Paper
265
- - `"book"`: Book
266
- - `"laws"`: Laws
267
- - `"presentation"`: Presentation
268
- - `"picture"`: Picture
269
- - `"one"`:One
270
- - `"knowledge_graph"`: Knowledge Graph
271
-
272
- ### Response
273
-
274
- Success:
275
-
276
- ```json
277
- {
278
- "code": 0
279
- }
280
- ```
281
-
282
- Failure:
283
-
284
- ```json
285
- {
286
- "code": 102,
287
- "message": "Can't change tenant_id."
288
- }
289
- ```
290
-
291
- ---
292
-
293
- ## List datasets
294
-
295
- **GET** `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
296
-
297
- Lists datasets.
298
-
299
- ### Request
300
-
301
- - Method: GET
302
- - URL: `/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
303
- - Headers:
304
- - `'Authorization: Bearer {YOUR_API_KEY}'`
305
-
306
- #### Request example
307
-
308
- ```bash
309
- curl --request GET \
310
- --url http://{address}/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
311
- --header 'Authorization: Bearer {YOUR_API_KEY}'
312
- ```
313
-
314
- #### Request parameters
315
-
316
- - `page`: (*Filter parameter*)
317
- Specifies the page on which the datasets will be displayed. Defaults to `1`.
318
- - `page_size`: (*Filter parameter*)
319
- The number of datasets on each page. Defaults to `1024`.
320
- - `orderby`: (*Filter parameter*)
321
- The field by which datasets should be sorted. Available options:
322
- - `create_time` (default)
323
- - `update_time`
324
- - `desc`: (*Filter parameter*)
325
- Indicates whether the retrieved datasets should be sorted in descending order. Defaults to `true`.
326
- - `name`: (*Filter parameter*)
327
- The name of the dataset to retrieve.
328
- - `id`: (*Filter parameter*)
329
- The ID of the dataset to retrieve.
330
-
331
- ### Response
332
-
333
- Success:
334
-
335
- ```json
336
- {
337
- "code": 0,
338
- "data": [
339
- {
340
- "avatar": "",
341
- "chunk_count": 59,
342
- "create_date": "Sat, 14 Sep 2024 01:12:37 GMT",
343
- "create_time": 1726276357324,
344
- "created_by": "69736c5e723611efb51b0242ac120007",
345
- "description": null,
346
- "document_count": 1,
347
- "embedding_model": "BAAI/bge-large-zh-v1.5",
348
- "id": "6e211ee0723611efa10a0242ac120007",
349
- "language": "English",
350
- "name": "mysql",
351
- "chunk_method": "knowledge_graph",
352
- "parser_config": {
353
- "chunk_token_num": 8192,
354
- "delimiter": "\\n!?;。;!?",
355
- "entity_types": [
356
- "organization",
357
- "person",
358
- "location",
359
- "event",
360
- "time"
361
- ]
362
- },
363
- "permission": "me",
364
- "similarity_threshold": 0.2,
365
- "status": "1",
366
- "tenant_id": "69736c5e723611efb51b0242ac120007",
367
- "token_num": 12744,
368
- "update_date": "Thu, 10 Oct 2024 04:07:23 GMT",
369
- "update_time": 1728533243536,
370
- "vector_similarity_weight": 0.3
371
- }
372
- ]
373
- }
374
- ```
375
-
376
- Failure:
377
-
378
- ```json
379
- {
380
- "code": 102,
381
- "message": "The dataset doesn't exist"
382
- }
383
- ```
384
-
385
- ---
386
-
387
- :::tip API GROUPING
388
- File Management within Dataset
389
- :::
390
-
391
- ---
392
-
393
- ## Upload documents
394
-
395
- **POST** `/api/v1/datasets/{dataset_id}/documents`
396
-
397
- Uploads documents to a specified dataset.
398
-
399
- ### Request
400
-
401
- - Method: POST
402
- - URL: `/api/v1/datasets/{dataset_id}/documents`
403
- - Headers:
404
- - `'Content-Type: multipart/form-data'`
405
- - `'Authorization: Bearer {YOUR_API_KEY}'`
406
- - Form:
407
- - `'file=@{FILE_PATH}'`
408
-
409
- #### Request example
410
-
411
- ```bash
412
- curl --request POST \
413
- --url http://{address}/api/v1/datasets/{dataset_id}/documents \
414
- --header 'Content-Type: multipart/form-data' \
415
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
416
- --form 'file=@./test1.txt' \
417
- --form 'file=@./test2.pdf'
418
- ```
419
-
420
- #### Request parameters
421
-
422
- - `dataset_id`: (*Path parameter*)
423
- The ID of the dataset to which the documents will be uploaded.
424
- - `'file'`: (*Body parameter*)
425
- A document to upload.
426
-
427
- ### Response
428
-
429
- Success:
430
-
431
- ```json
432
- {
433
- "code": 0,
434
- "data": [
435
- {
436
- "chunk_method": "naive",
437
- "created_by": "69736c5e723611efb51b0242ac120007",
438
- "dataset_id": "527fa74891e811ef9c650242ac120006",
439
- "id": "b330ec2e91ec11efbc510242ac120004",
440
- "location": "1.txt",
441
- "name": "1.txt",
442
- "parser_config": {
443
- "chunk_token_num": 128,
444
- "delimiter": "\\n!?;。;!?",
445
- "html4excel": false,
446
- "layout_recognize": true,
447
- "raptor": {
448
- "user_raptor": false
449
- }
450
- },
451
- "run": "UNSTART",
452
- "size": 17966,
453
- "thumbnail": "",
454
- "type": "doc"
455
- }
456
- ]
457
- }
458
- ```
459
-
460
- Failure:
461
-
462
- ```json
463
- {
464
- "code": 101,
465
- "message": "No file part!"
466
- }
467
- ```
468
-
469
- ---
470
-
471
- ## Update document
472
-
473
- **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
474
-
475
- Updates configurations for a specified document.
476
-
477
- ### Request
478
-
479
- - Method: PUT
480
- - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
481
- - Headers:
482
- - `'content-Type: application/json'`
483
- - `'Authorization: Bearer {YOUR_API_KEY}'`
484
- - Body:
485
- - `"name"`:`string`
486
- - `"chunk_method"`:`string`
487
- - `"parser_config"`:`object`
488
-
489
- #### Request example
490
-
491
- ```bash
492
- curl --request PUT \
493
- --url http://{address}/api/v1/datasets/{dataset_id}/info/{document_id} \
494
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
495
- --header 'Content-Type: application/json' \
496
- --data '
497
- {
498
- "name": "manual.txt",
499
- "chunk_method": "manual",
500
- "parser_config": {"chunk_token_count": 128}
501
- }'
502
-
503
- ```
504
-
505
- #### Request parameters
506
-
507
- - `dataset_id`: (*Path parameter*)
508
- The ID of the associated dataset.
509
- - `document_id`: (*Path parameter*)
510
- The ID of the document to update.
511
- - `"name"`: (*Body parameter*), `string`
512
- - `"chunk_method"`: (*Body parameter*), `string`
513
- The parsing method to apply to the document:
514
- - `"naive"`: General
515
- - `"manual`: Manual
516
- - `"qa"`: Q&A
517
- - `"table"`: Table
518
- - `"paper"`: Paper
519
- - `"book"`: Book
520
- - `"laws"`: Laws
521
- - `"presentation"`: Presentation
522
- - `"picture"`: Picture
523
- - `"one"`: One
524
- - `"knowledge_graph"`: Knowledge Graph
525
- - `"email"`: Email
526
- - `"parser_config"`: (*Body parameter*), `object`
527
- The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
528
- - If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
529
- - `"chunk_token_count"`: Defaults to `128`.
530
- - `"layout_recognize"`: Defaults to `true`.
531
- - `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
532
- - `"delimiter"`: Defaults to `"\n!?。;!?"`.
533
- - `"task_page_size"`: Defaults to `12`. For PDF only.
534
- - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
535
- - If `"chunk_method"` is `"qa"`, `"manuel"`, `"paper"`, `"book"`, `"laws"`, or `"presentation"`, the `"parser_config"` object contains the following attribute:
536
- - `"raptor"`: Raptor-specific settings. Defaults to: `{"use_raptor": false}`.
537
- - If `"chunk_method"` is `"table"`, `"picture"`, `"one"`, or `"email"`, `"parser_config"` is an empty JSON object.
538
- - If `"chunk_method"` is `"knowledge_graph"`, the `"parser_config"` object contains the following attributes:
539
- - `"chunk_token_count"`: Defaults to `128`.
540
- - `"delimiter"`: Defaults to `"\n!?。;!?"`.
541
- - `"entity_types"`: Defaults to `["organization","person","location","event","time"]`
542
-
543
- ### Response
544
-
545
- Success:
546
-
547
- ```json
548
- {
549
- "code": 0
550
- }
551
- ```
552
-
553
- Failure:
554
-
555
- ```json
556
- {
557
- "code": 102,
558
- "message": "The dataset does not have the document."
559
- }
560
- ```
561
-
562
- ---
563
-
564
- ## Download document
565
-
566
- **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}`
567
-
568
- Downloads a document from a specified dataset.
569
-
570
- ### Request
571
-
572
- - Method: GET
573
- - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}`
574
- - Headers:
575
- - `'Authorization: Bearer {YOUR_API_KEY}'`
576
- - Output:
577
- - `'{PATH_TO_THE_FILE}'`
578
-
579
- #### Request example
580
-
581
- ```bash
582
- curl --request GET \
583
- --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id} \
584
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
585
- --output ./ragflow.txt
586
- ```
587
-
588
- #### Request parameters
589
-
590
- - `dataset_id`: (*Path parameter*)
591
- The associated dataset ID.
592
- - `documents_id`: (*Path parameter*)
593
- The ID of the document to download.
594
-
595
- ### Response
596
-
597
- Success:
598
-
599
- ```text
600
- This is a test to verify the file download feature.
601
- ```
602
-
603
- Failure:
604
-
605
- ```json
606
- {
607
- "code": 102,
608
- "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
609
- }
610
- ```
611
-
612
- ---
613
-
614
- ## List documents
615
-
616
- **GET** `/api/v1/datasets/{dataset_id}/documents?offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}`
617
-
618
- Lists documents in a specified dataset.
619
-
620
- ### Request
621
-
622
- - Method: GET
623
- - URL: `/api/v1/datasets/{dataset_id}/documents?keywords={keyword}&page={page}&page_size={limit}&orderby={orderby}&desc={desc}&name={name}`
624
- - Headers:
625
- - `'content-Type: application/json'`
626
- - `'Authorization: Bearer {YOUR_API_KEY}'`
627
-
628
- #### Request example
629
-
630
- ```bash
631
- curl --request GET \
632
- --url http://{address}/api/v1/datasets/{dataset_id}/documents?keywords={keywords}&offset={offset}&limit={limit}&orderby={orderby}&desc={desc}&id={document_id} \
633
- --header 'Authorization: Bearer {YOUR_API_KEY}'
634
- ```
635
-
636
- #### Request parameters
637
-
638
- - `dataset_id`: (*Path parameter*)
639
- The associated dataset ID.
640
- - `keywords`: (*Filter parameter*), `string`
641
- The keywords used to match document titles.
642
- - `offset`: (*Filter parameter*), `integer`
643
- The starting index for the documents to retrieve. Typically used in conjunction with `limit`. Defaults to `1`.
644
- - `limit`: (*Filter parameter*), `integer`
645
- The maximum number of documents to retrieve. Defaults to `1024`.
646
- - `orderby`: (*Filter parameter*), `string`
647
- The field by which documents should be sorted. Available options:
648
- - `create_time` (default)
649
- - `update_time`
650
- - `desc`: (*Filter parameter*), `boolean`
651
- Indicates whether the retrieved documents should be sorted in descending order. Defaults to `true`.
652
- - `id`: (*Filter parameter*), `string`
653
- The ID of the document to retrieve.
654
-
655
- ### Response
656
-
657
- Success:
658
-
659
- ```json
660
- {
661
- "code": 0,
662
- "data": {
663
- "docs": [
664
- {
665
- "chunk_count": 0,
666
- "create_date": "Mon, 14 Oct 2024 09:11:01 GMT",
667
- "create_time": 1728897061948,
668
- "created_by": "69736c5e723611efb51b0242ac120007",
669
- "id": "3bcfbf8a8a0c11ef8aba0242ac120006",
670
- "knowledgebase_id": "7898da028a0511efbf750242ac120005",
671
- "location": "Test_2.txt",
672
- "name": "Test_2.txt",
673
- "parser_config": {
674
- "chunk_token_count": 128,
675
- "delimiter": "\n!?。;!?",
676
- "layout_recognize": true,
677
- "task_page_size": 12
678
- },
679
- "parser_method": "naive",
680
- "process_begin_at": null,
681
- "process_duation": 0.0,
682
- "progress": 0.0,
683
- "progress_msg": "",
684
- "run": "0",
685
- "size": 7,
686
- "source_type": "local",
687
- "status": "1",
688
- "thumbnail": null,
689
- "token_count": 0,
690
- "type": "doc",
691
- "update_date": "Mon, 14 Oct 2024 09:11:01 GMT",
692
- "update_time": 1728897061948
693
- }
694
- ],
695
- "total": 1
696
- }
697
- }
698
- ```
699
-
700
- Failure:
701
-
702
- ```json
703
- {
704
- "code": 102,
705
- "message": "You don't own the dataset 7898da028a0511efbf750242ac1220005. "
706
- }
707
- ```
708
-
709
- ---
710
-
711
- ## Delete documents
712
-
713
- **DELETE** `/api/v1/datasets/{dataset_id}/documents`
714
-
715
- Deletes documents by ID.
716
-
717
- ### Request
718
-
719
- - Method: DELETE
720
- - URL: `/api/v1/datasets/{dataset_id}/documents`
721
- - Headers:
722
- - `'Content-Type: application/json'`
723
- - `'Authorization: Bearer {YOUR_API_KEY}'`
724
- - Body:
725
- - `"ids"`: `list[string]`
726
-
727
- #### Request example
728
-
729
- ```bash
730
- curl --request DELETE \
731
- --url http://{address}/api/v1/datasets/{dataset_id}/documents \
732
- --header 'Content-Type: application/json' \
733
- --header 'Authorization: {YOUR_API_KEY}' \
734
- --data '
735
- {
736
- "ids": ["id_1","id_2"]
737
- }'
738
- ```
739
-
740
- #### Request parameters
741
-
742
- - `dataset_id`: (*Path parameter*)
743
- The associated dataset ID.
744
- - `"ids"`: (*Body parameter*), `list[string]`
745
- The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
746
-
747
- ### Response
748
-
749
- Success:
750
-
751
- ```json
752
- {
753
- "code": 0
754
- }.
755
- ```
756
-
757
- Failure:
758
-
759
- ```json
760
- {
761
- "code": 102,
762
- "message": "You do not own the dataset 7898da028a0511efbf750242ac1220005."
763
- }
764
- ```
765
-
766
- ---
767
-
768
- ## Parse documents
769
-
770
- **POST** `/api/v1/datasets/{dataset_id}/chunks`
771
-
772
- Parses documents in a specified dataset.
773
-
774
- ### Request
775
-
776
- - Method: POST
777
- - URL: `/api/v1/datasets/{dataset_id}/chunks`
778
- - Headers:
779
- - `'content-Type: application/json'`
780
- - 'Authorization: Bearer {YOUR_API_KEY}'
781
- - Body:
782
- - `"document_ids"`: `list[string]`
783
-
784
- #### Request example
785
-
786
- ```bash
787
- curl --request POST \
788
- --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
789
- --header 'Content-Type: application/json' \
790
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
791
- --data '
792
- {
793
- "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
794
- }'
795
- ```
796
-
797
- #### Request parameters
798
-
799
- - `dataset_id`: (*Path parameter*)
800
- The dataset ID.
801
- - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
802
- The IDs of the documents to parse.
803
-
804
- ### Response
805
-
806
- Success:
807
-
808
- ```json
809
- {
810
- "code": 0
811
- }
812
- ```
813
-
814
- Failure:
815
-
816
- ```json
817
- {
818
- "code": 102,
819
- "message": "`document_ids` is required"
820
- }
821
- ```
822
-
823
- ---
824
-
825
- ## Stop parsing documents
826
-
827
- **DELETE** `/api/v1/datasets/{dataset_id}/chunks`
828
-
829
- Stops parsing specified documents.
830
-
831
- ### Request
832
-
833
- - Method: DELETE
834
- - URL: `/api/v1/datasets/{dataset_id}/chunks`
835
- - Headers:
836
- - `'content-Type: application/json'`
837
- - `'Authorization: Bearer {YOUR_API_KEY}'`
838
- - Body:
839
- - `"document_ids"`: `list[string]`
840
-
841
- #### Request example
842
-
843
- ```bash
844
- curl --request DELETE \
845
- --url http://{address}/api/v1/datasets/{dataset_id}/chunks \
846
- --header 'Content-Type: application/json' \
847
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
848
- --data '
849
- {
850
- "document_ids": ["97a5f1c2759811efaa500242ac120004","97ad64b6759811ef9fc30242ac120004"]
851
- }'
852
- ```
853
-
854
- #### Request parameters
855
-
856
- - `dataset_id`: (*Path parameter*)
857
- The associated dataset ID.
858
- - `"document_ids"`: (*Body parameter*), `list[string]`, *Required*
859
- The IDs of the documents for which the parsing should be stopped.
860
-
861
- ### Response
862
-
863
- Success:
864
-
865
- ```json
866
- {
867
- "code": 0
868
- }
869
- ```
870
-
871
- Failure:
872
-
873
- ```json
874
- {
875
- "code": 102,
876
- "message": "`document_ids` is required"
877
- }
878
- ```
879
-
880
- ---
881
-
882
- ## Add chunks
883
-
884
- **POST** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
885
-
886
- Adds a chunk to a specified document in a specified dataset.
887
-
888
- ### Request
889
-
890
- - Method: POST
891
- - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
892
- - Headers:
893
- - `'content-Type: application/json'`
894
- - `'Authorization: Bearer {YOUR_API_KEY}'`
895
- - Body:
896
- - `"content"`: `string`
897
- - `"important_keywords"`: `list[string]`
898
-
899
- #### Request example
900
-
901
- ```bash
902
- curl --request POST \
903
- --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
904
- --header 'Content-Type: application/json' \
905
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
906
- --data '
907
- {
908
- "content": "<SOME_CHUNK_CONTENT_HERE>"
909
- }'
910
- ```
911
-
912
- #### Request parameters
913
-
914
- - `dataset_id`: (*Path parameter*)
915
- The associated dataset ID.
916
- - `document_ids`: (*Path parameter*)
917
- The associated document ID.
918
- - `"content"`: (*Body parameter*), `string`, *Required*
919
- The text content of the chunk.
920
- - `"important_keywords`(*Body parameter*), `list[string]`
921
- The key terms or phrases to tag with the chunk.
922
-
923
- ### Response
924
-
925
- Success:
926
-
927
- ```json
928
- {
929
- "code": 0,
930
- "data": {
931
- "chunk": {
932
- "content": "ragflow content",
933
- "create_time": "2024-10-16 08:05:04",
934
- "create_timestamp": 1729065904.581025,
935
- "dataset_id": [
936
- "c7ee74067a2c11efb21c0242ac120006"
937
- ],
938
- "document_id": "5c5999ec7be811ef9cab0242ac120005",
939
- "id": "d78435d142bd5cf6704da62c778795c5",
940
- "important_keywords": []
941
- }
942
- }
943
- }
944
- ```
945
-
946
- Failure:
947
-
948
- ```json
949
- {
950
- "code": 102,
951
- "message": "`content` is required"
952
- }
953
- ```
954
-
955
- ---
956
-
957
- ## List chunks
958
-
959
- **GET** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={id}`
960
-
961
- Lists chunks in a specified document.
962
-
963
- ### Request
964
-
965
- - Method: GET
966
- - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={chunk_id}`
967
- - Headers:
968
- - `'Authorization: Bearer {YOUR_API_KEY}'`
969
-
970
- #### Request example
971
-
972
- ```bash
973
- curl --request GET \
974
- --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&offset={offset}&limit={limit}&id={chunk_id} \
975
- --header 'Authorization: Bearer {YOUR_API_KEY}'
976
- ```
977
-
978
- #### Request parameters
979
-
980
- - `dataset_id`: (*Path parameter*)
981
- The associated dataset ID.
982
- - `document_ids`: (*Path parameter*)
983
- The associated document ID.
984
- - `keywords`(*Filter parameter*), `string`
985
- The keywords used to match chunk content.
986
- - `offset`(*Filter parameter*), `string`
987
- The starting index for the chunks to retrieve. Defaults to `1`.
988
- - `limit`(*Filter parameter*), `integer`
989
- The maximum number of chunks to retrieve. Default: `1024`
990
- - `id`(*Filter parameter*), `string`
991
- The ID of the chunk to retrieve.
992
-
993
- ### Response
994
-
995
- Success:
996
-
997
- ```json
998
- {
999
- "code": 0,
1000
- "data": {
1001
- "chunks": [
1002
- {
1003
- "available_int": 1,
1004
- "content": "This is a test content.",
1005
- "docnm_kwd": "1.txt",
1006
- "document_id": "b330ec2e91ec11efbc510242ac120004",
1007
- "id": "b48c170e90f70af998485c1065490726",
1008
- "image_id": "",
1009
- "important_keywords": "",
1010
- "positions": [
1011
- ""
1012
- ]
1013
- }
1014
- ],
1015
- "doc": {
1016
- "chunk_count": 1,
1017
- "chunk_method": "naive",
1018
- "create_date": "Thu, 24 Oct 2024 09:45:27 GMT",
1019
- "create_time": 1729763127646,
1020
- "created_by": "69736c5e723611efb51b0242ac120007",
1021
- "dataset_id": "527fa74891e811ef9c650242ac120006",
1022
- "id": "b330ec2e91ec11efbc510242ac120004",
1023
- "location": "1.txt",
1024
- "name": "1.txt",
1025
- "parser_config": {
1026
- "chunk_token_num": 128,
1027
- "delimiter": "\\n!?;。;!?",
1028
- "html4excel": false,
1029
- "layout_recognize": true,
1030
- "raptor": {
1031
- "user_raptor": false
1032
- }
1033
- },
1034
- "process_begin_at": "Thu, 24 Oct 2024 09:56:44 GMT",
1035
- "process_duation": 0.54213,
1036
- "progress": 0.0,
1037
- "progress_msg": "Task dispatched...",
1038
- "run": "2",
1039
- "size": 17966,
1040
- "source_type": "local",
1041
- "status": "1",
1042
- "thumbnail": "",
1043
- "token_count": 8,
1044
- "type": "doc",
1045
- "update_date": "Thu, 24 Oct 2024 11:03:15 GMT",
1046
- "update_time": 1729767795721
1047
- },
1048
- "total": 1
1049
- }
1050
- }
1051
- ```
1052
-
1053
- Failure:
1054
-
1055
- ```json
1056
- {
1057
- "code": 102,
1058
- "message": "You don't own the document 5c5999ec7be811ef9cab0242ac12000e5."
1059
- }
1060
- ```
1061
-
1062
- ---
1063
-
1064
- ## Delete chunks
1065
-
1066
- **DELETE** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
1067
-
1068
- Deletes chunks by ID.
1069
-
1070
- ### Request
1071
-
1072
- - Method: DELETE
1073
- - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks`
1074
- - Headers:
1075
- - `'content-Type: application/json'`
1076
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1077
- - Body:
1078
- - `"chunk_ids"`: `list[string]`
1079
-
1080
- #### Request example
1081
-
1082
- ```bash
1083
- curl --request DELETE \
1084
- --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks \
1085
- --header 'Content-Type: application/json' \
1086
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
1087
- --data '
1088
- {
1089
- "chunk_ids": ["test_1", "test_2"]
1090
- }'
1091
- ```
1092
-
1093
- #### Request parameters
1094
-
1095
- - `dataset_id`: (*Path parameter*)
1096
- The associated dataset ID.
1097
- - `document_ids`: (*Path parameter*)
1098
- The associated document ID.
1099
- - `"chunk_ids"`: (*Body parameter*), `list[string]`
1100
- The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
1101
-
1102
- ### Response
1103
-
1104
- Success:
1105
-
1106
- ```json
1107
- {
1108
- "code": 0
1109
- }
1110
- ```
1111
-
1112
- Failure:
1113
-
1114
- ```json
1115
- {
1116
- "code": 102,
1117
- "message": "`chunk_ids` is required"
1118
- }
1119
- ```
1120
-
1121
- ---
1122
-
1123
- ## Update chunk
1124
-
1125
- **PUT** `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
1126
-
1127
- Updates content or configurations for a specified chunk.
1128
-
1129
- ### Request
1130
-
1131
- - Method: PUT
1132
- - URL: `/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}`
1133
- - Headers:
1134
- - `'content-Type: application/json'`
1135
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1136
- - Body:
1137
- - `"content"`: `string`
1138
- - `"important_keywords"`: `string`
1139
- - `"available"`: `integer`
1140
-
1141
- #### Request example
1142
-
1143
- ```bash
1144
- curl --request PUT \
1145
- --url http://{address}/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} \
1146
- --header 'Content-Type: application/json' \
1147
- --header 'Authorization: {YOUR_API_KEY}' \
1148
- --data '
1149
- {
1150
- "content": "ragflow123",
1151
- "important_keywords": [],
1152
- }'
1153
- ```
1154
-
1155
- #### Request parameters
1156
-
1157
- - `dataset_id`: (*Path parameter*)
1158
- The associated dataset ID.
1159
- - `document_ids`: (*Path parameter*)
1160
- The associated document ID.
1161
- - `chunk_id`: (*Path parameter*)
1162
- The ID of the chunk to update.
1163
- - `"content"`: (*Body parameter*), `string`
1164
- The text content of the chunk.
1165
- - `"important_keywords"`: (*Body parameter*), `list[string]`
1166
- A list of key terms or phrases to tag with the chunk.
1167
- - `"available"`: (*Body parameter*) `boolean`
1168
- The chunk's availability status in the dataset. Value options:
1169
- - `true`: Available (default)
1170
- - `false`: Unavailable
1171
-
1172
- ### Response
1173
-
1174
- Success:
1175
-
1176
- ```json
1177
- {
1178
- "code": 0
1179
- }
1180
- ```
1181
-
1182
- Failure:
1183
-
1184
- ```json
1185
- {
1186
- "code": 102,
1187
- "message": "Can't find this chunk 29a2d9987e16ba331fb4d7d30d99b71d2"
1188
- }
1189
- ```
1190
-
1191
- ---
1192
-
1193
- ## Retrieve chunks
1194
-
1195
- **POST** `/api/v1/retrieval`
1196
-
1197
- Retrieves chunks from specified datasets.
1198
-
1199
- ### Request
1200
-
1201
- - Method: POST
1202
- - URL: `/api/v1/retrieval`
1203
- - Headers:
1204
- - `'content-Type: application/json'`
1205
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1206
- - Body:
1207
- - `"question"`: `string`
1208
- - `"dataset_ids"`: `list[string]`
1209
- - `"document_ids"`: `list[string]`
1210
- - `"offset"`: `integer`
1211
- - `"limit"`: `integer`
1212
- - `"similarity_threshold"`: `float`
1213
- - `"vector_similarity_weight"`: `float`
1214
- - `"top_k"`: `integer`
1215
- - `"rerank_id"`: `string`
1216
- - `"keyword"`: `boolean`
1217
- - `"highlight"`: `boolean`
1218
-
1219
- #### Request example
1220
-
1221
- ```bash
1222
- curl --request POST \
1223
- --url http://{address}/api/v1/retrieval \
1224
- --header 'Content-Type: application/json' \
1225
- --header 'Authorization: {YOUR_API_KEY}' \
1226
- --data '
1227
- {
1228
- "question": "What is advantage of ragflow?",
1229
- "dataset_ids": ["b2a62730759d11ef987d0242ac120004"],
1230
- "document_ids": ["77df9ef4759a11ef8bdd0242ac120004"]
1231
- }'
1232
- ```
1233
-
1234
- #### Request parameter
1235
-
1236
- - `"question"`: (*Body parameter*), `string`, *Required*
1237
- The user query or query keywords.
1238
- - `"dataset_ids"`: (*Body parameter*) `list[string]`
1239
- The IDs of the datasets to search. If you do not set this argument, ensure that you set `"document_ids"`.
1240
- - `"document_ids"`: (*Body parameter*), `list[string]`
1241
- 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"`.
1242
- - `"offset"`: (*Body parameter*), `integer`
1243
- The starting index for the documents to retrieve. Defaults to `1`.
1244
- - `"limit"`: (*Body parameter*)
1245
- The maximum number of chunks to retrieve. Defaults to `1024`.
1246
- - `"similarity_threshold"`: (*Body parameter*)
1247
- The minimum similarity score. Defaults to `0.2`.
1248
- - `"vector_similarity_weight"`: (*Body parameter*), `float`
1249
- 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.
1250
- - `"top_k"`: (*Body parameter*), `integer`
1251
- The number of chunks engaged in vector cosine computaton. Defaults to `1024`.
1252
- - `"rerank_id"`: (*Body parameter*), `integer`
1253
- The ID of the rerank model.
1254
- - `"keyword"`: (*Body parameter*), `boolean`
1255
- Indicates whether to enable keyword-based matching:
1256
- - `true`: Enable keyword-based matching.
1257
- - `false`: Disable keyword-based matching (default).
1258
- - `"highlight"`: (*Body parameter*), `boolean`
1259
- Specifies whether to enable highlighting of matched terms in the results:
1260
- - `true`: Enable highlighting of matched terms.
1261
- - `false`: Disable highlighting of matched terms (default).
1262
-
1263
- ### Response
1264
-
1265
- Success:
1266
-
1267
- ```json
1268
- {
1269
- "code": 0,
1270
- "data": {
1271
- "chunks": [
1272
- {
1273
- "content": "ragflow content",
1274
- "content_ltks": "ragflow content",
1275
- "document_id": "5c5999ec7be811ef9cab0242ac120005",
1276
- "document_keyword": "1.txt",
1277
- "highlight": "<em>ragflow</em> content",
1278
- "id": "d78435d142bd5cf6704da62c778795c5",
1279
- "img_id": "",
1280
- "important_keywords": [
1281
- ""
1282
- ],
1283
- "kb_id": "c7ee74067a2c11efb21c0242ac120006",
1284
- "positions": [
1285
- ""
1286
- ],
1287
- "similarity": 0.9669436601210759,
1288
- "term_similarity": 1.0,
1289
- "vector_similarity": 0.8898122004035864
1290
- }
1291
- ],
1292
- "doc_aggs": [
1293
- {
1294
- "count": 1,
1295
- "doc_id": "5c5999ec7be811ef9cab0242ac120005",
1296
- "doc_name": "1.txt"
1297
- }
1298
- ],
1299
- "total": 1
1300
- }
1301
- }
1302
- ```
1303
-
1304
- Failure:
1305
-
1306
- ```json
1307
- {
1308
- "code": 102,
1309
- "message": "`datasets` is required."
1310
- }
1311
- ```
1312
-
1313
- ---
1314
-
1315
- :::tip API GROUPING
1316
- Chat Assistant Management
1317
- :::
1318
-
1319
- ---
1320
-
1321
- ## Create chat assistant
1322
-
1323
- **POST** `/api/v1/chats`
1324
-
1325
- Creates a chat assistant.
1326
-
1327
- ### Request
1328
-
1329
- - Method: POST
1330
- - URL: `/api/v1/chats`
1331
- - Headers:
1332
- - `'content-Type: application/json'`
1333
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1334
- - Body:
1335
- - `"name"`: `string`
1336
- - `"avatar"`: `string`
1337
- - `"dataset_ids"`: `list[string]`
1338
- - `"llm"`: `object`
1339
- - `"prompt"`: `object`
1340
-
1341
- #### Request example
1342
-
1343
- ```shell
1344
- curl --request POST \
1345
- --url http://{address}/api/v1/chats \
1346
- --header 'Content-Type: application/json' \
1347
- --header 'Authorization: Bearer {YOUR_API_KEY}'
1348
- --data '{
1349
- "dataset_ids": ["0b2cbc8c877f11ef89070242ac120005"],
1350
- "name":"new_chat_1"
1351
- }'
1352
- ```
1353
-
1354
- #### Request parameters
1355
-
1356
- - `"name"`: (*Body parameter*), `string`, *Required*
1357
- The name of the chat assistant.
1358
- - `"avatar"`: (*Body parameter*), `string`
1359
- Base64 encoding of the avatar.
1360
- - `"dataset_ids"`: (*Body parameter*), `list[string]`
1361
- The IDs of the associated datasets.
1362
- - `"llm"`: (*Body parameter*), `object`
1363
- 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:
1364
- - `"model_name"`, `string`
1365
- The chat model name. If not set, the user's default chat model will be used.
1366
- - `"temperature"`: `float`
1367
- Controls the randomness of the model's predictions. A lower temperature increases the model's confidence in its responses; a higher temperature increases creativity and diversity. Defaults to `0.1`.
1368
- - `"top_p"`: `float`
1369
- 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`
1370
- - `"presence_penalty"`: `float`
1371
- This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
1372
- - `"frequency penalty"`: `float`
1373
- Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
1374
- - `"max_token"`: `integer`
1375
- The maximum length of the model’s output, measured in the number of tokens (words or pieces of words). Defaults to `512`.
1376
- - `"prompt"`: (*Body parameter*), `object`
1377
- 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:
1378
- - `"similarity_threshold"`: `float` RAGFlow uses a hybrid of weighted keyword similarity and vector cosine similarity 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`.
1379
- - `"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`.
1380
- - `"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`.
1381
- - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
1382
- - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
1383
- - All the variables in 'System' should be curly bracketed.
1384
- - The default value is `[{"key": "knowledge", "optional": true}]`.
1385
- - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
1386
- - `"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.
1387
- - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
1388
- - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
1389
- - `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset 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.
1390
- Here is the knowledge base:
1391
- {knowledge}
1392
- The above is the knowledge base.`
1393
-
1394
- ### Response
1395
-
1396
- Success:
1397
-
1398
- ```json
1399
- {
1400
- "code": 0,
1401
- "data": {
1402
- "avatar": "",
1403
- "create_date": "Thu, 24 Oct 2024 11:18:29 GMT",
1404
- "create_time": 1729768709023,
1405
- "dataset_ids": [
1406
- "527fa74891e811ef9c650242ac120006"
1407
- ],
1408
- "description": "A helpful Assistant",
1409
- "do_refer": "1",
1410
- "id": "b1f2f15691f911ef81180242ac120003",
1411
- "language": "English",
1412
- "llm": {
1413
- "frequency_penalty": 0.7,
1414
- "max_tokens": 512,
1415
- "model_name": "qwen-plus@Tongyi-Qianwen",
1416
- "presence_penalty": 0.4,
1417
- "temperature": 0.1,
1418
- "top_p": 0.3
1419
- },
1420
- "name": "12234",
1421
- "prompt": {
1422
- "empty_response": "Sorry! No relevant content was found in the knowledge base!",
1423
- "keywords_similarity_weight": 0.3,
1424
- "opener": "Hi! I'm your assistant, what can I do for you?",
1425
- "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 Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.",
1426
- "rerank_model": "",
1427
- "similarity_threshold": 0.2,
1428
- "top_n": 6,
1429
- "variables": [
1430
- {
1431
- "key": "knowledge",
1432
- "optional": false
1433
- }
1434
- ]
1435
- },
1436
- "prompt_type": "simple",
1437
- "status": "1",
1438
- "tenant_id": "69736c5e723611efb51b0242ac120007",
1439
- "top_k": 1024,
1440
- "update_date": "Thu, 24 Oct 2024 11:18:29 GMT",
1441
- "update_time": 1729768709023
1442
- }
1443
- }
1444
- ```
1445
-
1446
- Failure:
1447
-
1448
- ```json
1449
- {
1450
- "code": 102,
1451
- "message": "Duplicated chat name in creating dataset."
1452
- }
1453
- ```
1454
-
1455
- ---
1456
-
1457
- ## Update chat assistant
1458
-
1459
- **PUT** `/api/v1/chats/{chat_id}`
1460
-
1461
- Updates configurations for a specified chat assistant.
1462
-
1463
- ### Request
1464
-
1465
- - Method: PUT
1466
- - URL: `/api/v1/chats/{chat_id}`
1467
- - Headers:
1468
- - `'content-Type: application/json'`
1469
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1470
- - Body:
1471
- - `"name"`: `string`
1472
- - `"avatar"`: `string`
1473
- - `"dataset_ids"`: `list[string]`
1474
- - `"llm"`: `object`
1475
- - `"prompt"`: `object`
1476
-
1477
- #### Request example
1478
-
1479
- ```bash
1480
- curl --request PUT \
1481
- --url http://{address}/api/v1/chats/{chat_id} \
1482
- --header 'Content-Type: application/json' \
1483
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
1484
- --data '
1485
- {
1486
- "name":"Test"
1487
- }'
1488
- ```
1489
-
1490
- #### Parameters
1491
-
1492
- - `chat_id`: (*Path parameter*)
1493
- The ID of the chat assistant to update.
1494
- - `"name"`: (*Body parameter*), `string`, *Required*
1495
- The revised name of the chat assistant.
1496
- - `"avatar"`: (*Body parameter*), `string`
1497
- Base64 encoding of the avatar.
1498
- - `"dataset_ids"`: (*Body parameter*), `list[string]`
1499
- The IDs of the associated datasets.
1500
- - `"llm"`: (*Body parameter*), `object`
1501
- 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:
1502
- - `"model_name"`, `string`
1503
- The chat model name. If not set, the user's default chat model will be used.
1504
- - `"temperature"`: `float`
1505
- Controls the randomness of the model's predictions. A lower temperature increases the model's confidence in its responses; a higher temperature increases creativity and diversity. Defaults to `0.1`.
1506
- - `"top_p"`: `float`
1507
- 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`
1508
- - `"presence_penalty"`: `float`
1509
- This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to `0.2`.
1510
- - `"frequency penalty"`: `float`
1511
- Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to `0.7`.
1512
- - `"max_token"`: `integer`
1513
- The maximum length of the model’s output, measured in the number of tokens (words or pieces of words). Defaults to `512`.
1514
- - `"prompt"`: (*Body parameter*), `object`
1515
- Instructions for the LLM to follow. A `prompt` object contains the following attributes:
1516
- - `"similarity_threshold"`: `float` RAGFlow uses a hybrid of weighted keyword similarity and vector cosine similarity 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`.
1517
- - `"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`.
1518
- - `"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`.
1519
- - `"variables"`: `object[]` This argument lists the variables to use in the 'System' field of **Chat Configurations**. Note that:
1520
- - `"knowledge"` is a reserved variable, which represents the retrieved chunks.
1521
- - All the variables in 'System' should be curly bracketed.
1522
- - The default value is `[{"key": "knowledge", "optional": true}]`
1523
- - `"rerank_model"`: `string` If it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.
1524
- - `"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.
1525
- - `"opener"`: `string` The opening greeting for the user. Defaults to `"Hi! I am your assistant, can I help you?"`.
1526
- - `"show_quote`: `boolean` Indicates whether the source of text should be displayed. Defaults to `true`.
1527
- - `"prompt"`: `string` The prompt content. Defaults to `You are an intelligent assistant. Please summarize the content of the dataset 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.
1528
- Here is the knowledge base:
1529
- {knowledge}
1530
- The above is the knowledge base.`
1531
-
1532
- ### Response
1533
-
1534
- Success:
1535
-
1536
- ```json
1537
- {
1538
- "code": 0
1539
- }
1540
- ```
1541
-
1542
- Failure:
1543
-
1544
- ```json
1545
- {
1546
- "code": 102,
1547
- "message": "Duplicated chat name in updating dataset."
1548
- }
1549
- ```
1550
-
1551
- ---
1552
-
1553
- ## Delete chat assistants
1554
-
1555
- **DELETE** `/api/v1/chats`
1556
-
1557
- Deletes chat assistants by ID.
1558
-
1559
- ### Request
1560
-
1561
- - Method: DELETE
1562
- - URL: `/api/v1/chats`
1563
- - Headers:
1564
- - `'content-Type: application/json'`
1565
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1566
- - Body:
1567
- - `"ids"`: `list[string]`
1568
-
1569
- #### Request example
1570
-
1571
- ```bash
1572
- curl --request DELETE \
1573
- --url http://{address}/api/v1/chats \
1574
- --header 'Content-Type: application/json' \
1575
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
1576
- --data '
1577
- {
1578
- "ids": ["test_1", "test_2"]
1579
- }'
1580
- ```
1581
-
1582
- #### Request parameters
1583
-
1584
- - `"ids"`: (*Body parameter*), `list[string]`
1585
- The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
1586
-
1587
- ### Response
1588
-
1589
- Success:
1590
-
1591
- ```json
1592
- {
1593
- "code": 0
1594
- }
1595
- ```
1596
-
1597
- Failure:
1598
-
1599
- ```json
1600
- {
1601
- "code": 102,
1602
- "message": "ids are required"
1603
- }
1604
- ```
1605
-
1606
- ---
1607
-
1608
- ## List chat assistants
1609
-
1610
- **GET** `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}`
1611
-
1612
- Lists chat assistants.
1613
-
1614
- ### Request
1615
-
1616
- - Method: GET
1617
- - URL: `/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}`
1618
- - Headers:
1619
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1620
-
1621
- #### Request example
1622
-
1623
- ```bash
1624
- curl --request GET \
1625
- --url http://{address}/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} \
1626
- --header 'Authorization: Bearer {YOUR_API_KEY}'
1627
- ```
1628
-
1629
- #### Request parameters
1630
-
1631
- - `page`: (*Filter parameter*), `integer`
1632
- Specifies the page on which the chat assistants will be displayed. Defaults to `1`.
1633
- - `page_size`: (*Filter parameter*), `integer`
1634
- The number of chat assistants on each page. Defaults to `1024`.
1635
- - `orderby`: (*Filter parameter*), `string`
1636
- The attribute by which the results are sorted. Available options:
1637
- - `create_time` (default)
1638
- - `update_time`
1639
- - `desc`: (*Filter parameter*), `boolean`
1640
- Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults to `true`.
1641
- - `id`: (*Filter parameter*), `string`
1642
- The ID of the chat assistant to retrieve.
1643
- - `name`: (*Filter parameter*), `string`
1644
- The name of the chat assistant to retrieve.
1645
-
1646
- ### Response
1647
-
1648
- Success:
1649
-
1650
- ```json
1651
- {
1652
- "code": 0,
1653
- "data": [
1654
- {
1655
- "avatar": "",
1656
- "create_date": "Fri, 18 Oct 2024 06:20:06 GMT",
1657
- "create_time": 1729232406637,
1658
- "description": "A helpful Assistant",
1659
- "do_refer": "1",
1660
- "id": "04d0d8e28d1911efa3630242ac120006",
1661
- "dataset_ids": ["527fa74891e811ef9c650242ac120006"],
1662
- "language": "English",
1663
- "llm": {
1664
- "frequency_penalty": 0.7,
1665
- "max_tokens": 512,
1666
- "model_name": "qwen-plus@Tongyi-Qianwen",
1667
- "presence_penalty": 0.4,
1668
- "temperature": 0.1,
1669
- "top_p": 0.3
1670
- },
1671
- "name": "13243",
1672
- "prompt": {
1673
- "empty_response": "Sorry! No relevant content was found in the knowledge base!",
1674
- "keywords_similarity_weight": 0.3,
1675
- "opener": "Hi! I'm your assistant, what can I do for you?",
1676
- "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 Here is the knowledge base:\n {knowledge}\n The above is the knowledge base.",
1677
- "rerank_model": "",
1678
- "similarity_threshold": 0.2,
1679
- "top_n": 6,
1680
- "variables": [
1681
- {
1682
- "key": "knowledge",
1683
- "optional": false
1684
- }
1685
- ]
1686
- },
1687
- "prompt_type": "simple",
1688
- "status": "1",
1689
- "tenant_id": "69736c5e723611efb51b0242ac120007",
1690
- "top_k": 1024,
1691
- "update_date": "Fri, 18 Oct 2024 06:20:06 GMT",
1692
- "update_time": 1729232406638
1693
- }
1694
- ]
1695
- }
1696
- ```
1697
-
1698
- Failure:
1699
-
1700
- ```json
1701
- {
1702
- "code": 102,
1703
- "message": "The chat doesn't exist"
1704
- }
1705
- ```
1706
-
1707
- ## Create session
1708
-
1709
- **POST** `/api/v1/chats/{chat_id}/sessions`
1710
-
1711
- Creates a chat session.
1712
-
1713
- ### Request
1714
-
1715
- - Method: POST
1716
- - URL: `/api/v1/chats/{chat_id}/sessions`
1717
- - Headers:
1718
- - `'content-Type: application/json'`
1719
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1720
- - Body:
1721
- - `"name"`: `string`
1722
-
1723
- #### Request example
1724
-
1725
- ```bash
1726
- curl --request POST \
1727
- --url http://{address}/api/v1/chats/{chat_id}/sessions \
1728
- --header 'Content-Type: application/json' \
1729
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
1730
- --data '
1731
- {
1732
- "name": "new session"
1733
- }'
1734
- ```
1735
-
1736
- #### Request parameters
1737
-
1738
- - `chat_id`: (*Path parameter*)
1739
- The ID of the associated chat assistant.
1740
- - `"name"`: (*Body parameter*), `string`
1741
- The name of the chat session to create.
1742
-
1743
- ### Response
1744
-
1745
- Success:
1746
-
1747
- ```json
1748
- {
1749
- "code": 0,
1750
- "data": {
1751
- "chat_id": "2ca4b22e878011ef88fe0242ac120005",
1752
- "create_date": "Fri, 11 Oct 2024 08:46:14 GMT",
1753
- "create_time": 1728636374571,
1754
- "id": "4606b4ec87ad11efbc4f0242ac120006",
1755
- "messages": [
1756
- {
1757
- "content": "Hi! I am your assistant,can I help you?",
1758
- "role": "assistant"
1759
- }
1760
- ],
1761
- "name": "new session",
1762
- "update_date": "Fri, 11 Oct 2024 08:46:14 GMT",
1763
- "update_time": 1728636374571
1764
- }
1765
- }
1766
- ```
1767
-
1768
- Failure:
1769
-
1770
- ```json
1771
- {
1772
- "code": 102,
1773
- "message": "Name can not be empty."
1774
- }
1775
- ```
1776
-
1777
- ---
1778
-
1779
- ## Update session
1780
-
1781
- **PUT** `/api/v1/chats/{chat_id}/sessions/{session_id}`
1782
-
1783
- Updates a chat session.
1784
-
1785
- ### Request
1786
-
1787
- - Method: PUT
1788
- - URL: `/api/v1/chats/{chat_id}/sessions/{session_id}`
1789
- - Headers:
1790
- - `'content-Type: application/json'`
1791
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1792
- - Body:
1793
- - `"name`: string
1794
-
1795
- #### Request example
1796
- ```bash
1797
- curl --request PUT \
1798
- --url http://{address}/api/v1/chats/{chat_id}/sessions/{session_id} \
1799
- --header 'Content-Type: application/json' \
1800
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
1801
- --data '
1802
- {
1803
- "name": "<REVISED_SESSION_NAME_HERE>"
1804
- }'
1805
- ```
1806
-
1807
- #### Request Parameter
1808
-
1809
- - `chat_id`: (*Path parameter*)
1810
- The ID of the associated chat assistant.
1811
- - `session_id`: (*Path parameter*)
1812
- The ID of the session to update.
1813
- - `"name"`: (*Body Parameter), `string`
1814
- The revised name of the session.
1815
-
1816
- ### Response
1817
-
1818
- Success:
1819
-
1820
- ```json
1821
- {
1822
- "code": 0
1823
- }
1824
- ```
1825
-
1826
- Failure:
1827
-
1828
- ```json
1829
- {
1830
- "code": 102,
1831
- "message": "Name cannot be empty."
1832
- }
1833
- ```
1834
-
1835
- ---
1836
-
1837
- ## List sessions
1838
-
1839
- **GET** `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
1840
-
1841
- Lists sessions associated with a specified chat assistant.
1842
-
1843
- ### Request
1844
-
1845
- - Method: GET
1846
- - URL: `/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}`
1847
- - Headers:
1848
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1849
-
1850
- #### Request example
1851
-
1852
- ```bash
1853
- curl --request GET \
1854
- --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} \
1855
- --header 'Authorization: Bearer {YOUR_API_KEY}'
1856
- ```
1857
-
1858
- #### Request Parameters
1859
-
1860
- - `chat_id`: (*Path parameter*)
1861
- The ID of the associated chat assistant.
1862
- - `page`: (*Filter parameter*), `integer`
1863
- Specifies the page on which the sessions will be displayed. Defaults to `1`.
1864
- - `page_size`: (*Filter parameter*), `integer`
1865
- The number of sessions on each page. Defaults to `1024`.
1866
- - `orderby`: (*Filter parameter*), `string`
1867
- The field by which sessions should be sorted. Available options:
1868
- - `create_time` (default)
1869
- - `update_time`
1870
- - `desc`: (*Filter parameter*), `boolean`
1871
- Indicates whether the retrieved sessions should be sorted in descending order. Defaults to `true`.
1872
- - `name`: (*Filter parameter*) `string`
1873
- The name of the chat session to retrieve.
1874
- - `id`: (*Filter parameter*), `string`
1875
- The ID of the chat session to retrieve.
1876
-
1877
- ### Response
1878
-
1879
- Success:
1880
-
1881
- ```json
1882
- {
1883
- "code": 0,
1884
- "data": [
1885
- {
1886
- "chat": "2ca4b22e878011ef88fe0242ac120005",
1887
- "create_date": "Fri, 11 Oct 2024 08:46:43 GMT",
1888
- "create_time": 1728636403974,
1889
- "id": "578d541e87ad11ef96b90242ac120006",
1890
- "messages": [
1891
- {
1892
- "content": "Hi! I am your assistant,can I help you?",
1893
- "role": "assistant"
1894
- }
1895
- ],
1896
- "name": "new session",
1897
- "update_date": "Fri, 11 Oct 2024 08:46:43 GMT",
1898
- "update_time": 1728636403974
1899
- }
1900
- ]
1901
- }
1902
- ```
1903
-
1904
- Failure:
1905
-
1906
- ```json
1907
- {
1908
- "code": 102,
1909
- "message": "The session doesn't exist"
1910
- }
1911
- ```
1912
-
1913
- ---
1914
-
1915
- ## Delete sessions
1916
-
1917
- **DELETE** `/api/v1/chats/{chat_id}/sessions`
1918
-
1919
- Deletes sessions by ID.
1920
-
1921
- ### Request
1922
-
1923
- - Method: DELETE
1924
- - URL: `/api/v1/chats/{chat_id}/sessions`
1925
- - Headers:
1926
- - `'content-Type: application/json'`
1927
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1928
- - Body:
1929
- - `"ids"`: `list[string]`
1930
-
1931
- #### Request example
1932
-
1933
- ```bash
1934
- # Either id or name must be provided, but not both.
1935
- curl --request DELETE \
1936
- --url http://{address}/api/v1/chats/{chat_id}/sessions \
1937
- --header 'Content-Type: application/json' \
1938
- --header 'Authorization: Bear {YOUR_API_KEY}' \
1939
- --data '
1940
- {
1941
- "ids": ["test_1", "test_2"]
1942
- }'
1943
- ```
1944
-
1945
- #### Request Parameters
1946
-
1947
- - `chat_id`: (*Path parameter*)
1948
- The ID of the associated chat assistant.
1949
- - `"ids"`: (*Body Parameter*), `list[string]`
1950
- The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
1951
-
1952
- ### Response
1953
-
1954
- Success:
1955
-
1956
- ```json
1957
- {
1958
- "code": 0
1959
- }
1960
- ```
1961
-
1962
- Failure:
1963
-
1964
- ```json
1965
- {
1966
- "code": 102,
1967
- "message": "The chat doesn't own the session"
1968
- }
1969
- ```
1970
-
1971
- ---
1972
-
1973
- ## Converse
1974
-
1975
- **POST** `/api/v1/chats/{chat_id}/completions`
1976
-
1977
- Asks a question to start an AI-powered conversation.
1978
-
1979
- ### Request
1980
-
1981
- - Method: POST
1982
- - URL: `/api/v1/chats/{chat_id}/completions`
1983
- - Headers:
1984
- - `'content-Type: application/json'`
1985
- - `'Authorization: Bearer {YOUR_API_KEY}'`
1986
- - Body:
1987
- - `"question"`: `string`
1988
- - `"stream"`: `boolean`
1989
- - `"session_id"`: `string`
1990
-
1991
- #### Request example
1992
-
1993
- ```bash
1994
- curl --request POST \
1995
- --url http://{address}/api/v1/chats/{chat_id}/completions \
1996
- --header 'Content-Type: application/json' \
1997
- --header 'Authorization: Bearer {YOUR_API_KEY}' \
1998
- --data-binary '
1999
- {
2000
- "question": "What is RAGFlow?",
2001
- "stream": true
2002
- }'
2003
- ```
2004
-
2005
- #### Request Parameters
2006
-
2007
- - `chat_id`: (*Path parameter*)
2008
- The ID of the associated chat assistant.
2009
- - `"question"`: (*Body Parameter*), `string` *Required*
2010
- The question to start an AI-powered conversation.
2011
- - `"stream"`: (*Body Parameter*), `boolean`
2012
- Indicates whether to output responses in a streaming way:
2013
- - `true`: Enable streaming.
2014
- - `false`: Disable streaming (default).
2015
- - `"session_id"`: (*Body Parameter*)
2016
- The ID of session. If it is not provided, a new session will be generated.
2017
-
2018
- ### Response
2019
-
2020
- Success:
2021
-
2022
- ```json
2023
- data: {
2024
- "code": 0,
2025
- "data": {
2026
- "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide",
2027
- "reference": {},
2028
- "audio_binary": null,
2029
- "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
2030
- "session_id": "e14344d08d1a11efb6210242ac120004"
2031
- }
2032
- }
2033
-
2034
- data: {
2035
- "code": 0,
2036
- "data": {
2037
- "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide information, answer questions, and assist with tasks based on the knowledge available to me",
2038
- "reference": {},
2039
- "audio_binary": null,
2040
- "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
2041
- "session_id": "e14344d08d1a11efb6210242ac120004"
2042
- }
2043
- }
2044
-
2045
- data: {
2046
- "code": 0,
2047
- "data": {
2048
- "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide information, answer questions, and assist with tasks based on the knowledge available to me. How can I assist you today?",
2049
- "reference": {},
2050
- "audio_binary": null,
2051
- "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
2052
- "session_id": "e14344d08d1a11efb6210242ac120004"
2053
- }
2054
- }
2055
-
2056
- data: {
2057
- "code": 0,
2058
- "data": {
2059
- "answer": "I am an intelligent assistant designed to help you with your inquiries. I can provide information, answer questions, and assist with tasks based on the knowledge available to me ##0$$. How can I assist you today?",
2060
- "reference": {
2061
- "total": 8,
2062
- "chunks": [
2063
- {
2064
- "chunk_id": "895d34de762e674b43e8613c6fb54c6d",
2065
- "content_ltks": "xxxx\r\n\r\n\"\"\"\r\nyou are an intellig assistant. pleas summar the content of the knowledg base to answer the question. pleas list thedata in the knowledg base and answer in detail. when all knowledg base content is irrelev to the question , your answer must includ the sentenc\"the answer you are lookfor isnot found in the knowledg base!\" answer needto consid chat history.\r\n here is the knowledg base:\r\n{ knowledg}\r\nthe abov is the knowledg base.\r\n\"\"\"\r\n1\r\n 2\r\n 3\r\n 4\r\n 5\r\n 6\r\nxxxx ",
2066
- "content_with_weight": "xxxx\r\n\r\n\"\"\"\r\nYou 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.\r\n Here is the knowledge base:\r\n {knowledge}\r\n The above is the knowledge base.\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\nxxxx\r\n\r\n\"\"\"\r\nxxxx",
2067
- "doc_id": "5c5999ec7be811ef9cab0242ac120005",
2068
- "docnm_kwd": "1.txt",
2069
- "kb_id": "c7ee74067a2c11efb21c0242ac120006",
2070
- "important_kwd": [],
2071
- "img_id": "",
2072
- "similarity": 0.4442746624416507,
2073
- "vector_similarity": 0.3843936320913369,
2074
- "term_similarity": 0.4699379611632138,
2075
- "positions": [
2076
- ""
2077
- ]
2078
- }
2079
- ],
2080
- "doc_aggs": [
2081
- {
2082
- "doc_name": "1.txt",
2083
- "doc_id": "5c5999ec7be811ef9cab0242ac120005",
2084
- "count": 1
2085
- }
2086
- ]
2087
- },
2088
- "prompt": "xxxx\r\n\r\n\"\"\"\r\nYou 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.\r\n Here is the knowledge base:\r\n {knowledge}\r\n The above is the knowledge base.\r\n\"\"\"\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\nxxxx\n\n### Query:\nwho are you,please answer me in English\n\n### Elapsed\n - Retrieval: 332.2 ms\n - LLM: 2972.1 ms",
2089
- "id": "d8e5ebb6-6b52-4fd1-bd02-35b52ba3acaa",
2090
- "session_id": "e14344d08d1a11efb6210242ac120004"
2091
- }
2092
- }
2093
-
2094
- data:{
2095
- "code": 0,
2096
- "data": true
2097
- }
2098
- ```
2099
-
2100
- Failure:
2101
-
2102
- ```json
2103
- {
2104
- "code": 102,
2105
- "message": "Please input your question."
2106
- }
2107
- ```
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
web/src/components/api-service/chat-overview-modal/api-content.tsx CHANGED
@@ -1,8 +1,7 @@
1
  import HightLightMarkdown from '@/components/highlight-markdown';
2
  import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
 
3
  import { Button, Card, Flex, Space } from 'antd';
4
- // import apiDoc from '../../../../../api/http_api_reference.md';
5
- import apiDoc from '@parent/api/http_api_reference.md';
6
  import ChatApiKeyModal from '../chat-api-key-modal';
7
  import EmbedModal from '../embed-modal';
8
  import { usePreviewChat, useShowEmbedModal } from '../hooks';
 
1
  import HightLightMarkdown from '@/components/highlight-markdown';
2
  import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
3
+ import apiDoc from '@parent/docs/references/http_api_reference.md';
4
  import { Button, Card, Flex, Space } from 'antd';
 
 
5
  import ChatApiKeyModal from '../chat-api-key-modal';
6
  import EmbedModal from '../embed-modal';
7
  import { usePreviewChat, useShowEmbedModal } from '../hooks';