@@ -27,7 +27,7 @@ This api is based on an existing Knowledge and creates a new document through te
27
27
28
28
Request example:
29
29
30
- ``` json
30
+ ``` bash
31
31
curl --location --request POST ' https://api.dify.ai/v1/datasets/{dataset_id}/document/create_by_text' \
32
32
--header ' Authorization: Bearer {api_key}' \
33
33
--header ' Content-Type: application/json' \
@@ -77,7 +77,7 @@ curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/doc
77
77
--data-raw ' {"name": "text","text": "text","indexing_technique": "high_quality","process_rule": {"mode": "automatic"}}'
78
78
```
79
79
80
- ``` bash
80
+ ``` json
81
81
{
82
82
"document" : {
83
83
"id" : " " ,
@@ -113,7 +113,7 @@ This api is based on an existing Knowledge and creates a new document through a
113
113
114
114
Request example:
115
115
116
- ``` json
116
+ ``` bash
117
117
curl --location --request POST ' https://api.dify.ai/v1/datasets/{dataset_id}/document/create_by_file' \
118
118
--header ' Authorization: Bearer {api_key}' \
119
119
--form ' data="{"indexing_technique":"high_quality","process_rule":{"rules":{"pre_processing_rules":[{"id":"remove_extra_spaces","enabled":true},{"id":"remove_urls_emails","enabled":true}],"segmentation":{"separator":"###","max_tokens":500}},"mode":"custom"}}";type=text/plain' \
@@ -207,41 +207,203 @@ Response example:
207
207
{
208
208
"data" : [
209
209
{
210
- "id" : " " ,
211
- "name" : " name" ,
212
- "description" : " desc" ,
210
+ "id" : " eaedb485-95ac-4ffd-ab1e-18da6d676a2f" ,
211
+ "name" : " Test Knowledge Base" ,
212
+ "description" : " " ,
213
+ "provider" : " vendor" ,
213
214
"permission" : " only_me" ,
214
- "data_source_type" : " upload_file" ,
215
- "indexing_technique" : " " ,
216
- "app_count" : 2 ,
217
- "document_count" : 10 ,
218
- "word_count" : 1200 ,
219
- "created_by" : " " ,
220
- "created_at" : " " ,
221
- "updated_by" : " " ,
222
- "updated_at" : " "
223
- },
224
- ...
215
+ "data_source_type" : null ,
216
+ "indexing_technique" : null ,
217
+ "app_count" : 0 ,
218
+ "document_count" : 0 ,
219
+ "word_count" : 0 ,
220
+ "created_by" : " e99a1635-f725-4951-a99a-1daaaa76cfc6" ,
221
+ "created_at" : 1735620612 ,
222
+ "updated_by" : " e99a1635-f725-4951-a99a-1daaaa76cfc6" ,
223
+ "updated_at" : 1735620612 ,
224
+ "embedding_model" : null ,
225
+ "embedding_model_provider" : null ,
226
+ "embedding_available" : true ,
227
+ "retrieval_model_dict" : {
228
+ "search_method" : " semantic_search" ,
229
+ "reranking_enable" : false ,
230
+ "reranking_mode" : null ,
231
+ "reranking_model" : {
232
+ "reranking_provider_name" : " " ,
233
+ "reranking_model_name" : " "
234
+ },
235
+ "weights" : null ,
236
+ "top_k" : 2 ,
237
+ "score_threshold_enabled" : false ,
238
+ "score_threshold" : null
239
+ },
240
+ "tags" : [],
241
+ "doc_form" : null ,
242
+ "external_knowledge_info" : {
243
+ "external_knowledge_id" : null ,
244
+ "external_knowledge_api_id" : null ,
245
+ "external_knowledge_api_name" : null ,
246
+ "external_knowledge_api_endpoint" : null
247
+ },
248
+ "external_retrieval_model" : {
249
+ "top_k" : 2 ,
250
+ "score_threshold" : 0.0 ,
251
+ "score_threshold_enabled" : null
252
+ }
253
+ }
225
254
],
226
- "has_more" : true ,
255
+ "has_more" : false ,
227
256
"limit" : 20 ,
228
- "total" : 50 ,
257
+ "total" : 1 ,
229
258
"page" : 1
230
259
}
231
260
```
232
261
262
+ ### ** View Knowledge Base**
263
+ Get knowledge base details by knowledge base ID
264
+
265
+ ``` bash
266
+ curl --location --request GET ' https://api.dify.ai/v1/datasets/{dataset_id}' \
267
+ --header ' Authorization: Bearer {api_key}'
268
+ ```
269
+
270
+ Response example:
271
+
272
+ 输出示例:
273
+
274
+ ``` json
275
+ {
276
+ "id" : " eaedb485-95ac-4ffd-ab1e-18da6d676a2f" ,
277
+ "name" : " Test Knowledge Base" ,
278
+ "description" : " " ,
279
+ "provider" : " vendor" ,
280
+ "permission" : " only_me" ,
281
+ "data_source_type" : null ,
282
+ "indexing_technique" : null ,
283
+ "app_count" : 0 ,
284
+ "document_count" : 0 ,
285
+ "word_count" : 0 ,
286
+ "created_by" : " e99a1635-f725-4951-a99a-1daaaa76cfc6" ,
287
+ "created_at" : 1735620612 ,
288
+ "updated_by" : " e99a1635-f725-4951-a99a-1daaaa76cfc6" ,
289
+ "updated_at" : 1735620612 ,
290
+ "embedding_model" : null ,
291
+ "embedding_model_provider" : null ,
292
+ "embedding_available" : true ,
293
+ "retrieval_model_dict" : {
294
+ "search_method" : " semantic_search" ,
295
+ "reranking_enable" : false ,
296
+ "reranking_mode" : null ,
297
+ "reranking_model" : {
298
+ "reranking_provider_name" : " " ,
299
+ "reranking_model_name" : " "
300
+ },
301
+ "weights" : null ,
302
+ "top_k" : 2 ,
303
+ "score_threshold_enabled" : false ,
304
+ "score_threshold" : null
305
+ },
306
+ "tags" : [],
307
+ "doc_form" : null ,
308
+ "external_knowledge_info" : {
309
+ "external_knowledge_id" : null ,
310
+ "external_knowledge_api_id" : null ,
311
+ "external_knowledge_api_name" : null ,
312
+ "external_knowledge_api_endpoint" : null
313
+ },
314
+ "external_retrieval_model" : {
315
+ "top_k" : 2 ,
316
+ "score_threshold" : 0.0 ,
317
+ "score_threshold_enabled" : null
318
+ }
319
+ }
320
+ ```
321
+
322
+ ### ** Update Knowledge Base**
323
+ Update a knowledge base by knowledge base ID
324
+
325
+ ``` bash
326
+ curl --location --request POST ' https://api.dify.ai/v1/datasets/{dataset_id}' \
327
+ --header ' Authorization: Bearer {api_key}' \
328
+ --header ' Content-Type: application/json' \
329
+ --data-raw ' {"name": "Test Knowledge Base", "indexing_technique": "high_quality", "permission": "only_me",' \
330
+ " embedding_model_provider" : " zhipuai" , " embedding_model" : " embedding-3" , " retrieval_model" : " " , " partial_member_list" : []}'
331
+ ```
332
+
333
+ Parameters:
334
+ - indexing_technique: high_quality, economy, None
335
+ - permission: only_me, all_team_members, partial_members (this partial_members option specifies team members)
336
+ - embedding_model_provider: specified embedding model provider, must be set up in the system first, corresponding to the provider field
337
+ - embedding_model: specified embedding model, corresponding to the model field
338
+ - retrieval_model: specified retrieval model, corresponding to the model field
339
+
340
+ The provider and model name of the embedding model can be obtained through the following interface:
341
+ v1/workspaces/current/models/model-types/text-embedding. For specific instructions, see the following text.
342
+ The Authorization used is the Dataset API Token.
343
+
344
+ Response example:
345
+
346
+ ```json
347
+ {
348
+ "id": "eaedb485-95ac-4ffd-ab1e-18da6d676a2f",
349
+ "name": "Test Knowledge Base",
350
+ "description": "",
351
+ "provider": "vendor",
352
+ "permission": "only_me",
353
+ "data_source_type": null,
354
+ "indexing_technique": "high_quality",
355
+ "app_count": 0,
356
+ "document_count": 0,
357
+ "word_count": 0,
358
+ "created_by": "e99a1635-f725-4951-a99a-1daaaa76cfc6",
359
+ "created_at": 1735620612,
360
+ "updated_by": "e99a1635-f725-4951-a99a-1daaaa76cfc6",
361
+ "updated_at": 1735622679,
362
+ "embedding_model": "embedding-3",
363
+ "embedding_model_provider": "zhipuai",
364
+ "embedding_available": null,
365
+ "retrieval_model_dict": {
366
+ "search_method": "semantic_search",
367
+ "reranking_enable": false,
368
+ "reranking_mode": null,
369
+ "reranking_model": {
370
+ "reranking_provider_name": "",
371
+ "reranking_model_name": ""
372
+ },
373
+ "weights": null,
374
+ "top_k": 2,
375
+ "score_threshold_enabled": false,
376
+ "score_threshold": null
377
+ },
378
+ "tags": [],
379
+ "doc_form": null,
380
+ "external_knowledge_info": {
381
+ "external_knowledge_id": null,
382
+ "external_knowledge_api_id": null,
383
+ "external_knowledge_api_name": null,
384
+ "external_knowledge_api_endpoint": null
385
+ },
386
+ "external_retrieval_model": {
387
+ "top_k": 2,
388
+ "score_threshold": 0.0,
389
+ "score_threshold_enabled": null
390
+ },
391
+ "partial_member_list": []
392
+ }
393
+ ```
394
+
233
395
### Delete a knowledge base
234
396
235
397
Request example:
236
398
237
- ``` json
399
+ ```bash
238
400
curl --location --request DELETE ' https://api.dify.ai/v1/datasets/{dataset_id}' \
239
401
--header ' Authorization: Bearer {api_key}'
240
402
```
241
403
242
404
Response example:
243
405
244
- ``` json
406
+ ```
245
407
204 No Content
246
408
```
247
409
@@ -413,7 +575,7 @@ Response example:
413
575
"disabled_at" : null ,
414
576
"disabled_by" : null ,
415
577
"archived" : false
416
- },
578
+ }
417
579
],
418
580
"has_more" : false ,
419
581
"limit" : 20 ,
@@ -654,6 +816,89 @@ Response example:
654
816
}
655
817
```
656
818
819
+ ### Get available embedding models
820
+
821
+ ``` bash
822
+ curl --location --request GET ' http://localhost:5001/v1/workspaces/current/models/model-types/text-embedding' \
823
+ --header ' Authorization: Bearer {api_key}' \
824
+ --header ' Content-Type: application/json'
825
+ ```
826
+
827
+ Response example:
828
+
829
+ ``` json
830
+ {
831
+ "data" : [
832
+ {
833
+ "provider" : " zhipuai" ,
834
+ "label" : {
835
+ "zh_Hans" : " 智谱 AI" ,
836
+ "en_US" : " ZHIPU AI"
837
+ },
838
+ "icon_small" : {
839
+ "zh_Hans" : " http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_small/zh_Hans" ,
840
+ "en_US" : " http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_small/en_US"
841
+ },
842
+ "icon_large" : {
843
+ "zh_Hans" : " http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_large/zh_Hans" ,
844
+ "en_US" : " http://127.0.0.1:5001/console/api/workspaces/current/model-providers/zhipuai/icon_large/en_US"
845
+ },
846
+ "status" : " active" ,
847
+ "models" : [
848
+ {
849
+ "model" : " embedding-3" ,
850
+ "label" : {
851
+ "zh_Hans" : " embedding-3" ,
852
+ "en_US" : " embedding-3"
853
+ },
854
+ "model_type" : " text-embedding" ,
855
+ "features" : null ,
856
+ "fetch_from" : " predefined-model" ,
857
+ "model_properties" : {
858
+ "context_size" : 8192
859
+ },
860
+ "deprecated" : false ,
861
+ "status" : " active" ,
862
+ "load_balancing_enabled" : false
863
+ },
864
+ {
865
+ "model" : " embedding-2" ,
866
+ "label" : {
867
+ "zh_Hans" : " embedding-2" ,
868
+ "en_US" : " embedding-2"
869
+ },
870
+ "model_type" : " text-embedding" ,
871
+ "features" : null ,
872
+ "fetch_from" : " predefined-model" ,
873
+ "model_properties" : {
874
+ "context_size" : 8192
875
+ },
876
+ "deprecated" : false ,
877
+ "status" : " active" ,
878
+ "load_balancing_enabled" : false
879
+ },
880
+ {
881
+ "model" : " text_embedding" ,
882
+ "label" : {
883
+ "zh_Hans" : " text_embedding" ,
884
+ "en_US" : " text_embedding"
885
+ },
886
+ "model_type" : " text-embedding" ,
887
+ "features" : null ,
888
+ "fetch_from" : " predefined-model" ,
889
+ "model_properties" : {
890
+ "context_size" : 512
891
+ },
892
+ "deprecated" : false ,
893
+ "status" : " active" ,
894
+ "load_balancing_enabled" : false
895
+ }
896
+ ]
897
+ }
898
+ ]
899
+ }
900
+ ```
901
+
657
902
### Error message
658
903
659
904
Response example:
0 commit comments