fix: remove artificial MAX_STREAM_CHUNKS limit that cut off long responses
The plugin hard-capped streaming responses at 1000 chunks. For large models like qwen2.5:32b generating detailed answers, this limit was easily exceeded, causing the response to stop mid-sentence. The Ollama stream already terminates naturally when the model sends the final done signal, so the artificial chunk limit served no purpose. - src/chat-view.ts: Remove chunkCount tracking and MAX_STREAM_CHUNKS constant. Let the stream run until Ollama signals completion.
This commit is contained in:
@@ -9337,7 +9337,6 @@ ${userMessage}` : userMessage;
|
|||||||
const stream = this.ollamaClient.streamChat(completeMessages, tools);
|
const stream = this.ollamaClient.streamChat(completeMessages, tools);
|
||||||
let fullResponse = "";
|
let fullResponse = "";
|
||||||
let toolCalls = [];
|
let toolCalls = [];
|
||||||
let chunkCount = 0;
|
|
||||||
for await (const chunk of stream) {
|
for await (const chunk of stream) {
|
||||||
if (chunk.content) {
|
if (chunk.content) {
|
||||||
fullResponse += chunk.content;
|
fullResponse += chunk.content;
|
||||||
@@ -9350,10 +9349,6 @@ ${userMessage}` : userMessage;
|
|||||||
if (chunk.tool_calls) {
|
if (chunk.tool_calls) {
|
||||||
toolCalls = [...toolCalls, ...chunk.tool_calls];
|
toolCalls = [...toolCalls, ...chunk.tool_calls];
|
||||||
}
|
}
|
||||||
chunkCount++;
|
|
||||||
if (chunkCount > MAX_STREAM_CHUNKS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (toolCalls.length > 0) {
|
if (toolCalls.length > 0) {
|
||||||
await this.processToolCalls(
|
await this.processToolCalls(
|
||||||
@@ -9391,7 +9386,6 @@ ${userMessage}` : userMessage;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var MAX_STREAM_CHUNKS = 1e3;
|
|
||||||
var MAX_TOOL_CALLS = 5;
|
var MAX_TOOL_CALLS = 5;
|
||||||
|
|
||||||
// src/constants.ts
|
// src/constants.ts
|
||||||
|
|||||||
@@ -487,7 +487,6 @@ export class ChatView extends ItemView {
|
|||||||
|
|
||||||
let fullResponse = '';
|
let fullResponse = '';
|
||||||
let toolCalls: OllamaToolCall[] = [];
|
let toolCalls: OllamaToolCall[] = [];
|
||||||
let chunkCount = 0;
|
|
||||||
|
|
||||||
for await (const chunk of stream) {
|
for await (const chunk of stream) {
|
||||||
if (chunk.content) {
|
if (chunk.content) {
|
||||||
@@ -502,11 +501,6 @@ export class ChatView extends ItemView {
|
|||||||
if (chunk.tool_calls) {
|
if (chunk.tool_calls) {
|
||||||
toolCalls = [...toolCalls, ...chunk.tool_calls];
|
toolCalls = [...toolCalls, ...chunk.tool_calls];
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkCount++;
|
|
||||||
if (chunkCount > MAX_STREAM_CHUNKS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process tool calls if any
|
// Process tool calls if any
|
||||||
@@ -575,5 +569,4 @@ export class ChatView extends ItemView {
|
|||||||
private conversationStateManager: ConversationStateManager;
|
private conversationStateManager: ConversationStateManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_STREAM_CHUNKS = 1000;
|
|
||||||
const MAX_TOOL_CALLS = 5;
|
const MAX_TOOL_CALLS = 5;
|
||||||
|
|||||||
Reference in New Issue
Block a user