Skip to content

Commit dd863ee

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

File tree

8 files changed

+27
-1275
lines changed

8 files changed

+27
-1275
lines changed

src/types/logging/span.types.ts

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

484484
// Type for all span types
485-
export type Span = WorkflowSpan | LlmSpan | RetrieverSpan | ToolSpan;
485+
export type Span =
486+
| WorkflowSpan
487+
| AgentSpan
488+
| LlmSpan
489+
| RetrieverSpan
490+
| ToolSpan;
486491

487492
/**
488493
* 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/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)