Skip to content

Commit a08415a

Browse files
committed
feature(stream): Adjusted base handler class for expected types, adjusted mock version of logger class.
1 parent 9f08b63 commit a08415a

File tree

9 files changed

+29
-1277
lines changed

9 files changed

+29
-1277
lines changed

src/types/logging/span.types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,12 @@ export class ToolSpan extends BaseStep {
292292
}
293293

294294
// Type for all span types
295-
export type Span = WorkflowSpan | LlmSpan | RetrieverSpan | ToolSpan;
295+
export type Span =
296+
| WorkflowSpan
297+
| AgentSpan
298+
| LlmSpan
299+
| RetrieverSpan
300+
| ToolSpan;
296301

297302
/**
298303
* Type guard to validate if a value is a valid AgentType

src/types/streaming-adapter.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ export interface StreamingMetricsResult {
1515
durationNs: number;
1616
tokenUsage: TokenUsage | null;
1717
}
18-

src/utils/galileo-logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ class GalileoLogger {
961961
_updateSpanStreaming(span: Span, output: any): void {
962962
// Mock: Just log for now, will be replaced when PR is merged
963963
console.debug('[MOCK] _updateSpanStreaming called', {
964-
spanId: span.id,
964+
spanId: 'span.id',
965965
output: typeof output === 'string' ? output.substring(0, 100) : output
966966
});
967967
// TODO: Replace with actual implementation when streaming mode PR is merged
@@ -989,7 +989,7 @@ class GalileoLogger {
989989
): void {
990990
// Mock: Just log for now, will be replaced when PR is merged
991991
console.debug('[MOCK] _updateTraceStreaming called', {
992-
traceId: trace.id,
992+
traceId: 'trace.id',
993993
output: typeof output === 'string' ? output.substring(0, 100) : output,
994994
isComplete
995995
});

src/utils/streaming/base-streaming-adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { GalileoLogger } from '../galileo-logger';
22
import { ErrorManager } from '../errors';
33
import { StreamingMetrics } from './metrics';
44
import { StreamingFinalizer, StreamingFinalizerConfig } from './finalizer';
5-
import { TokenUsage, StreamingMetricsResult } from '../../types/streaming-adapter.types';
5+
import {
6+
TokenUsage,
7+
StreamingMetricsResult
8+
} from '../../types/streaming-adapter.types';
69
import {
710
LlmSpanAllowedInputType,
811
LlmSpanAllowedOutputType

src/utils/streaming/finalizer.ts

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
import { GalileoLogger } from '../galileo-logger';
2-
import { StreamingMetrics } from './metrics';
3-
import {
1+
import type { GalileoLogger } from '../galileo-logger';
2+
import type { StreamingMetrics } from './metrics';
3+
import type {
44
LlmSpanAllowedInputType,
55
LlmSpanAllowedOutputType
66
} from '../../types/logging/step.types';
7-
import { Span } from '../../types/logging/span.types';
7+
import type { Span } from '../../types/logging/span.types';
88
import { Trace } from '../../types/logging/trace.types';
99
import type { ToolDefinition } from './base-streaming-adapter';
1010

11-
/**
12-
* Extended logger interface with streaming update methods
13-
* These methods are mocked and will be replaced when streaming mode PR is merged
14-
*/
15-
export interface GalileoLoggerWithStreaming extends GalileoLogger {
16-
_updateSpanStreaming?(span: Span, output: LlmSpanAllowedOutputType): void;
17-
_updateTraceStreaming?(
18-
trace: Trace,
19-
output: LlmSpanAllowedOutputType,
20-
isComplete?: boolean
21-
): void;
22-
}
23-
2411
/**
2512
* Configuration for streaming finalization
2613
*/
@@ -114,21 +101,13 @@ export class StreamingFinalizer {
114101
return;
115102
}
116103

117-
// Type guard to check if logger has streaming methods
118-
const loggerWithStreaming = this.logger as GalileoLoggerWithStreaming;
119-
120-
// TO-DO: After logger PR merged, substitute for actual implementation.
104+
// Call streaming update methods (mock implementations in GalileoLogger)
121105
if (currentParent instanceof Trace) {
122-
// Mock implementation - assumes _updateTraceStreaming exists in another branch/PR
123-
loggerWithStreaming._updateTraceStreaming?.(
124-
currentParent,
125-
output,
126-
false
127-
);
106+
// Update trace with partial output during streaming
107+
this.logger._updateTraceStreaming(currentParent, output, false);
128108
} else {
129-
// Mock implementation - assumes _updateSpanStreaming exists in another branch/PR
130-
// currentParent is a Span (WorkflowSpan, AgentSpan, etc.)
131-
loggerWithStreaming._updateSpanStreaming?.(currentParent as Span, output);
109+
// currentParent is a Span (WorkflowSpan, AgentSpan, LlmSpan, etc.)
110+
this.logger._updateSpanStreaming(currentParent as Span, output);
132111
}
133112
}
134113
}

src/utils/streaming/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export { StreamingMetrics } from './metrics';
1212
export { StreamingFinalizer } from './finalizer';
1313
export { BaseStreamingAdapter } from './base-streaming-adapter';
1414
export { ErrorManager, ErrorInfo } from '../errors';
15-
export type { TokenUsage, StreamingMetricsResult } from '../../types/streaming-adapter.types';
15+
export type {
16+
TokenUsage,
17+
StreamingMetricsResult
18+
} from '../../types/streaming-adapter.types';
1619
export type { StreamingFinalizerConfig } from './finalizer';
1720
export type {
1821
BaseStreamingAdapterConfig,

src/utils/streaming/metrics.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { TokenUsage, StreamingMetricsResult } from '../../types/streaming-adapter.types';
1+
import type {
2+
TokenUsage,
3+
StreamingMetricsResult
4+
} from '../../types/streaming-adapter.types';
25

36
/**
47
* Tracks streaming metrics including TTFT, duration, and token usage
@@ -77,4 +80,3 @@ export class StreamingMetrics {
7780
this.tokenUsage = null;
7881
}
7982
}
80-

0 commit comments

Comments
 (0)