mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 07:36:03 +08:00
feat: fetch model support struct output
This commit is contained in:
parent
abbafd56ef
commit
5cdf70503d
@ -59,6 +59,7 @@ export enum ModelFeatureEnum {
|
||||
video = 'video',
|
||||
document = 'document',
|
||||
audio = 'audio',
|
||||
StructuredOutput = 'structured-output',
|
||||
}
|
||||
|
||||
export enum ModelFeatureTextEnum {
|
||||
|
@ -10,16 +10,15 @@ import {
|
||||
import useAvailableVarList from '../_base/hooks/use-available-var-list'
|
||||
import useConfigVision from '../../hooks/use-config-vision'
|
||||
import type { LLMNodeType, StructuredOutput } from './types'
|
||||
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import { useModelList, useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import {
|
||||
ModelFeatureEnum,
|
||||
ModelTypeEnum,
|
||||
} from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
|
||||
import { RETRIEVAL_OUTPUT_STRUCT } from '@/app/components/workflow/constants'
|
||||
import { checkHasContextBlock, checkHasHistoryBlock, checkHasQueryBlock } from '@/app/components/base/prompt-editor/constants'
|
||||
import useSWR from 'swr'
|
||||
import { fetchModelParameterRules } from '@/service/common'
|
||||
|
||||
const useConfig = (id: string, payload: LLMNodeType) => {
|
||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||
@ -280,9 +279,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
||||
}, [inputs, setInputs])
|
||||
|
||||
// structure output
|
||||
// TODO: this method has problem, different model has different parameter rules that show support structured output
|
||||
const { data: parameterRulesData } = useSWR((model?.provider && model?.name) ? `/workspaces/current/model-providers/${model.provider}/models/parameter-rules?model=${model.name}` : null, fetchModelParameterRules)
|
||||
const isModelSupportStructuredOutput = parameterRulesData?.data?.some((rule: any) => rule.name === 'json_schema')
|
||||
const { data: modelList } = useModelList(ModelTypeEnum.textGeneration)
|
||||
const isModelSupportStructuredOutput = modelList
|
||||
?.find(provideItem => provideItem.provider === model?.provider)
|
||||
?.models.find(modelItem => modelItem.model === model?.name)
|
||||
?.features?.includes(ModelFeatureEnum.StructuredOutput)
|
||||
|
||||
const handleStructureOutputEnableChange = useCallback((enabled: boolean) => {
|
||||
const newInputs = produce(inputs, (draft) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user