feat: passing the inputs values using difyChatbotConfig
(#6376)
This commit is contained in:
20
web/app/components/base/chat/utils.ts
Normal file
20
web/app/components/base/chat/utils.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
async function decodeBase64AndDecompress(base64String: string) {
|
||||
const binaryString = atob(base64String)
|
||||
const compressedUint8Array = Uint8Array.from(binaryString, char => char.charCodeAt(0))
|
||||
const decompressedStream = new Response(compressedUint8Array).body.pipeThrough(new DecompressionStream('gzip'))
|
||||
const decompressedArrayBuffer = await new Response(decompressedStream).arrayBuffer()
|
||||
return new TextDecoder().decode(decompressedArrayBuffer)
|
||||
}
|
||||
|
||||
function getProcessedInputsFromUrlParams(): Record<string, any> {
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const inputs: Record<string, any> = {}
|
||||
urlParams.forEach(async (value, key) => {
|
||||
inputs[key] = await decodeBase64AndDecompress(decodeURIComponent(value))
|
||||
})
|
||||
return inputs
|
||||
}
|
||||
|
||||
export {
|
||||
getProcessedInputsFromUrlParams,
|
||||
}
|
Reference in New Issue
Block a user