Commit 0518da1e authored by Joel's avatar Joel

feat: handle llm memory

parent 6f6f0322
import { MemoryRole } from '../../types' import { BlockEnum } from '../../types'
import type { LLMNodeType } from './types' import type { LLMNodeType } from './types'
import { Resolution } from '@/types/app' import { Resolution } from '@/types/app'
export const mockData: LLMNodeType = { export const mockData: LLMNodeType = {
title: 'Test', title: 'Test',
desc: 'Test', desc: 'Test',
type: 'Test', type: BlockEnum.LLM,
model: { model: {
provider: 'openai', provider: 'openai',
name: 'gpt-4', name: 'gpt-4',
...@@ -26,7 +26,10 @@ export const mockData: LLMNodeType = { ...@@ -26,7 +26,10 @@ export const mockData: LLMNodeType = {
], ],
prompt: [], prompt: [],
memory: { memory: {
role_prefix: MemoryRole.assistant, role_prefix: {
user: 'user: ',
assistant: 'assistant: ',
},
window: { window: {
enabled: false, enabled: false,
size: 0, size: 0,
......
...@@ -26,9 +26,11 @@ const Panel: FC = () => { ...@@ -26,9 +26,11 @@ const Panel: FC = () => {
handleContextVarChange, handleContextVarChange,
handleMemoryChange, handleMemoryChange,
} = useConfig(mockData) } = useConfig(mockData)
const isChatApp = true // TODO: get from app context
const model = inputs.model const model = inputs.model
const modelMode = inputs.model?.mode const modelMode = inputs.model?.mode
const isChatMode = modelMode === 'chat' const isChatModel = modelMode === 'chat'
const isCompletionModel = !isChatModel
return ( return (
<div className='mt-2'> <div className='mt-2'>
...@@ -84,14 +86,18 @@ const Panel: FC = () => { ...@@ -84,14 +86,18 @@ const Panel: FC = () => {
Prompt Prompt
</Field> </Field>
{/* */}
{isChatApp && isChatApp && (
<div className='text-xs text-gray-300'>Memory examples(Designing)</div>
)}
{/* Memory */} {/* Memory */}
{isChatMode && ( {isChatApp && (
<> <>
<MemoryConfig <MemoryConfig
readonly={readOnly} readonly={readOnly}
payload={inputs.memory} payload={inputs.memory}
onChange={handleMemoryChange} onChange={handleMemoryChange}
canSetRoleName canSetRoleName={isCompletionModel}
/> />
<Split /> <Split />
</> </>
......
This diff is collapsed.
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