-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDB-reader.yml
326 lines (319 loc) · 9.04 KB
/
DB-reader.yml
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
app:
description: ''
icon: 🤖
icon_background: '#FFEAD5'
mode: workflow
name: DB-reader
use_icon_as_answer_icon: false
kind: app
version: 0.1.3
workflow:
conversation_variables: []
environment_variables: []
features:
file_upload:
allowed_file_extensions:
- .JPG
- .JPEG
- .PNG
- .GIF
- .WEBP
- .SVG
allowed_file_types:
- image
allowed_file_upload_methods:
- local_file
- remote_url
enabled: false
fileUploadConfig:
audio_file_size_limit: 50
batch_count_limit: 5
file_size_limit: 15
image_file_size_limit: 10
video_file_size_limit: 100
workflow_file_upload_limit: 10
image:
enabled: false
number_limits: 3
transfer_methods:
- local_file
- remote_url
number_limits: 3
opening_statement: ''
retriever_resource:
enabled: true
sensitive_word_avoidance:
enabled: false
speech_to_text:
enabled: false
suggested_questions: []
suggested_questions_after_answer:
enabled: false
text_to_speech:
enabled: false
language: ''
voice: ''
graph:
edges:
- data:
isInIteration: false
sourceType: llm
targetType: code
id: 1732980872194-source-1732980912700-target
source: '1732980872194'
sourceHandle: source
target: '1732980912700'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: code
targetType: llm
id: 1732980912700-source-1732980920612-target
source: '1732980912700'
sourceHandle: source
target: '1732980920612'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: llm
targetType: end
id: 1732980920612-source-1732980940056-target
source: '1732980920612'
sourceHandle: source
target: '1732980940056'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: start
targetType: knowledge-retrieval
id: 1732970305758-source-1733132854491-target
source: '1732970305758'
sourceHandle: source
target: '1733132854491'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: knowledge-retrieval
targetType: llm
id: 1733132854491-source-1732980872194-target
source: '1733132854491'
sourceHandle: source
target: '1732980872194'
targetHandle: target
type: custom
zIndex: 0
nodes:
- data:
desc: ''
selected: false
title: 开始
type: start
variables:
- label: 请输入您的查询需求
max_length: 200
options: []
required: true
type: text-input
variable: question
height: 90
id: '1732970305758'
position:
x: -200.45867167179856
y: 203.94580912716032
positionAbsolute:
x: -200.45867167179856
y: 203.94580912716032
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
context:
enabled: true
variable_selector:
- '1733132854491'
- result
desc: ''
model:
completion_params:
temperature: 0.7
mode: chat
name: Qwen2:7b
provider: ollama
prompt_template:
- id: ab2999ee-62f7-4b4d-a230-b6dd043e7aad
role: system
text: '请作为一个数据库管理员,理解用户的具体需求,并生成对应的SQL。其中,数据库表名和字段名信息通过查阅{{#context#}}知识库获得。生成的结果只包含可以运行的SQL,不需要解释。 '
- id: 832946d2-761c-49dd-9136-9f6d3ec1a946
role: user
text: '问题: {{#1732970305758.question#}}
'
- id: 64acd278-efbf-46bd-a7b7-2a4d5cfaa78b
role: assistant
text: ''
selected: false
title: LLM自动生成SQL
type: llm
variables: []
vision:
enabled: false
height: 98
id: '1732980872194'
position:
x: 29.290583767340934
y: 499.3999411044708
positionAbsolute:
x: 29.290583767340934
y: 499.3999411044708
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
code: "import urllib.request\nimport json\n\ndef main(sql_query: str) -> dict:\n\
\ # Flask 服务端点\n api_url = \"http://192.168.10.219:5003/execute_query\"\
\n\n # 请求体\n payload = {\n \"sql_query\": sql_query\n }\n\
\n # 将查询参数进行 URL 编码\n encoded_params = urllib.parse.urlencode(payload)\n\
\n # 创造请求对象, 拼接完整的 URL\n req = f\"{api_url}?{encoded_params}\"\n\n\
\ try:\n # 发送请求并获取响应\n with urllib.request.urlopen(req)\
\ as response:\n # 读取并解码响应\n result_data = json.loads(response.read().decode('utf-8'))\n\
\ # 将结果转换为字符串格式\n result_str = json.dumps(result_data,\
\ ensure_ascii=False) # 确保中文字符正常显示\n print(result_str)\n \
\ return {\n 'result': result_str # 返回字符串类型结果\n \
\ }\n except Exception as e:\n raise Exception(f\"Error:{str(e)}\"\
)\n"
code_language: python3
desc: ''
outputs:
result:
children: null
type: string
selected: false
title: 执行SQL
type: code
variables:
- value_selector:
- '1732980872194'
- text
variable: sql_query
height: 54
id: '1732980912700'
position:
x: 149.1166163724659
y: 652.6699088065056
positionAbsolute:
x: 149.1166163724659
y: 652.6699088065056
selected: true
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
context:
enabled: true
variable_selector:
- '1733132854491'
- result
desc: ''
model:
completion_params:
temperature: 0.7
mode: chat
name: Qwen2:7b
provider: ollama
prompt_template:
- id: bf2cad29-b645-4416-9799-06dd56c5ce86
role: system
text: '你是数据分析师,请分析JSON格式的SQL查询放回结果,回答用户的问题
'
- id: bef9db8e-1608-4e8f-abdd-eed980fc1b6b
role: user
text: '问题是:{{#1732970305758.question#}}
SQL是: {{#1732980872194.text#}}
数据是:{{#1732980912700.result#}}
请在结果中按照模板中的三个步骤回答问题:(1)具体执行的SQL是{{#1732980872194.text#}},(2):SQL返回的结果是{{#1732980912700.result#}},(3)然后回复问题的答案,尽可能简短。'
selected: false
title: LLM结果分析
type: llm
variables: []
vision:
enabled: false
height: 98
id: '1732980920612'
position:
x: 293.86542871638255
y: 744.8910559846614
positionAbsolute:
x: 293.86542871638255
y: 744.8910559846614
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
desc: ''
outputs:
- value_selector:
- '1732980920612'
- text
variable: text
selected: false
title: 结束
type: end
height: 90
id: '1732980940056'
position:
x: 437.35951722392167
y: 873.9731111688593
positionAbsolute:
x: 437.35951722392167
y: 873.9731111688593
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
dataset_ids:
- 3ad8b24f-fd2b-4d3b-bd38-ff60039097ed
desc: ''
multiple_retrieval_config:
reranking_enable: false
reranking_mode: reranking_model
top_k: 4
query_variable_selector:
- '1732970305758'
- question
retrieval_mode: multiple
selected: false
title: 知识检索
type: knowledge-retrieval
height: 92
id: '1733132854491'
position:
x: -88.20604288351262
y: 352.9945268220258
positionAbsolute:
x: -88.20604288351262
y: 352.9945268220258
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
viewport:
x: 398.636722585323
y: 114.5359283321757
zoom: 0.39931970501408437