feat: Add user variable processing function to chat history (#22863)

This commit is contained in:
croatialu 2025-07-24 10:06:49 +08:00 • committed by GitHub
commit d1572f47a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 37 additions and 4 deletions

View file

@ -16,7 +16,7 @@ import type {
Feedback,
} from '../types'
import { CONVERSATION_ID_INFO } from '../constants'
import { buildChatItemTree, getProcessedSystemVariablesFromUrlParams, getRawInputsFromUrlParams } from '../utils'
import { buildChatItemTree, getProcessedSystemVariablesFromUrlParams, getRawInputsFromUrlParams, getRawUserVariablesFromUrlParams } from '../utils'
import { addFileInfos, sortAgentSorts } from '../../../tools/utils'
import { getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils'
import {
@ -181,6 +181,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
const newConversationInputsRef = useRef<Record<string, any>>({})
const [newConversationInputs, setNewConversationInputs] = useState<Record<string, any>>({})
const [initInputs, setInitInputs] = useState<Record<string, any>>({})
const [initUserVariables, setInitUserVariables] = useState<Record<string, any>>({})
const handleNewConversationInputsChange = useCallback((newInputs: Record<string, any>) => {
newConversationInputsRef.current = newInputs
setNewConversationInputs(newInputs)
@ -249,7 +250,9 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
// init inputs from url params
(async () => {
const inputs = await getRawInputsFromUrlParams()
const userVariables = await getRawUserVariablesFromUrlParams()
setInitInputs(inputs)
setInitUserVariables(userVariables)
})()
}, [])
@ -520,5 +523,6 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
currentConversationInputs,
setCurrentConversationInputs,
allInputsHidden,
initUserVariables,
}
}