@mmmbuto/zai-codex-bridge 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server.js +6 -2
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
const http = require('http');
|
|
14
14
|
const crypto = require('crypto');
|
|
15
|
+
const { createGunzip } = require('zlib');
|
|
16
|
+
const { pipeline } = require('stream');
|
|
15
17
|
|
|
16
18
|
// Configuration from environment
|
|
17
19
|
const PORT = parseInt(process.env.PORT || '31415', 10);
|
|
@@ -269,7 +271,8 @@ async function makeUpstreamRequest(path, body, headers) {
|
|
|
269
271
|
const auth = pickAuth(headers);
|
|
270
272
|
const upstreamHeaders = {
|
|
271
273
|
'Content-Type': 'application/json',
|
|
272
|
-
'Authorization': auth
|
|
274
|
+
'Authorization': auth,
|
|
275
|
+
'Accept-Encoding': 'identity' // Disable compression to avoid gzip issues
|
|
273
276
|
};
|
|
274
277
|
|
|
275
278
|
log('info', 'Upstream request:', {
|
|
@@ -456,7 +459,8 @@ async function streamChatToResponses(stream, res, responseId, messageItemId) {
|
|
|
456
459
|
|
|
457
460
|
try {
|
|
458
461
|
for await (const chunk of stream) {
|
|
459
|
-
|
|
462
|
+
const chunkStr = Buffer.from(chunk).toString('utf8');
|
|
463
|
+
buffer += chunkStr;
|
|
460
464
|
|
|
461
465
|
// Z.ai stream: SSE lines "data: {...}\n"
|
|
462
466
|
// Split by newline and process each complete line
|