mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-07 01:46:49 +08:00
feat: support assistant frontend (#2139)
Co-authored-by: StyleZhang <jasonapring2015@outlook.com>
This commit is contained in:
@@ -15,6 +15,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
||||
if (item['text-input'])
|
||||
return ['string', item['text-input']]
|
||||
|
||||
if (item.external_data_tool)
|
||||
return ['api', item.external_data_tool]
|
||||
|
||||
return ['select', item.select]
|
||||
})()
|
||||
const is_context_var = dataset_query_variable === content.variable
|
||||
@@ -30,6 +33,19 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
||||
is_context_var,
|
||||
})
|
||||
}
|
||||
else if (type === 'api') {
|
||||
promptVariables.push({
|
||||
key: content.variable,
|
||||
name: content.label,
|
||||
required: content.required,
|
||||
type: content.type,
|
||||
enabled: content.enabled,
|
||||
config: content.config,
|
||||
icon: content.icon,
|
||||
icon_background: content.icon_background,
|
||||
is_context_var,
|
||||
})
|
||||
}
|
||||
else {
|
||||
promptVariables.push({
|
||||
key: content.variable,
|
||||
@@ -63,6 +79,20 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
|
||||
},
|
||||
} as any)
|
||||
}
|
||||
else if (item.type === 'api') {
|
||||
userInputs.push({
|
||||
external_data_tool: {
|
||||
label: item.name,
|
||||
variable: item.key,
|
||||
enabled: item.enabled,
|
||||
type: item.type,
|
||||
config: item.config,
|
||||
required: item.required,
|
||||
icon: item.icon,
|
||||
icon_background: item.icon_background,
|
||||
},
|
||||
} as any)
|
||||
}
|
||||
else {
|
||||
userInputs.push({
|
||||
select: {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, getMaxVarNameLength } from '@/config'
|
||||
import { CONTEXT_PLACEHOLDER_TEXT, HISTORY_PLACEHOLDER_TEXT, PRE_PROMPT_PLACEHOLDER_TEXT, QUERY_PLACEHOLDER_TEXT } from '@/app/components/base/prompt-editor/constants'
|
||||
const otherAllowedRegex = /^[a-zA-Z0-9_]+$/
|
||||
export const getNewVar = (key: string) => {
|
||||
export const getNewVar = (key: string, type: string) => {
|
||||
return {
|
||||
...VAR_ITEM_TEMPLATE,
|
||||
type: type || 'string',
|
||||
key,
|
||||
name: key.slice(0, getMaxVarNameLength(key)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user