feat: Embedded chat window supports userVariables configuration. (#20983)

This commit is contained in:
croatialu
2025-06-18 14:27:02 +08:00
committed by GitHub
parent 787a556bd7
commit 15800c6108
8 changed files with 58 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ import type {
Feedback,
} from '../types'
import { CONVERSATION_ID_INFO } from '../constants'
import { buildChatItemTree, getProcessedInputsFromUrlParams, getProcessedSystemVariablesFromUrlParams } from '../utils'
import { buildChatItemTree, getProcessedInputsFromUrlParams, getProcessedSystemVariablesFromUrlParams, getProcessedUserVariablesFromUrlParams } from '../utils'
import { getProcessedFilesFromResponse } from '../../file-uploader/utils'
import {
fetchAppInfo,
@@ -169,6 +169,7 @@ export const useEmbeddedChatbot = () => {
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)
@@ -237,7 +238,9 @@ export const useEmbeddedChatbot = () => {
// init inputs from url params
(async () => {
const inputs = await getProcessedInputsFromUrlParams()
const userVariables = await getProcessedUserVariablesFromUrlParams()
setInitInputs(inputs)
setInitUserVariables(userVariables)
})()
}, [])
useEffect(() => {
@@ -418,5 +421,6 @@ export const useEmbeddedChatbot = () => {
currentConversationInputs,
setCurrentConversationInputs,
allInputsHidden,
initUserVariables,
}
}