Emit event on streaming tick
| @@ -454,7 +454,9 @@ export const event_types = { | ||
| 454 | 454 | // TODO: Naming convention is inconsistent with other events |
| 455 | 455 | CHARACTER_DELETED: 'characterDeleted', |
| 456 | 456 | CHARACTER_DUPLICATED: 'character_duplicated', |
| 457 | - SMOOTH_STREAM_TOKEN_RECEIVED: 'smooth_stream_token_received', | |
| 457 | + /** @deprecated The event is aliased to STREAM_TOKEN_RECEIVED. */ | |
| 458 | + SMOOTH_STREAM_TOKEN_RECEIVED: 'stream_token_received', | |
| 459 | + STREAM_TOKEN_RECEIVED: 'stream_token_received', | |
| 458 | 460 | FILE_ATTACHMENT_DELETED: 'file_attachment_deleted', |
| 459 | 461 | WORLDINFO_FORCE_ACTIVATE: 'worldinfo_force_activate', |
| 460 | 462 | OPEN_CHARACTER_LIBRARY: 'open_character_library', |
| @@ -3122,6 +3124,7 @@ class StreamingProcessor { | ||
| 3122 | 3124 | if (logprobs) { |
| 3123 | 3125 | this.messageLogprobs.push(...(Array.isArray(logprobs) ? logprobs : [logprobs])); |
| 3124 | 3126 | } |
| 3127 | + await eventSource.emit(event_types.STREAM_TOKEN_RECEIVED, text); | |
| 3125 | 3128 | await sw.tick(() => this.onProgressStreaming(this.messageId, this.continueMessage + text)); |
| 3126 | 3129 | } |
| 3127 | 3130 | const seconds = (timestamps[timestamps.length - 1] - timestamps[0]) / 1000; |
| @@ -1,4 +1,3 @@ | ||
| 1 | -import { eventSource, event_types } from '../script.js'; | |
| 2 | 1 | import { power_user } from './power-user.js'; |
| 3 | 2 | import { delay } from './utils.js'; |
| 4 | 3 | |
| @@ -268,7 +267,6 @@ export class SmoothEventSourceStream extends EventSourceStream { | ||
| 268 | 267 | hasFocus && await delay(getDelay(lastStr)); |
| 269 | 268 | controller.enqueue(new MessageEvent(event.type, { data: JSON.stringify(parsed.data) })); |
| 270 | 269 | lastStr = parsed.chunk; |
| 271 | - hasFocus && await eventSource.emit(event_types.SMOOTH_STREAM_TOKEN_RECEIVED, parsed.chunk); | |
| 272 | 270 | } |
| 273 | 271 | } catch (error) { |
| 274 | 272 | console.debug('Smooth Streaming parsing error', error); |