This repository was archived by the owner on Dec 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexternal_knowledge_base.en.yaml
More file actions
185 lines (184 loc) · 6.71 KB
/
external_knowledge_base.en.yaml
File metadata and controls
185 lines (184 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
openapi: 3.0.0
info:
title: Dify External Knowledge API
description: |
This API is used to connect to a knowledge base that is independent of Dify and maintained by developers. Users can use this schema to generate server-side code for their own implementation.
For more details, please refer to "External Knowledge API" documentation (https://docs.dify.ai/guides/knowledge-base/external-knowledge-api-documentation).
version: 1.3.1
servers:
- url: '{baseUrl}'
variables:
baseUrl:
default: 'https://your-endpoint'
description: External Knowledge API Server URL
security:
- bearerApiKeyAuth: []
paths:
/retrieval:
post:
summary: Retrieve Knowledge Content
description: Retrieve relevant content from external knowledge base based on user query
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- knowledge_id
- query
- retrieval_setting
properties:
knowledge_id:
type: string
description: Your knowledge's unique ID
example: AAA-BBB-CCC
query:
type: string
description: User's query
example: What is Dify?
retrieval_setting:
type: object
required:
- top_k
- score_threshold
properties:
top_k:
type: integer
description: Maximum number of retrieved results
example: 5
score_threshold:
type: number
description: 'The score limit of relevance of the result to the query, scope: 0~1'
minimum: 0
maximum: 1
example: 0.5
description: Knowledge's retrieval parameters
metadata_condition:
type: object
description: Original array filtering
properties:
logical_operator:
type: string
description: 'Logical operator, values can be ''and'' or ''or'', default is ''and'''
enum:
- and
- or
example: and
conditions:
type: array
description: List of conditions
items:
type: object
required:
- name
- comparison_operator
properties:
name:
type: array
items:
type: string
description: Names of the metadata to filter
example:
- category
- tag
comparison_operator:
type: string
description: Comparison operator
enum:
- contains
- not contains
- start with
- end with
- is
- is not
- empty
- not empty
- '='
- ≠
- '>'
- <
- ≥
- ≤
- before
- after
example: contains
value:
type: string
description: 'Comparison value, can be omitted when the operator is ''empty'', ''not empty'', ''null'', or ''not null'''
example: AI
responses:
'200':
description: Successfully retrieved results
content:
application/json:
schema:
type: object
required:
- records
properties:
records:
type: array
items:
type: object
required:
- content
- score
- title
properties:
content:
type: string
description: Contains a chunk of text from a data source in the knowledge base
example: 'Dify:The Innovation Engine for GenAI Applications'
score:
type: number
description: 'The score of relevance of the result to the query, scope: 0~1'
minimum: 0
maximum: 1
example: 0.5
title:
type: string
description: Document title
example: Dify Introduction
metadata:
type: object
description: Contains metadata attributes and their values for the document in the data source
example:
path: 's3://dify/knowledge.txt'
description: dify knowledge document
'403':
description: Access denied
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
securitySchemes:
bearerApiKeyAuth:
type: http
scheme: bearer
schemas:
Error:
type: object
required:
- error_code
- error_msg
properties:
error_code:
type: integer
description: Error code
enum:
- 1001
- 1002
- 2001
example: 1001
error_msg:
type: string
description: The description of API exception
example: Invalid Authorization header format. Expected 'Bearer ' format.