Skip to content

Commit e8746dd

Browse files
committed
zen: fix opus unicode characters
closes #8967
1 parent 80020ad commit e8746dd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • packages/console/app/src/routes/zen/util/provider

packages/console/app/src/routes/zen/util/provider/anthropic.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
6565
buffer = newBuffer
6666

6767
const messages = []
68-
6968
while (buffer.length >= 4) {
7069
// first 4 bytes are the total length (big-endian)
7170
const totalLength = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getUint32(0, false)
@@ -121,7 +120,9 @@ export const anthropicHelper: ProviderHelper = ({ reqModel, providerModel }) =>
121120

122121
const parsedDataResult = JSON.parse(data)
123122
delete parsedDataResult.p
124-
const bytes = atob(parsedDataResult.bytes)
123+
const binary = atob(parsedDataResult.bytes)
124+
const uint8 = Uint8Array.from(binary, (c) => c.charCodeAt(0))
125+
const bytes = decoder.decode(uint8)
125126
const eventName = JSON.parse(bytes).type
126127
messages.push([`event: ${eventName}`, "\n", `data: ${bytes}`, "\n\n"].join(""))
127128
}

0 commit comments

Comments
 (0)