feat: llm support struct output (#17994)

Co-authored-by: twwu <twwu@dify.ai>
Co-authored-by: zxhlyh <jasonapring2015@outlook.com>
This commit is contained in:
Joel
2025-04-18 16:53:43 +08:00
committed by GitHub
parent da9269ca97
commit 775dc47abe
82 changed files with 4190 additions and 276 deletions

View File

@@ -180,6 +180,17 @@ const translation = {
noParams: 'No parameters needed',
},
showMyCreatedAppsOnly: 'Created by me',
structOutput: {
moreFillTip: 'Showing max 10 levels of nesting',
required: 'Required',
LLMResponse: 'LLM Response',
configure: 'Configure',
notConfiguredTip: 'Structured output has not been configured yet',
structured: 'Structured',
structuredTip: 'Structured Outputs is a feature that ensures the model will always generate responses that adhere to your supplied JSON Schema',
modelNotSupported: 'Model not supported',
modelNotSupportedTip: 'The current model does not support this feature and is automatically downgraded to prompt injection.',
},
}
export default translation

View File

@@ -56,6 +56,7 @@ const translation = {
regenerate: 'Regenerate',
submit: 'Submit',
skip: 'Skip',
format: 'Format',
},
errorMsg: {
fieldRequired: '{{field}} is required',

View File

@@ -423,6 +423,34 @@ const translation = {
variable: 'Variable',
},
sysQueryInUser: 'sys.query in user message is required',
jsonSchema: {
title: 'Structured Output Schema',
instruction: 'Instruction',
promptTooltip: 'Convert the text description into a standardized JSON Schema structure.',
promptPlaceholder: 'Describe your JSON Schema...',
generate: 'Generate',
import: 'Import from JSON',
generateJsonSchema: 'Generate JSON Schema',
generationTip: 'You can use natural language to quickly create a JSON Schema.',
generating: 'Generating JSON Schema...',
generatedResult: 'Generated Result',
resultTip: 'Here is the generated result. If you\'re not satisfied, you can go back and modify your prompt.',
back: 'Back',
regenerate: 'Regenerate',
apply: 'Apply',
doc: 'Learn more about structured output',
resetDefaults: 'Reset',
required: 'required',
addField: 'Add Field',
addChildField: 'Add Child Field',
showAdvancedOptions: 'Show advanced options',
stringValidations: 'String Validations',
fieldNamePlaceholder: 'Field Name',
descriptionPlaceholder: 'Add description',
warningTips: {
saveSchema: 'Please finish editing the current field before saving the schema',
},
},
},
knowledgeRetrieval: {
queryVariable: 'Query Variable',

View File

@@ -33,7 +33,7 @@ export const languages = data.languages
export const LanguagesSupported = languages.filter(item => item.supported).map(item => item.value)
export const getLanguage = (locale: string) => {
if (locale === 'zh-Hans')
if (['zh-Hans', 'ja-JP'].includes(locale))
return locale.replace('-', '_')
return LanguagesSupported[0].replace('-', '_')

View File

@@ -181,6 +181,17 @@ const translation = {
},
openInExplore: '在“探索”中打开',
showMyCreatedAppsOnly: '我创建的',
structOutput: {
moreFillTip: '最多显示 10 级嵌套',
required: '必填',
LLMResponse: 'LLM 的响应',
configure: '配置',
notConfiguredTip: '结构化输出尚未配置',
structured: '结构化输出',
structuredTip: '结构化输出是一项功能,可确保模型始终生成符合您提供的 JSON 模式的响应',
modelNotSupported: '模型不支持',
modelNotSupportedTip: '当前模型不支持此功能,将自动降级为提示注入。',
},
}
export default translation

View File

@@ -56,6 +56,7 @@ const translation = {
regenerate: '重新生成',
submit: '提交',
skip: '跳过',
format: '格式化',
},
errorMsg: {
fieldRequired: '{{field}} 为必填项',

View File

@@ -424,6 +424,34 @@ const translation = {
variable: '变量',
},
sysQueryInUser: 'user message 中必须包含 sys.query',
jsonSchema: {
title: '结构化输出 Schema',
instruction: '指令',
promptTooltip: '将文本描述转换为标准化的 JSON Schema 结构',
promptPlaceholder: '描述你的 JSON Schema...',
generate: '生成',
import: '从 JSON 导入',
generateJsonSchema: '生成 JSON Schema',
generationTip: '可以使用自然语言快速创建 JSON Schema。',
generating: '正在为您生成 JSON Schema...',
generatedResult: '生成结果',
resultTip: '以下是生成的结果。如果你对这个结果不满意,可以返回并修改你的提示词。',
back: '返回',
regenerate: '重新生成',
apply: '应用',
doc: '了解有关结构化输出的更多信息',
resetDefaults: '清空配置',
required: '必填',
addField: '添加字段',
addChildField: '添加子字段',
showAdvancedOptions: '显示高级选项',
stringValidations: '字符串验证',
fieldNamePlaceholder: '字段名',
descriptionPlaceholder: '添加描述',
warningTips: {
saveSchema: '请先完成当前字段的编辑',
},
},
},
knowledgeRetrieval: {
queryVariable: '查询变量',