mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 01:18:05 +08:00
feat: mermory size config
This commit is contained in:
@ -3,25 +3,27 @@ import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import TextEditor from '../../_base/components/editor/text-editor'
|
||||
import MemoryConfig from '../../_base/components/memory-config'
|
||||
import type { Memory } from '@/app/components/workflow/types'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.questionClassifiers'
|
||||
|
||||
type Props = {
|
||||
instruction: string
|
||||
onInstructionChange: (instruction: string) => void
|
||||
memory: Memory
|
||||
onMemoryChange: (memory: Memory) => void
|
||||
}
|
||||
|
||||
const AdvancedSetting: FC<Props> = ({
|
||||
instruction,
|
||||
onInstructionChange,
|
||||
memory,
|
||||
onMemoryChange,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<>
|
||||
<TextEditor
|
||||
title={t(`${i18nPrefix}.instruction`)!}
|
||||
value={instruction}
|
||||
@ -35,7 +37,14 @@ const AdvancedSetting: FC<Props> = ({
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<MemoryConfig
|
||||
className='mt-4'
|
||||
readonly={false}
|
||||
payload={memory}
|
||||
onChange={onMemoryChange}
|
||||
canSetRoleName={false}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default React.memo(AdvancedSetting)
|
||||
|
||||
@ -20,6 +20,7 @@ const Panel: FC = () => {
|
||||
handleQueryVarChange,
|
||||
handleTopicsChange,
|
||||
handleInstructionChange,
|
||||
handleMemoryChange,
|
||||
} = useConfig(mockData)
|
||||
const model = inputs.model
|
||||
|
||||
@ -65,6 +66,7 @@ const Panel: FC = () => {
|
||||
instruction={inputs.instruction}
|
||||
onInstructionChange={handleInstructionChange}
|
||||
memory={inputs.memory}
|
||||
onMemoryChange={handleMemoryChange}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useCallback, useState } from 'react'
|
||||
import produce from 'immer'
|
||||
import type { ValueSelector } from '../../types'
|
||||
import type { Memory, ValueSelector } from '../../types'
|
||||
import type { QuestionClassifierNodeType } from './types'
|
||||
|
||||
const useConfig = (initInputs: QuestionClassifierNodeType) => {
|
||||
@ -44,6 +44,13 @@ const useConfig = (initInputs: QuestionClassifierNodeType) => {
|
||||
setInputs(newInputs)
|
||||
}, [inputs, setInputs])
|
||||
|
||||
const handleMemoryChange = useCallback((memory: Memory) => {
|
||||
const newInputs = produce(inputs, (draft) => {
|
||||
draft.memory = memory
|
||||
})
|
||||
setInputs(newInputs)
|
||||
}, [inputs, setInputs])
|
||||
|
||||
return {
|
||||
inputs,
|
||||
handleModelChanged,
|
||||
@ -51,6 +58,7 @@ const useConfig = (initInputs: QuestionClassifierNodeType) => {
|
||||
handleQueryVarChange,
|
||||
handleTopicsChange,
|
||||
handleInstructionChange,
|
||||
handleMemoryChange,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user