学生成绩查询工作流(带数据库查询)
本工作流主要介绍使用dify工作流和数据库查询整合的案例
工作流图谱
YAML 源码
app:
description: 本工作流主要介绍使用dify工作流和数据库查询整合的案例
icon: 🤖
icon_background: '#FFEAD5'
mode: advanced-chat
name: 学生成绩查询工作流(带数据库查询)
use_icon_as_answer_icon: false
kind: app
version: 0.1.5
workflow:
conversation_variables:
- description: 分页数量,最多显示多少行
id: 1d7aa0ed-014b-4644-9584-45b3c99e439e
name: limit
selector:
- conversation
- limit
value: '3'
value_type: string
- description: 1数据库存储的课程号
id: ac259667-58b4-40d3-97e0-a028b2663ed1
name: course_id
selector:
- conversation
- course_id
value: '1'
value_type: string
- description: 1001 是张三这个人额学生证ID
id: 1099b85c-c730-4027-8696-0cf815f898d4
name: student_id
selector:
- conversation
- student_id
value: '1001'
value_type: string
environment_variables:
- description: ''
id: cb0405e3-18ea-44c7-91e0-293c4fd5fb38
name: base_url
selector:
- env
- base_url
value: http://127.0.0.1:9090/
value_type: string
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:
sourceType: start
targetType: llm
id: 1740632143521-llm
source: '1740632143521'
sourceHandle: source
target: llm
targetHandle: target
type: custom
- data:
isInIteration: false
sourceType: llm
targetType: if-else
id: llm-source-1740634251160-target
source: llm
sourceHandle: source
target: '1740634251160'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: if-else
targetType: answer
id: 1740634251160-false-1740634312789-target
selected: false
source: '1740634251160'
sourceHandle: 'false'
target: '1740634312789'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: if-else
targetType: code
id: 1740634251160-true-1740636026594-target
source: '1740634251160'
sourceHandle: 'true'
target: '1740636026594'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: if-else
targetType: answer
id: 1740634251160-060040ea-2780-45b2-9d82-43b4a348a99d-1740634312789-target
source: '1740634251160'
sourceHandle: 060040ea-2780-45b2-9d82-43b4a348a99d
target: '1740634312789'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: code
targetType: tool
id: 1740636026594-source-1740640600640-target
source: '1740636026594'
sourceHandle: source
target: '1740640600640'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: tool
targetType: answer
id: 1740640600640-source-1740634495719-target
source: '1740640600640'
sourceHandle: source
target: '1740634495719'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: if-else
targetType: code
id: 1740634251160-f0a6872e-7639-4bcf-9f57-42b8405e7db2-1740645177116-target
source: '1740634251160'
sourceHandle: f0a6872e-7639-4bcf-9f57-42b8405e7db2
target: '1740645177116'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: code
targetType: answer
id: 1740645177116-source-1740646969095-target
source: '1740645177116'
sourceHandle: source
target: '1740646969095'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: if-else
targetType: code
id: 1740634251160-acff276c-b01d-4caf-a41c-5c5b56c44016-1740647348150-target
source: '1740634251160'
sourceHandle: acff276c-b01d-4caf-a41c-5c5b56c44016
target: '1740647348150'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: code
targetType: answer
id: 1740647348150-source-1740647528305-target
source: '1740647348150'
sourceHandle: source
target: '1740647528305'
targetHandle: target
type: custom
zIndex: 0
nodes:
- data:
desc: ''
selected: false
title: 开始
type: start
variables: []
height: 52
id: '1740632143521'
position:
x: 44.39035099509192
y: 556.9218300469233
positionAbsolute:
x: 44.39035099509192
y: 556.9218300469233
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
- data:
context:
enabled: false
variable_selector: []
desc: ''
model:
completion_params:
temperature: 0.1
mode: chat
name: internlm3-8b-instruct
provider: openai_api_compatible
prompt_template:
- id: 8da3ae0f-97ad-4be4-b912-f8fd54d62f46
role: system
text: '# Role: 教学考试系统查询专家
# Goal: 根据用户输入的信息,提取关键信息,并将查询归类到以下类别,并只返回类别编号:
# - 学生成绩 (类别编号: 1)
# - 平均分 (类别编号: 2)
# - 课程的排名 (类别编号: 3)
# - 查询不到 (类别编号: 0)
# Constraints:
- 1. 只能从用户输入中提取信息。
- 2. 必须将查询归类到预定义的类别。
- 3. 输出必须只包含类别编号。
- 4. 如果查询无法归类到 1, 2, 3,则返回 0。
## Output Format
{{category_number}}
# Examples:
## 学生成绩类 (类别编号: 1):
- 查询学生成绩
- 查询"张三"程序
- 查询该班级所有学生成绩
## 平均分 (类别编号: 2):
- 查询班级平均分
- 查询某个人平均成绩
## 课程的排名 (类别编号: 3):
- 查询课程的排名
- 查询数学课程排名
## 查询不到 (类别编号: 0):
- 无法识别的查询
# 用户输入:
{{user_input}}
# 分析结果:
{{category_number}}'
- role: user
text: 请根据用户输入提示词{{#sys.query#}}进行判断
selected: false
title: LLM
type: llm
variables: []
vision:
enabled: false
height: 96
id: llm
position:
x: 366.21561974003555
y: 522.0779561943804
positionAbsolute:
x: 366.21561974003555
y: 522.0779561943804
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
- data:
cases:
- case_id: 'true'
conditions:
- comparison_operator: contains
id: c0016bf9-a7cd-4b2c-9d8f-14fc5661977c
value: '1'
varType: string
variable_selector:
- llm
- text
id: 'true'
logical_operator: and
- case_id: f0a6872e-7639-4bcf-9f57-42b8405e7db2
conditions:
- comparison_operator: contains
id: 818a5c0f-21dc-4b13-9893-43572d726bca
value: '2'
varType: string
variable_selector:
- llm
- text
id: f0a6872e-7639-4bcf-9f57-42b8405e7db2
logical_operator: and
- case_id: acff276c-b01d-4caf-a41c-5c5b56c44016
conditions:
- comparison_operator: contains
id: 46a1f566-1cdc-4510-a1fd-8888ed09ad63
value: '3'
varType: string
variable_selector:
- llm
- text
id: acff276c-b01d-4caf-a41c-5c5b56c44016
logical_operator: and
- case_id: 060040ea-2780-45b2-9d82-43b4a348a99d
conditions:
- comparison_operator: contains
id: 07eeecbb-0f2d-4cf4-a57d-ab6f9bf04e5a
value: '0'
varType: string
variable_selector:
- llm
- text
id: 060040ea-2780-45b2-9d82-43b4a348a99d
logical_operator: and
desc: ''
selected: false
title: 条件分支
type: if-else
height: 268
id: '1740634251160'
position:
x: 680
y: 424
positionAbsolute:
x: 680
y: 424
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
- data:
answer: 没有查询到学习系统相关接口信息,请重新输入。
desc: ''
selected: false
title: 未获取信息回复
type: answer
variables: []
height: 114
id: '1740634312789'
position:
x: 1083.8215646551178
y: 747.0254706110104
positionAbsolute:
x: 1083.8215646551178
y: 747.0254706110104
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 242
- data:
answer: '{{#1740640600640.files#}}'
desc: ''
selected: false
title: 学生成绩接口回复
type: answer
variables: []
height: 101
id: '...(过长已截断)