Skip to content

Commit e06ccc4

Browse files
committed
fix: add timestamp_ms to StreamJsonAssistantEvent type, remove as any casts
1 parent 2be2187 commit e06ccc4

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/streaming/ai-sdk-parts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class StreamToAiSdkParts {
4242

4343
handleEvent(event: StreamJsonEvent): AiSdkStreamPart[] {
4444
if (isAssistantText(event)) {
45-
const isPartial = typeof (event as any).timestamp_ms === "number";
45+
const isPartial = typeof event.timestamp_ms === "number";
4646
if (isPartial) {
4747
this.sawAssistantPartials = true;
4848
const text = extractText(event);
@@ -56,7 +56,7 @@ export class StreamToAiSdkParts {
5656
}
5757

5858
if (isThinking(event)) {
59-
const isPartial = typeof (event as any).timestamp_ms === "number";
59+
const isPartial = typeof event.timestamp_ms === "number";
6060
if (isPartial) {
6161
this.sawThinkingPartials = true;
6262
const text = extractThinking(event);

src/streaming/openai-sse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class StreamToSseConverter {
7575

7676
handleEvent(event: StreamJsonEvent): string[] {
7777
if (isAssistantText(event)) {
78-
const isPartial = typeof (event as any).timestamp_ms === "number";
78+
const isPartial = typeof event.timestamp_ms === "number";
7979
if (isPartial) {
8080
this.sawAssistantPartials = true;
8181
const text = extractText(event);
@@ -89,7 +89,7 @@ export class StreamToSseConverter {
8989
}
9090

9191
if (isThinking(event)) {
92-
const isPartial = typeof (event as any).timestamp_ms === "number";
92+
const isPartial = typeof event.timestamp_ms === "number";
9393
if (isPartial) {
9494
this.sawThinkingPartials = true;
9595
const text = extractThinking(event);

src/streaming/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type StreamJsonUserEvent = {
3535
export type StreamJsonAssistantEvent = {
3636
type: "assistant";
3737
timestamp?: number;
38+
timestamp_ms?: number;
3839
session_id?: string;
3940
message: {
4041
role: "assistant";

0 commit comments

Comments
 (0)