From 77950e48c76f4a3b29d01831d43039caba29888a Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期二, 18 十一月 2025 14:12:42 +0800
Subject: [PATCH] 修改
---
app/components/base/chat/utils.ts | 43 ++++++++++---------------------------------
1 files changed, 10 insertions(+), 33 deletions(-)
diff --git a/app/components/base/chat/utils.ts b/app/components/base/chat/utils.ts
index bdac599..ce7a7c0 100644
--- a/app/components/base/chat/utils.ts
+++ b/app/components/base/chat/utils.ts
@@ -3,42 +3,20 @@
import type { ChatItem, ChatItemInTree } from './types'
async function decodeBase64AndDecompress(base64String: string) {
- try {
- 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)
- }
- catch {
- return undefined
- }
+ 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)
}
-async function getProcessedInputsFromUrlParams(): Promise<Record<string, any>> {
+function getProcessedInputsFromUrlParams(): Record<string, any> {
const urlParams = new URLSearchParams(window.location.search)
const inputs: Record<string, any> = {}
- const entriesArray = Array.from(urlParams.entries())
- await Promise.all(
- entriesArray.map(async ([key, value]) => {
- if (!key.startsWith('sys.'))
- inputs[key] = await decodeBase64AndDecompress(decodeURIComponent(value))
- }),
- )
+ urlParams.forEach(async (value, key) => {
+ inputs[key] = await decodeBase64AndDecompress(decodeURIComponent(value))
+ })
return inputs
-}
-
-async function getProcessedSystemVariablesFromUrlParams(): Promise<Record<string, any>> {
- const urlParams = new URLSearchParams(window.location.search)
- const systemVariables: Record<string, any> = {}
- const entriesArray = Array.from(urlParams.entries())
- await Promise.all(
- entriesArray.map(async ([key, value]) => {
- if (key.startsWith('sys.'))
- systemVariables[key.slice(4)] = await decodeBase64AndDecompress(decodeURIComponent(value))
- }),
- )
- return systemVariables
}
function isValidGeneratedAnswer(item?: ChatItem | ChatItemInTree): boolean {
@@ -122,7 +100,7 @@
let targetNode: ChatItemInTree | undefined
// find path to the target message
- const stack = tree.slice().reverse().map(rootNode => ({
+ const stack = tree.toReversed().map(rootNode => ({
node: rootNode,
path: [rootNode],
}))
@@ -185,7 +163,6 @@
export {
getProcessedInputsFromUrlParams,
- getProcessedSystemVariablesFromUrlParams,
isValidGeneratedAnswer,
getLastAnswer,
buildChatItemTree,
--
Gitblit v1.8.0