mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Handle auto parsing reasoning during streaming
- Add function to handle auto parsing reasoning from the streamed message during streaming - Only works when the reasoning prefix is EXACTLY at the beginning of the message - Tried to keep this lightweight, no regex parsing, remembering the index, so it's simple string splicing - Add utility function that trims a string only if `trim_spaces` is enabled
This commit is contained in:
@ -3223,6 +3223,7 @@ class StreamingProcessor {
|
||||
|
||||
// Update reasoning
|
||||
await this.reasoningHandler.process(messageId, mesChanged);
|
||||
processedText = chat[messageId]['mes'];
|
||||
|
||||
// Token count update.
|
||||
const tokenCountText = this.reasoningHandler.reasoning + processedText;
|
||||
@ -3373,7 +3374,7 @@ class StreamingProcessor {
|
||||
this.messageLogprobs.push(...(Array.isArray(logprobs) ? logprobs : [logprobs]));
|
||||
}
|
||||
// Get the updated reasoning string into the handler
|
||||
this.reasoningHandler.updateReasoning(this.messageId, state?.reasoning ?? '');
|
||||
this.reasoningHandler.updateReasoning(this.messageId, state?.reasoning);
|
||||
await eventSource.emit(event_types.STREAM_TOKEN_RECEIVED, text);
|
||||
await sw.tick(async () => await this.onProgressStreaming(this.messageId, this.continueMessage + text));
|
||||
}
|
||||
|
Reference in New Issue
Block a user