mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-26 09:04:33 +08:00
embedding in websites support initializes to specify the conversation_id (#18602)
This commit is contained in:
parent
205535c8e9
commit
d5fe50e471
@ -48,6 +48,7 @@ const OPTION_MAP = {
|
|||||||
: ''},
|
: ''},
|
||||||
systemVariables: {
|
systemVariables: {
|
||||||
// user_id: 'YOU CAN DEFINE USER ID HERE',
|
// user_id: 'YOU CAN DEFINE USER ID HERE',
|
||||||
|
// conversation_id: 'YOU CAN DEFINE CONVERSATION ID HERE, IT MUST BE A VALID UUID',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -73,9 +73,11 @@ export const useEmbeddedChatbot = () => {
|
|||||||
const appId = useMemo(() => appData?.app_id, [appData])
|
const appId = useMemo(() => appData?.app_id, [appData])
|
||||||
|
|
||||||
const [userId, setUserId] = useState<string>()
|
const [userId, setUserId] = useState<string>()
|
||||||
|
const [conversationId, setConversationId] = useState<string>()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProcessedSystemVariablesFromUrlParams().then(({ user_id }) => {
|
getProcessedSystemVariablesFromUrlParams().then(({ user_id, conversation_id }) => {
|
||||||
setUserId(user_id)
|
setUserId(user_id)
|
||||||
|
setConversationId(conversation_id)
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@ -109,7 +111,8 @@ export const useEmbeddedChatbot = () => {
|
|||||||
const [conversationIdInfo, setConversationIdInfo] = useLocalStorageState<Record<string, Record<string, string>>>(CONVERSATION_ID_INFO, {
|
const [conversationIdInfo, setConversationIdInfo] = useLocalStorageState<Record<string, Record<string, string>>>(CONVERSATION_ID_INFO, {
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
})
|
})
|
||||||
const currentConversationId = useMemo(() => conversationIdInfo?.[appId || '']?.[userId || 'DEFAULT'] || '', [appId, conversationIdInfo, userId])
|
const currentConversationId = useMemo(() => conversationIdInfo?.[appId || '']?.[userId || 'DEFAULT'] || conversationId || '',
|
||||||
|
[appId, conversationIdInfo, userId, conversationId])
|
||||||
const handleConversationIdInfoChange = useCallback((changeConversationId: string) => {
|
const handleConversationIdInfoChange = useCallback((changeConversationId: string) => {
|
||||||
if (appId) {
|
if (appId) {
|
||||||
let prevValue = conversationIdInfo?.[appId || '']
|
let prevValue = conversationIdInfo?.[appId || '']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user