Commit 604930db authored by Joel's avatar Joel

feat: support detect when to show vision config

parent c3f99779
...@@ -20,6 +20,7 @@ const Panel: FC = () => { ...@@ -20,6 +20,7 @@ const Panel: FC = () => {
const { const {
inputs, inputs,
isShowVisionConfig,
handleModelChanged, handleModelChanged,
handleCompletionParamsChange, handleCompletionParamsChange,
handleVarListChange, handleVarListChange,
...@@ -88,8 +89,8 @@ const Panel: FC = () => { ...@@ -88,8 +89,8 @@ const Panel: FC = () => {
Prompt Prompt
</Field> </Field>
{/* */} {/* Memory examples */}
{isChatApp && isChatApp && ( {isChatApp && isChatModel && (
<div className='text-xs text-gray-300'>Memory examples(Designing)</div> <div className='text-xs text-gray-300'>Memory examples(Designing)</div>
)} )}
{/* Memory */} {/* Memory */}
...@@ -106,6 +107,7 @@ const Panel: FC = () => { ...@@ -106,6 +107,7 @@ const Panel: FC = () => {
)} )}
{/* Vision: GPT4-vision and so on */} {/* Vision: GPT4-vision and so on */}
{isShowVisionConfig && (
<Field <Field
title={t(`${i18nPrefix}.vision`)} title={t(`${i18nPrefix}.vision`)}
tooltip={t('appDebug.vision.description')!} tooltip={t('appDebug.vision.description')!}
...@@ -116,8 +118,8 @@ const Panel: FC = () => { ...@@ -116,8 +118,8 @@ const Panel: FC = () => {
/> />
} }
/> />
)}
</div> </div>
<Split />
<div className='px-4 pt-4 pb-2'> <div className='px-4 pt-4 pb-2'>
<OutputVars> <OutputVars>
<> <>
......
...@@ -4,11 +4,14 @@ import useVarList from '../_base/hooks/use-var-list' ...@@ -4,11 +4,14 @@ import useVarList from '../_base/hooks/use-var-list'
import type { Memory, ValueSelector } from '../../types' import type { Memory, ValueSelector } from '../../types'
import type { LLMNodeType } from './types' import type { LLMNodeType } from './types'
import type { Resolution } from '@/types/app' import type { Resolution } from '@/types/app'
import { useTextGenerationCurrentProviderAndModelAndModelList } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
const useConfig = (initInputs: LLMNodeType) => { const useConfig = (initInputs: LLMNodeType) => {
const [inputs, setInputs] = useState<LLMNodeType>(initInputs) const [inputs, setInputs] = useState<LLMNodeType>(initInputs)
// model // model
const model = inputs.model
const handleModelChanged = useCallback((model: { provider: string; modelId: string; mode?: string }) => { const handleModelChanged = useCallback((model: { provider: string; modelId: string; mode?: string }) => {
const newInputs = produce(inputs, (draft) => { const newInputs = produce(inputs, (draft) => {
draft.model.provider = model.provider draft.model.provider = model.provider
...@@ -25,6 +28,16 @@ const useConfig = (initInputs: LLMNodeType) => { ...@@ -25,6 +28,16 @@ const useConfig = (initInputs: LLMNodeType) => {
setInputs(newInputs) setInputs(newInputs)
}, [inputs, setInputs]) }, [inputs, setInputs])
const {
currentModel: currModel,
} = useTextGenerationCurrentProviderAndModelAndModelList(
{
provider: model.provider,
model: model.name,
},
)
const isShowVisionConfig = !!currModel?.features?.includes(ModelFeatureEnum.vision)
// variables // variables
const { handleVarListChange, handleAddVariable } = useVarList<LLMNodeType>({ const { handleVarListChange, handleAddVariable } = useVarList<LLMNodeType>({
inputs, inputs,
...@@ -55,6 +68,7 @@ const useConfig = (initInputs: LLMNodeType) => { ...@@ -55,6 +68,7 @@ const useConfig = (initInputs: LLMNodeType) => {
return { return {
inputs, inputs,
isShowVisionConfig,
handleModelChanged, handleModelChanged,
handleCompletionParamsChange, handleCompletionParamsChange,
handleVarListChange, handleVarListChange,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment