feat: passing the inputs values using difyChatbotConfig (#6376)

This commit is contained in:
yoyocircle
2024-07-18 21:54:16 +08:00
committed by GitHub
parent e493ce9981
commit 284ef52bba
4 changed files with 82 additions and 42 deletions

View 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,
}