mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Replace FlashDecidedToContinueEvent with NextSpeakerCheckEvent (#5257)
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
ApiErrorEvent,
|
||||
FlashFallbackEvent,
|
||||
LoopDetectedEvent,
|
||||
FlashDecidedToContinueEvent,
|
||||
NextSpeakerCheckEvent,
|
||||
SlashCommandEvent,
|
||||
} from '../types.js';
|
||||
import { EventMetadataKey } from './event-metadata-key.js';
|
||||
@@ -40,7 +40,7 @@ const api_error_event_name = 'api_error';
|
||||
const end_session_event_name = 'end_session';
|
||||
const flash_fallback_event_name = 'flash_fallback';
|
||||
const loop_detected_event_name = 'loop_detected';
|
||||
const flash_decided_to_continue_event_name = 'flash_decided_to_continue';
|
||||
const next_speaker_check_event_name = 'next_speaker_check';
|
||||
const slash_command_event_name = 'slash_command';
|
||||
|
||||
export interface LogResponse {
|
||||
@@ -512,12 +512,20 @@ export class ClearcutLogger {
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logFlashDecidedToContinueEvent(event: FlashDecidedToContinueEvent): void {
|
||||
logNextSpeakerCheck(event: NextSpeakerCheckEvent): void {
|
||||
const data = [
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_PROMPT_ID,
|
||||
value: JSON.stringify(event.prompt_id),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_RESPONSE_FINISH_REASON,
|
||||
value: JSON.stringify(event.finish_reason),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_NEXT_SPEAKER_CHECK_RESULT,
|
||||
value: JSON.stringify(event.result),
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SESSION_ID,
|
||||
value: this.config?.getSessionId() ?? '',
|
||||
@@ -525,7 +533,7 @@ export class ClearcutLogger {
|
||||
];
|
||||
|
||||
this.enqueueLogEvent(
|
||||
this.createLogEvent(flash_decided_to_continue_event_name, data),
|
||||
this.createLogEvent(next_speaker_check_event_name, data),
|
||||
);
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
@@ -173,6 +173,16 @@ export enum EventMetadataKey {
|
||||
|
||||
// Logs the subcommand of the slash command.
|
||||
GEMINI_CLI_SLASH_COMMAND_SUBCOMMAND = 42,
|
||||
|
||||
// ==========================================================================
|
||||
// Next Speaker Check Event Keys
|
||||
// ===========================================================================
|
||||
|
||||
// Logs the finish reason of the previous streamGenerateContent response
|
||||
GEMINI_CLI_RESPONSE_FINISH_REASON = 43,
|
||||
|
||||
// Logs the result of the next speaker check
|
||||
GEMINI_CLI_NEXT_SPEAKER_CHECK_RESULT = 44,
|
||||
}
|
||||
|
||||
export function getEventMetadataKey(
|
||||
|
||||
@@ -13,8 +13,7 @@ export const EVENT_API_ERROR = 'gemini_cli.api_error';
|
||||
export const EVENT_API_RESPONSE = 'gemini_cli.api_response';
|
||||
export const EVENT_CLI_CONFIG = 'gemini_cli.config';
|
||||
export const EVENT_FLASH_FALLBACK = 'gemini_cli.flash_fallback';
|
||||
export const EVENT_FLASH_DECIDED_TO_CONTINUE =
|
||||
'gemini_cli.flash_decided_to_continue';
|
||||
export const EVENT_NEXT_SPEAKER_CHECK = 'gemini_cli.next_speaker_check';
|
||||
export const EVENT_SLASH_COMMAND = 'gemini_cli.slash_command';
|
||||
|
||||
export const METRIC_TOOL_CALL_COUNT = 'gemini_cli.tool.call.count';
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
EVENT_TOOL_CALL,
|
||||
EVENT_USER_PROMPT,
|
||||
EVENT_FLASH_FALLBACK,
|
||||
EVENT_FLASH_DECIDED_TO_CONTINUE,
|
||||
EVENT_NEXT_SPEAKER_CHECK,
|
||||
SERVICE_NAME,
|
||||
EVENT_SLASH_COMMAND,
|
||||
} from './constants.js';
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
ToolCallEvent,
|
||||
UserPromptEvent,
|
||||
FlashFallbackEvent,
|
||||
FlashDecidedToContinueEvent,
|
||||
NextSpeakerCheckEvent,
|
||||
LoopDetectedEvent,
|
||||
SlashCommandEvent,
|
||||
} from './types.js';
|
||||
@@ -314,22 +314,22 @@ export function logLoopDetected(
|
||||
logger.emit(logRecord);
|
||||
}
|
||||
|
||||
export function logFlashDecidedToContinue(
|
||||
export function logNextSpeakerCheck(
|
||||
config: Config,
|
||||
event: FlashDecidedToContinueEvent,
|
||||
event: NextSpeakerCheckEvent,
|
||||
): void {
|
||||
ClearcutLogger.getInstance(config)?.logFlashDecidedToContinueEvent(event);
|
||||
ClearcutLogger.getInstance(config)?.logNextSpeakerCheck(event);
|
||||
if (!isTelemetrySdkInitialized()) return;
|
||||
|
||||
const attributes: LogAttributes = {
|
||||
...getCommonAttributes(config),
|
||||
...event,
|
||||
'event.name': EVENT_FLASH_DECIDED_TO_CONTINUE,
|
||||
'event.name': EVENT_NEXT_SPEAKER_CHECK,
|
||||
};
|
||||
|
||||
const logger = logs.getLogger(SERVICE_NAME);
|
||||
const logRecord: LogRecord = {
|
||||
body: `Flash decided to continue.`,
|
||||
body: `Next speaker check.`,
|
||||
attributes,
|
||||
};
|
||||
logger.emit(logRecord);
|
||||
|
||||
@@ -266,15 +266,19 @@ export class LoopDetectedEvent {
|
||||
}
|
||||
}
|
||||
|
||||
export class FlashDecidedToContinueEvent {
|
||||
'event.name': 'flash_decided_to_continue';
|
||||
export class NextSpeakerCheckEvent {
|
||||
'event.name': 'next_speaker_check';
|
||||
'event.timestamp': string; // ISO 8601
|
||||
prompt_id: string;
|
||||
finish_reason: string;
|
||||
result: string;
|
||||
|
||||
constructor(prompt_id: string) {
|
||||
this['event.name'] = 'flash_decided_to_continue';
|
||||
constructor(prompt_id: string, finish_reason: string, result: string) {
|
||||
this['event.name'] = 'next_speaker_check';
|
||||
this['event.timestamp'] = new Date().toISOString();
|
||||
this.prompt_id = prompt_id;
|
||||
this.finish_reason = finish_reason;
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,5 +306,5 @@ export type TelemetryEvent =
|
||||
| ApiResponseEvent
|
||||
| FlashFallbackEvent
|
||||
| LoopDetectedEvent
|
||||
| FlashDecidedToContinueEvent
|
||||
| NextSpeakerCheckEvent
|
||||
| SlashCommandEvent;
|
||||
|
||||
Reference in New Issue
Block a user