fix(ollama-stream): 修复变量名错误和Node.js环境兼容性问题
This commit is contained in:
parent
72b139df08
commit
7f82d055fc
@ -565,7 +565,7 @@ export async function* parseNdjsonStream(
|
||||
// Reset buffer if we're done
|
||||
if (done && accumulatedBuffer.trim()) {
|
||||
try {
|
||||
yield parseJsonPreservingUnsafeIntegers(accumBuffer.trim()) as OllamaChatResponse;
|
||||
yield parseJsonPreservingUnsafeIntegers(accumulatedBuffer.trim()) as OllamaChatResponse;
|
||||
} catch {
|
||||
log.warn(`Skipping malformed trailing data: ${accumulatedBuffer.trim().slice(0, 120)}`);
|
||||
}
|
||||
@ -749,17 +749,6 @@ export function createOllamaStreamFn(
|
||||
for await (const chunk of parseNdjsonStream(reader, config.bufferSize)) {
|
||||
const currentTime = Date.now();
|
||||
|
||||
// Check connection health periodically
|
||||
if (currentTime - lastConnectionCheck > connectionCheckInterval) {
|
||||
if (!navigator.onLine) {
|
||||
connectionHealthy = false;
|
||||
log.warn("[manusilized] Connection lost, attempting to recover...");
|
||||
} else {
|
||||
connectionHealthy = true;
|
||||
}
|
||||
lastConnectionCheck = currentTime;
|
||||
}
|
||||
|
||||
// Throttle streaming to reduce UI updates
|
||||
if (currentTime - lastStreamTime < config.throttleDelay) {
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user