From e7199c228b036c254d6911dde98319ccf45fcecf Mon Sep 17 00:00:00 2001 From: hannesrudolph Date: Mon, 9 Jun 2025 11:06:28 -0600 Subject: [PATCH] fix: Use ApiStreamChunk type for proper type compatibility - Replace custom StreamChunk interface with ApiStreamChunk import - Update all generator method signatures to use ApiStreamChunk - Fixes type compatibility issues with yield* delegation - Resolves CI test failures related to type mismatches --- src/api/providers/bedrock.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/api/providers/bedrock.ts b/src/api/providers/bedrock.ts index 6181a96de8..05183e5b32 100644 --- a/src/api/providers/bedrock.ts +++ b/src/api/providers/bedrock.ts @@ -64,11 +64,8 @@ interface BedrockPayload { } } -// Define interface for stream chunks with proper typing -interface StreamChunk { - type: "reasoning" | "text" - text: string -} +// Import the proper stream chunk types +import { ApiStreamChunk } from "../transform/stream" // Define types for stream events based on AWS SDK export interface StreamEvent { @@ -170,7 +167,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH /** * Handles thinking content block events */ - private *handleThinkingContentBlock(contentBlock: any): Generator { + private *handleThinkingContentBlock(contentBlock: any): Generator { if (contentBlock?.type === "thinking" && contentBlock.thinking !== undefined) { yield { type: "reasoning", @@ -182,7 +179,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH /** * Handles text content block events */ - private *handleTextContentBlock(start: any, contentBlock: any): Generator { + private *handleTextContentBlock(start: any, contentBlock: any): Generator { const text = start?.text || contentBlock?.text if (text !== undefined) { yield { @@ -195,7 +192,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH /** * Handles thinking delta events */ - private *handleThinkingDelta(delta: any): Generator { + private *handleThinkingDelta(delta: any): Generator { if (delta.type === "thinking_delta" && delta.thinking) { yield { type: "reasoning", @@ -207,7 +204,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH /** * Handles signature delta events (part of thinking) */ - private *handleSignatureDelta(delta: any): Generator { + private *handleSignatureDelta(delta: any): Generator { if (delta.type === "signature_delta" && delta.signature) { // Signature is part of the thinking process, treat it as reasoning yield { @@ -220,7 +217,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH /** * Handles text delta events */ - private *handleTextDelta(delta: any): Generator { + private *handleTextDelta(delta: any): Generator { if (delta.text) { yield { type: "text",