mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-19 22:09:11 +08:00
Update Code Generator to use the currently configured model. (#9740)
This commit is contained in:
parent
400392230b
commit
95dc90e6b2
@ -7,8 +7,7 @@ import ConfigPrompt from '../../config-prompt'
|
|||||||
import { languageMap } from '../../../../workflow/nodes/_base/components/editor/code-editor/index'
|
import { languageMap } from '../../../../workflow/nodes/_base/components/editor/code-editor/index'
|
||||||
import { generateRuleCode } from '@/service/debug'
|
import { generateRuleCode } from '@/service/debug'
|
||||||
import type { CodeGenRes } from '@/service/debug'
|
import type { CodeGenRes } from '@/service/debug'
|
||||||
import { ModelModeType } from '@/types/app'
|
import { type AppType, type Model, ModelModeType } from '@/types/app'
|
||||||
import type { AppType, Model } from '@/types/app'
|
|
||||||
import Modal from '@/app/components/base/modal'
|
import Modal from '@/app/components/base/modal'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import { Generator } from '@/app/components/base/icons/src/vender/other'
|
import { Generator } from '@/app/components/base/icons/src/vender/other'
|
||||||
@ -16,6 +15,10 @@ import Toast from '@/app/components/base/toast'
|
|||||||
import Loading from '@/app/components/base/loading'
|
import Loading from '@/app/components/base/loading'
|
||||||
import Confirm from '@/app/components/base/confirm'
|
import Confirm from '@/app/components/base/confirm'
|
||||||
import type { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
import type { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||||
|
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||||
|
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||||
|
import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon'
|
||||||
|
import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name'
|
||||||
export type IGetCodeGeneratorResProps = {
|
export type IGetCodeGeneratorResProps = {
|
||||||
mode: AppType
|
mode: AppType
|
||||||
isShow: boolean
|
isShow: boolean
|
||||||
@ -31,9 +34,12 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
|
|||||||
codeLanguages,
|
codeLanguages,
|
||||||
onClose,
|
onClose,
|
||||||
onFinished,
|
onFinished,
|
||||||
|
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
|
const {
|
||||||
|
currentProvider,
|
||||||
|
currentModel,
|
||||||
|
} = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.textGeneration)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [instruction, setInstruction] = React.useState<string>('')
|
const [instruction, setInstruction] = React.useState<string>('')
|
||||||
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false)
|
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false)
|
||||||
@ -51,9 +57,10 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const model: Model = {
|
const model: Model = {
|
||||||
provider: 'openai',
|
provider: currentProvider?.provider || '',
|
||||||
name: 'gpt-4o-mini',
|
name: currentModel?.model || '',
|
||||||
mode: ModelModeType.chat,
|
mode: ModelModeType.chat,
|
||||||
|
// This is a fixed parameter
|
||||||
completion_params: {
|
completion_params: {
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
max_tokens: 0,
|
max_tokens: 0,
|
||||||
@ -112,6 +119,19 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
|
|||||||
<div className={'leading-[28px] text-lg font-bold'}>{t('appDebug.codegen.title')}</div>
|
<div className={'leading-[28px] text-lg font-bold'}>{t('appDebug.codegen.title')}</div>
|
||||||
<div className='mt-1 text-[13px] font-normal text-gray-500'>{t('appDebug.codegen.description')}</div>
|
<div className='mt-1 text-[13px] font-normal text-gray-500'>{t('appDebug.codegen.description')}</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='flex items-center'>
|
||||||
|
<ModelIcon
|
||||||
|
className='shrink-0 mr-1.5'
|
||||||
|
provider={currentProvider}
|
||||||
|
modelName={currentModel?.model}
|
||||||
|
/>
|
||||||
|
<ModelName
|
||||||
|
className='grow'
|
||||||
|
modelItem={currentModel!}
|
||||||
|
showMode
|
||||||
|
showFeatures
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className='mt-6'>
|
<div className='mt-6'>
|
||||||
<div className='text-[0px]'>
|
<div className='text-[0px]'>
|
||||||
<div className='mb-2 leading-5 text-sm font-medium text-gray-900'>{t('appDebug.codegen.instruction')}</div>
|
<div className='mb-2 leading-5 text-sm font-medium text-gray-900'>{t('appDebug.codegen.instruction')}</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user