mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 03:24:42 -07:00
chore(core): improve encapsulation and remove unused exports (#19556)
This commit is contained in:
@@ -32,7 +32,6 @@ import type {
|
||||
ConversationFinishedEvent,
|
||||
ChatCompressionEvent,
|
||||
MalformedJsonResponseEvent,
|
||||
InvalidChunkEvent,
|
||||
ContentRetryEvent,
|
||||
ContentRetryFailureEvent,
|
||||
RipgrepFallbackEvent,
|
||||
@@ -65,7 +64,6 @@ import {
|
||||
recordToolCallMetrics,
|
||||
recordChatCompressionMetrics,
|
||||
recordFileOperationMetric,
|
||||
recordInvalidChunk,
|
||||
recordContentRetry,
|
||||
recordContentRetryFailure,
|
||||
recordModelRoutingMetrics,
|
||||
@@ -470,22 +468,6 @@ export function logMalformedJsonResponse(
|
||||
});
|
||||
}
|
||||
|
||||
export function logInvalidChunk(
|
||||
config: Config,
|
||||
event: InvalidChunkEvent,
|
||||
): void {
|
||||
ClearcutLogger.getInstance(config)?.logInvalidChunkEvent(event);
|
||||
bufferTelemetryEvent(() => {
|
||||
const logger = logs.getLogger(SERVICE_NAME);
|
||||
const logRecord: LogRecord = {
|
||||
body: event.toLogBody(),
|
||||
attributes: event.toOpenTelemetryAttributes(config),
|
||||
};
|
||||
logger.emit(logRecord);
|
||||
recordInvalidChunk(config);
|
||||
});
|
||||
}
|
||||
|
||||
export function logContentRetry(
|
||||
config: Config,
|
||||
event: ContentRetryEvent,
|
||||
|
||||
@@ -617,7 +617,7 @@ let baselineComparisonHistogram: Histogram | undefined;
|
||||
let isMetricsInitialized = false;
|
||||
let isPerformanceMonitoringEnabled = false;
|
||||
|
||||
export function getMeter(): Meter | undefined {
|
||||
function getMeter(): Meter | undefined {
|
||||
if (!cliMeter) {
|
||||
cliMeter = metrics.getMeter(SERVICE_NAME);
|
||||
}
|
||||
@@ -1019,7 +1019,7 @@ function getGenAiOperationName(): GenAiOperationName {
|
||||
|
||||
// Performance Monitoring Functions
|
||||
|
||||
export function initializePerformanceMonitoring(config: Config): void {
|
||||
function initializePerformanceMonitoring(config: Config): void {
|
||||
const meter = getMeter();
|
||||
if (!meter) return;
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ export function toChatMessage(content?: Content): ChatMessage {
|
||||
return message;
|
||||
}
|
||||
|
||||
export function toOTelPart(part: Part): AnyPart {
|
||||
function toOTelPart(part: Part): AnyPart {
|
||||
if (part.thought) {
|
||||
if (part.text) {
|
||||
return new ReasoningPart(part.text);
|
||||
@@ -287,7 +287,7 @@ export enum OTelRole {
|
||||
TOOL = 'tool',
|
||||
}
|
||||
|
||||
export function toOTelRole(role?: string): OTelRole {
|
||||
function toOTelRole(role?: string): OTelRole {
|
||||
switch (role?.toLowerCase()) {
|
||||
case 'system':
|
||||
return OTelRole.SYSTEM;
|
||||
@@ -322,7 +322,7 @@ export enum OTelFinishReason {
|
||||
ERROR = 'error',
|
||||
}
|
||||
|
||||
export function toOTelFinishReason(finishReason?: string): OTelFinishReason {
|
||||
function toOTelFinishReason(finishReason?: string): OTelFinishReason {
|
||||
switch (finishReason) {
|
||||
// we have significantly more finish reasons than the spec
|
||||
case FinishReason.FINISH_REASON_UNSPECIFIED:
|
||||
@@ -376,7 +376,7 @@ export interface ChatMessage {
|
||||
parts: AnyPart[];
|
||||
}
|
||||
|
||||
export class TextPart {
|
||||
class TextPart {
|
||||
readonly type = 'text';
|
||||
content: string;
|
||||
|
||||
@@ -385,7 +385,7 @@ export class TextPart {
|
||||
}
|
||||
}
|
||||
|
||||
export class ToolCallRequestPart {
|
||||
class ToolCallRequestPart {
|
||||
readonly type = 'tool_call';
|
||||
name?: string;
|
||||
id?: string;
|
||||
@@ -398,7 +398,7 @@ export class ToolCallRequestPart {
|
||||
}
|
||||
}
|
||||
|
||||
export class ToolCallResponsePart {
|
||||
class ToolCallResponsePart {
|
||||
readonly type = 'tool_call_response';
|
||||
response?: string;
|
||||
id?: string;
|
||||
@@ -409,7 +409,7 @@ export class ToolCallResponsePart {
|
||||
}
|
||||
}
|
||||
|
||||
export class ReasoningPart {
|
||||
class ReasoningPart {
|
||||
readonly type = 'reasoning';
|
||||
content: string;
|
||||
|
||||
@@ -418,7 +418,7 @@ export class ReasoningPart {
|
||||
}
|
||||
}
|
||||
|
||||
export class GenericPart {
|
||||
class GenericPart {
|
||||
type: string;
|
||||
[key: string]: unknown;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user