-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_data_analysis.yml
More file actions
170 lines (155 loc) · 3.98 KB
/
Copy pathai_data_analysis.yml
File metadata and controls
170 lines (155 loc) · 3.98 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
version: 0.5.0
kind: app
app:
name: AI 智能问数
mode: workflow
icon: 📊
icon_background: '#FFEAD5'
description: 将自然语言转换为 SQL 查询并分析数据结果
use_icon_as_answer_icon: false
workflow:
graph:
nodes:
- id: start
position:
x: 100
y: 300
width: 244
height: 54
data:
type: start
title: Start
desc: ''
variables:
- variable: query
type: string
label: 数据问题
required: true
max_length: 256
default: ''
options: []
- variable: table_schema
type: string
label: 表结构
required: false
max_length: 256
default: CREATE TABLE sales (date DATE, amount DECIMAL, region VARCHAR)
options: []
- id: d7579be0
position:
x: 400
y: 100
width: 244
height: 54
data:
type: llm
title: 生成SQL
desc: ''
model:
provider: openai
name: gpt-4
mode: chat
completion_params:
temperature: 0.7
max_tokens: 4096
prompt_template:
- role: user
text: '你是一个数据分析师。根据以下表结构,将用户问题转换为 SQL 查询语句。
表结构:
{{#start.table_schema#}}
用户问题:
{{#start.query#}}
请只输出 SQL 语句,不要包含其他解释。'
- id: f3dc8e41
position:
x: 700
y: 100
width: 244
height: 54
data:
type: code
title: 执行查询
desc: ''
code_language: python3
code: "def main(args):\n sql = args.get(\"sql\")\n # 这里模拟数据库返回结果\n \
\ # 实际项目中,这里会连接数据库执行 SQL\n print(f\"Executing: {sql}\")\n \n \
\ mock_data = [\n {\"date\": \"2024-01-01\", \"amount\": 1000, \"\
region\": \"North\"},\n {\"date\": \"2024-01-02\", \"amount\": 1500,\
\ \"region\": \"South\"}\n ]\n \n return {\n \"result\"\
: mock_data,\n \"status\": \"success\"\n }\n"
variables:
- variable: sql
value_selector:
- 生成SQL
- text
outputs:
- variable: result
type: array-object
- id: 70e52fd5
position:
x: 100
y: 300
width: 244
height: 54
data:
type: llm
title: 分析结果
desc: ''
model:
provider: openai
name: gpt-4
mode: chat
completion_params:
temperature: 0.7
max_tokens: 4096
prompt_template:
- role: user
text: '根据执行的 SQL 和数据结果,回答用户的问题。
问题:{{#start.query#}}
SQL:{{#生成SQL.text#}}
数据结果:
{{#执行查询.result#}}
请用通俗易懂的语言总结数据洞察。'
- id: 743de7ae
position:
x: 400
y: 300
width: 244
height: 54
data:
type: end
title: End
desc: ''
outputs:
- variable: answer
value_selector:
- 分析结果
- text
- variable: sql
value_selector:
- 生成SQL
- text
edges:
- id: edge_0
source: start
target: d7579be0
sourceHandle: source
targetHandle: target
- id: edge_1
source: d7579be0
target: f3dc8e41
sourceHandle: source
targetHandle: target
- id: edge_2
source: f3dc8e41
target: 70e52fd5
sourceHandle: source
targetHandle: target
- id: edge_3
source: 70e52fd5
target: 743de7ae
sourceHandle: source
targetHandle: target
features: {}
environment_variables: []
conversation_variables: []