Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion frontend/src/axios/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 对象,可以取消该请求
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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}`
Expand Down
100 changes: 98 additions & 2 deletions frontend/src/axios/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_ {

Expand Down Expand Up @@ -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
}

/**
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="node-row-item">
<span class="info-title" style="font-size: 13px; color: rgba(52, 199, 89, 1)">{{
appConfig.local('Init. Parameters')
}}</span>
}}</span>
</div>
<hr />
<div v-if="allowedPrompts.length > 0 && isPromptTemplate" class="node-row-item col" @mousedown.stop @click.stop>
Expand All @@ -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%"></fv-combobox>
<span v-if="promptParamModel.length > 0" class="info-title">{{ appConfig.local('Prompt Parameters')
}}</span>
<kv-input v-if="promptParamModel.length > 0" v-model="promptParamModel" :readonly="true"></kv-input>
</div>
<div v-if="thisData.operatorParams" v-show="item.show" v-for="(item, index) in thisData.operatorParams.init"
:key="`init_${index}`" class="node-row-item col">
Expand All @@ -26,7 +29,7 @@
<div class="node-row-item">
<span class="info-title" style="font-size: 13px; color: rgba(0, 122, 255, 1)">{{
appConfig.local('Run Parameters')
}}</span>
}}</span>
</div>
<hr />
<div v-if="thisData.operatorParams" v-show="hiddenParam(item)"
Expand All @@ -35,11 +38,8 @@
<Handle :id="`${item.name}::target::run_key`" type="target" class="handle-item" :position="Position.Left" />
<Handle :id="`${item.name}::source::run_key`" type="source" class="handle-item"
:position="Position.Right" />
<fv-text-box :theme="theme" v-model="item.value"
:placeholder="appConfig.local('Please input') + ` ${item.name}`" font-size="12" border-radius="3"
:border-width="2" :reveal-border="true" :border-color="thisData.shadowColor"
:focus-border-color="thisData.borderColor" underline style="width: 100%; height: 35px"
@update:modelValue="emitUpdateRunValue(item)" @mousedown.stop @click.stop></fv-text-box>
<value-input :theme="theme" v-model="item.value" :item-obj="item" :this-data="thisData"
@update:modelValue="emitUpdateRunValue(item)" @mousedown.stop @click.stop></value-input>
</div>
<div v-if="currentLog" class="node-group-item"
:style="{ background: theme === 'dark' ? 'rgba(0, 0, 0, 1)' : '' }">
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
})
Expand All @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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%"></fv-combobox>
<kv-input v-if="computedUIType === 'kv_input'" v-model="thisValue"></kv-input>
</div>
</template>

Expand All @@ -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: ''
Expand Down Expand Up @@ -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'
}
},
Expand Down
Loading