( config: Config, event: ChatCompressionEvent, )
| 385 | } |
| 386 | |
| 387 | export function logChatCompression( |
| 388 | config: Config, |
| 389 | event: ChatCompressionEvent, |
| 390 | ): void { |
| 391 | ClearcutLogger.getInstance(config)?.logChatCompressionEvent(event); |
| 392 | |
| 393 | const attributes: LogAttributes = { |
| 394 | ...getCommonAttributes(config), |
| 395 | ...event, |
| 396 | 'event.name': EVENT_CHAT_COMPRESSION, |
| 397 | }; |
| 398 | |
| 399 | const logger = logs.getLogger(SERVICE_NAME); |
| 400 | const logRecord: LogRecord = { |
| 401 | body: `Chat compression (Saved ${event.tokens_before - event.tokens_after} tokens)`, |
| 402 | attributes, |
| 403 | }; |
| 404 | logger.emit(logRecord); |
| 405 | |
| 406 | recordChatCompressionMetrics(config, { |
| 407 | tokens_before: event.tokens_before, |
| 408 | tokens_after: event.tokens_after, |
| 409 | }); |
| 410 | } |
| 411 | |
| 412 | export function logKittySequenceOverflow( |
| 413 | config: Config, |
no test coverage detected