From c8da97fbc5a74ac891a25b6393db7799fa6ec229 Mon Sep 17 00:00:00 2001
From: alever_sn <759636538@qq.com>
Date: Thu, 12 Feb 2026 13:21:59 +0800
Subject: [PATCH] [update] Update promptInfo and var_keyword.
---
frontend/src/axios/api.js | 61 ++++++++++-
frontend/src/axios/model.js | 100 +++++++++++++++++-
.../mainFlow/nodes/operatorNode/index.vue | 87 ++++++++++++---
.../{valueInput.vue => valueInput/index.vue} | 8 ++
.../nodes/operatorNode/valueInput/kvInput.vue | 87 +++++++++++++++
.../manage/mainFlow/pipeline/index.vue | 3 +-
frontend/src/stores/dataflow.js | 15 +++
frontend/src/views/manage/dataflow/index.vue | 9 ++
8 files changed, 349 insertions(+), 21 deletions(-)
rename frontend/src/components/manage/mainFlow/nodes/operatorNode/{valueInput.vue => valueInput/index.vue} (93%)
create mode 100644 frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/kvInput.vue
diff --git a/frontend/src/axios/api.js b/frontend/src/axios/api.js
index f9b58dd..6dd7172 100644
--- a/frontend/src/axios/api.js
+++ b/frontend/src/axios/api.js
@@ -998,7 +998,7 @@ export class tasks {
}
/**
- * @summary 下载任务执行结果文件
+ * @summary 下载任务执行结果文件,step从0开始计数,想请求第一个算子传step=0
* @param {String} [pathtask_id]
* @param {Number} [step]
* @param {CancelTokenSource} [cancelSource] Axios Cancel Source 对象,可以取消该请求
@@ -1729,6 +1729,57 @@ export class prompts {
})
}
+ /**
+ * @summary 根据 Prompt 名称获取 Prompt 信息
+ * @param {String} [pathprompt_name]
+ * @param {CancelTokenSource} [cancelSource] Axios Cancel Source 对象,可以取消该请求
+ * @param {Function} [uploadProgress] 上传回调函数
+ * @param {Function} [downloadProgress] 下载回调函数
+ */
+ static async get_prompt_info_api_v1_prompts_prompt_info__prompt_name__get(pathprompt_name,cancelSource,uploadProgress,downloadProgress){
+ return await new Promise((resolve,reject)=>{
+ let responseType = "json";
+ let options = {
+ method:'get',
+ url:'/api/v1/prompts/prompt-info/'+pathprompt_name+'',
+ data:{},
+ params:{},
+ headers:{
+ "Content-Type":""
+ },
+ onUploadProgress:uploadProgress,
+ onDownloadProgress:downloadProgress
+ }
+ // support wechat mini program
+ if (cancelSource!=undefined){
+ options.cancelToken = cancelSource.token
+ }
+ if (responseType != "json"){
+ options.responseType = responseType;
+ }
+ axios(options)
+ .then(res=>{
+ if (res.config.responseType=="blob"){
+ resolve(new Blob([res.data],{
+ type: res.headers["content-type"].split(";")[0]
+ }))
+ }else{
+ resolve(res.data);
+ return res.data
+ }
+ }).catch(err=>{
+ if (err.response){
+ if (err.response.data)
+ reject(err.response.data)
+ else
+ reject(err.response);
+ }else{
+ reject(err)
+ }
+ })
+ })
+ }
+
/**
* @summary 根据算子名称获取对应的 Prompt 列表
* @param {String} [pathoperator_name]
@@ -1850,6 +1901,14 @@ prompts.get_prompt_info_api_v1_prompts_prompt_info_get.fullPath=`${axios.default
*/
prompts.get_prompt_info_api_v1_prompts_prompt_info_get.path=`/api/v1/prompts/prompt-info`
/**
+* @description get_prompt_info_api_v1_prompts_prompt_info__prompt_name__get url链接,包含baseURL
+*/
+prompts.get_prompt_info_api_v1_prompts_prompt_info__prompt_name__get.fullPath=`${axios.defaults.baseURL}/api/v1/prompts/prompt-info/{prompt_name}`
+/**
+* @description get_prompt_info_api_v1_prompts_prompt_info__prompt_name__get url链接,不包含baseURL
+*/
+prompts.get_prompt_info_api_v1_prompts_prompt_info__prompt_name__get.path=`/api/v1/prompts/prompt-info/{prompt_name}`
+/**
* @description get_prompts_api_v1_prompts__operator_name__get url链接,包含baseURL
*/
prompts.get_prompts_api_v1_prompts__operator_name__get.fullPath=`${axios.defaults.baseURL}/api/v1/prompts/{operator_name}`
diff --git a/frontend/src/axios/model.js b/frontend/src/axios/model.js
index b5ffd59..e76b5f3 100644
--- a/frontend/src/axios/model.js
+++ b/frontend/src/axios/model.js
@@ -591,6 +591,39 @@ export class ApiResponse_PromptInfoMapOut_ {
*/
message=undefined
+}
+export class ApiResponse_PromptInfoOut_ {
+
+ /**
+ *
+ * @param {undefined} success
+ * @param {Number} code 业务错误码,0 表示成功
+ * @param {String} message
+ */
+ constructor(success = undefined,code = undefined,message = undefined,data = undefined,meta = undefined){
+ this.success = success
+ this.code = code
+ this.message = message
+ this.data = data
+ this.meta = meta
+ }
+
+ /**
+ *
+ * @type {undefined}
+ */
+ success=undefined
+ /**
+ * 业务错误码,0 表示成功
+ * @type {Number}
+ */
+ code=undefined
+ /**
+ *
+ * @type {String}
+ */
+ message=undefined
+
}
export class ApiResponse_PromptSourceOut_ {
@@ -1567,12 +1600,16 @@ export class PromptInfoOut {
* @param {String} class_str
* @param {String} primary_type
* @param {String} secondary_type
+ * @param {String} description
+ * @param {PromptParameterGroupsSchema} parameter
*/
- constructor(operator = undefined,class_str = undefined,primary_type = undefined,secondary_type = undefined){
+ constructor(operator = undefined,class_str = undefined,primary_type = undefined,secondary_type = undefined,description = undefined,parameter = undefined){
this.operator = operator
this.class_str = class_str
this.primary_type = primary_type
this.secondary_type = secondary_type
+ this.description = description
+ this.parameter = parameter
}
/**
@@ -1594,7 +1631,66 @@ export class PromptInfoOut {
*
* @type {String}
*/
- secondary_type=undefined
+ secondary_type=undefined
+ /**
+ *
+ * @type {String}
+ */
+ description=undefined
+ /**
+ *
+ * @type {PromptParameterGroupsSchema}
+ */
+ parameter=undefined
+
+}
+export class PromptParameterGroupsSchema {
+
+ /**
+ *
+ * @param {Array} init
+ * @param {Array} build_prompt
+ */
+ constructor(init = undefined,build_prompt = undefined){
+ this.init = init
+ this.build_prompt = build_prompt
+ }
+
+ /**
+ *
+ * @type {Array}
+ */
+ init=undefined
+ /**
+ *
+ * @type {Array}
+ */
+ build_prompt=undefined
+
+}
+export class PromptParameterSchema {
+
+ /**
+ *
+ * @param {String} name
+ * @param {String} kind
+ */
+ constructor(name = undefined,default_value = undefined,kind = undefined){
+ this.name = name
+ this.default_value = default_value
+ this.kind = kind
+ }
+
+ /**
+ *
+ * @type {String}
+ */
+ name=undefined
+ /**
+ *
+ * @type {String}
+ */
+ kind=undefined
}
export class PromptSourceOut {
diff --git a/frontend/src/components/manage/mainFlow/nodes/operatorNode/index.vue b/frontend/src/components/manage/mainFlow/nodes/operatorNode/index.vue
index f99f0fb..82655aa 100644
--- a/frontend/src/components/manage/mainFlow/nodes/operatorNode/index.vue
+++ b/frontend/src/components/manage/mainFlow/nodes/operatorNode/index.vue
@@ -7,7 +7,7 @@
{{
appConfig.local('Init. Parameters')
- }}
+ }}
@@ -16,6 +16,9 @@
:options="allowedPrompts" :choosen-slider-background="thisData.borderColor"
:reveal-background-color="[thisData.shadowColor, 'rgba(255, 255, 255, 1)']"
:reveal-border-color="thisData.borderColor" border-radius="8" style="width: 100%">
+ {{ appConfig.local('Prompt Parameters')
+ }}
+
@@ -26,7 +29,7 @@
{{
appConfig.local('Run Parameters')
- }}
+ }}
-
+
@@ -70,7 +70,8 @@ import { useTheme } from '@/stores/theme'
import { Position, Handle } from '@vue-flow/core'
import baseNode from '@/components/manage/mainFlow/nodes/baseNode.vue'
-import valueInput from './valueInput.vue'
+import valueInput from './valueInput/index.vue'
+import kvInput from './valueInput/kvInput.vue'
const { $api } = useGlobal()
@@ -148,6 +149,11 @@ const promptTemplateModel = computed({
(item) => item.name === 'prompt_template'
)
if (!prompt_template.value) return {}
+ if (typeof (prompt_template.value) === 'object')
+ return {
+ key: prompt_template.value.cls_name,
+ text: prompt_template.value.cls_name
+ }
return {
key: prompt_template.value,
text: prompt_template.value
@@ -158,11 +164,45 @@ const promptTemplateModel = computed({
},
set(val) {
if (!val.key) return
+ if (val.key === promptTemplateModel.value.key) return
if (thisData.value.operatorParams.init) {
let prompt_template = thisData.value.operatorParams.init.find(
(item) => item.name === 'prompt_template'
)
- prompt_template.value = val.key
+ let promptInfo = dataflow.promptInfo[val.key]
+ let promptParams = []
+ if (promptInfo && promptInfo.parameter.init)
+ promptParams = promptInfo.parameter.init
+ promptParams.forEach((param) => {
+ param.value = param.default_value || ''
+ })
+ prompt_template.value = {
+ cls_name: val.key,
+ params: promptParams
+ }
+ }
+ }
+})
+const promptParamModel = computed({
+ get() {
+ try {
+ let prompt_template = thisData.value.operatorParams.init.find(
+ (item) => item.name === 'prompt_template'
+ )
+ if (!prompt_template.value) return {}
+ if (typeof (prompt_template.value) === 'object')
+ return prompt_template.value.params
+ return []
+ } catch (error) {
+ return []
+ }
+ },
+ set(val) {
+ if (thisData.value.operatorParams.init) {
+ let prompt_template = thisData.value.operatorParams.init.find(
+ (item) => item.name === 'prompt_template'
+ )
+ prompt_template.value.params = val
}
}
})
@@ -179,15 +219,28 @@ const paramsWrapper = (objs) => {
item.show = true
if (item.name === 'prompt_template') {
let val = item.value
- if (val.indexOf("'") > -1) {
- val = val.match(/'(.*)'/)
- if (val) {
- val = val[1]
- val = val.split('.')
- val = val[val.length - 1]
- } else val = ''
+ if (typeof (val) === 'string') {
+ if (val.indexOf("'") > -1) {
+ val = val.match(/'(.*)'/)
+ if (val) {
+ val = val[1]
+ val = val.split('.')
+ val = val[val.length - 1]
+ } else val = ''
+ }
+ let promptInfo = dataflow.promptInfo[val]
+ let promptParams = []
+ if (promptInfo && promptInfo.parameter.init)
+ promptParams = promptInfo.parameter.init
+ promptParams.forEach((param) => {
+ param.value = param.default_value || ''
+ })
+ item.value = {
+ cls_name: val,
+ params: promptParams
+ }
}
- item.value = val
+ else item.value = val
item.show = false
}
}
diff --git a/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput.vue b/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/index.vue
similarity index 93%
rename from frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput.vue
rename to frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/index.vue
index 89b115f..f8a349b 100644
--- a/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput.vue
+++ b/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/index.vue
@@ -15,6 +15,7 @@
:options="dataManagerList" :choosen-slider-background="thisData.borderColor"
:reveal-background-color="[thisData.shadowColor, 'rgba(255, 255, 255, 1)']"
:reveal-border-color="thisData.borderColor" border-radius="8" style="width: 100%">
+
@@ -23,7 +24,12 @@ import { useAppConfig } from '@/stores/appConfig'
import { useDataflow } from '@/stores/dataflow'
import { mapState } from 'pinia'
+import kvInput from './kvInput.vue';
+
export default {
+ components: {
+ kvInput
+ },
props: {
modelValue: {
default: ''
@@ -63,6 +69,8 @@ export default {
if (this.itemObj.name === 'database_manager') {
return 'database_manager'
}
+ if (this.itemObj.kind === 'VAR_KEYWORD')
+ return 'kv_input'
return 'text'
}
},
diff --git a/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/kvInput.vue b/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/kvInput.vue
new file mode 100644
index 0000000..ddefc0d
--- /dev/null
+++ b/frontend/src/components/manage/mainFlow/nodes/operatorNode/valueInput/kvInput.vue
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/components/manage/mainFlow/pipeline/index.vue b/frontend/src/components/manage/mainFlow/pipeline/index.vue
index 0ee1b9a..5bb92b2 100644
--- a/frontend/src/components/manage/mainFlow/pipeline/index.vue
+++ b/frontend/src/components/manage/mainFlow/pipeline/index.vue
@@ -167,6 +167,7 @@ export default {
if (newValue) {
this.getDatasets()
this.getOperators(this.language === 'cn' ? 'zh' : 'en')
+ this.getPromptInfo()
}
},
thisValue(newValue) {
@@ -216,7 +217,7 @@ export default {
this.getPipelineList()
},
methods: {
- ...mapActions(useDataflow, ['getDatasets', 'getOperators', 'getPipelines', 'getTasks']),
+ ...mapActions(useDataflow, ['getDatasets', 'getOperators', 'getPromptInfo', 'getPipelines', 'getTasks']),
async getPipelineList() {
if (!this.lock.pipeline) return
this.lock.pipeline = false
diff --git a/frontend/src/stores/dataflow.js b/frontend/src/stores/dataflow.js
index b2230f7..b717412 100644
--- a/frontend/src/stores/dataflow.js
+++ b/frontend/src/stores/dataflow.js
@@ -113,6 +113,19 @@ export const useDataflow = defineStore('useDataflow', () => {
})
}
+ const promptInfo = ref({})
+ const getPromptInfo = async () => {
+ await proxy.$api.prompts.get_prompt_info_api_v1_prompts_prompt_info_get().then((res) => {
+ if (res.code === 200) {
+ promptInfo.value = res.data.prompts
+ } else {
+ proxy.$barWarning(res.message, {
+ status: 'warning'
+ })
+ }
+ })
+ }
+
const datasets = ref([])
const getDatasets = async () => {
let res = await proxy.$api.datasets.list_datasets().catch((err) => {
@@ -257,6 +270,8 @@ export const useDataflow = defineStore('useDataflow', () => {
operators,
groupOperators,
getOperators,
+ promptInfo,
+ getPromptInfo,
datasets,
getDatasets,
text2sqlDatasets,
diff --git a/frontend/src/views/manage/dataflow/index.vue b/frontend/src/views/manage/dataflow/index.vue
index 95667b8..2ea08da 100644
--- a/frontend/src/views/manage/dataflow/index.vue
+++ b/frontend/src/views/manage/dataflow/index.vue
@@ -308,6 +308,7 @@ export default {
mounted() {
this.setViewport()
this.getServing()
+ this.getPromptInfo()
},
methods: {
...mapActions(useDataflow, [
@@ -316,6 +317,7 @@ export default {
'getDataManagerList',
'chooseServing',
'getPipelines',
+ 'getPromptInfo',
'getTasks',
'getExecution',
'clearExecution'
@@ -576,11 +578,18 @@ export default {
status: 'correct'
})
}
+ else {
+ this.$barWarning(this.local('Pipeline execution failed') + res.message, {
+ status: 'warning'
+ })
+ this.lock.running = true
+ }
})
.catch((err) => {
this.$barWarning(this.local('Pipeline execution failed'), {
status: 'error'
})
+ this.lock.running = true
})
},
async handleRunClick() {