mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix: Improve type safety for Bedrock stream generators
- Add StreamChunk interface with proper type definitions - Update all generator methods to use Generator<StreamChunk, void, unknown> - Addresses review feedback for better type safety
This commit is contained in:
parent
388978807a
commit
d9a6a0edb7
1 changed files with 11 additions and 5 deletions
|
|
@ -64,6 +64,12 @@ interface BedrockPayload {
|
|||
}
|
||||
}
|
||||
|
||||
// Define interface for stream chunks with proper typing
|
||||
interface StreamChunk {
|
||||
type: "reasoning" | "text"
|
||||
text: string
|
||||
}
|
||||
|
||||
// Define types for stream events based on AWS SDK
|
||||
export interface StreamEvent {
|
||||
messageStart?: {
|
||||
|
|
@ -164,7 +170,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
/**
|
||||
* Handles thinking content block events
|
||||
*/
|
||||
private *handleThinkingContentBlock(contentBlock: any): Generator<any, void, unknown> {
|
||||
private *handleThinkingContentBlock(contentBlock: any): Generator<StreamChunk, void, unknown> {
|
||||
if (contentBlock?.type === "thinking" && contentBlock.thinking !== undefined) {
|
||||
yield {
|
||||
type: "reasoning",
|
||||
|
|
@ -176,7 +182,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
/**
|
||||
* Handles text content block events
|
||||
*/
|
||||
private *handleTextContentBlock(start: any, contentBlock: any): Generator<any, void, unknown> {
|
||||
private *handleTextContentBlock(start: any, contentBlock: any): Generator<StreamChunk, void, unknown> {
|
||||
const text = start?.text || contentBlock?.text
|
||||
if (text !== undefined) {
|
||||
yield {
|
||||
|
|
@ -189,7 +195,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
/**
|
||||
* Handles thinking delta events
|
||||
*/
|
||||
private *handleThinkingDelta(delta: any): Generator<any, void, unknown> {
|
||||
private *handleThinkingDelta(delta: any): Generator<StreamChunk, void, unknown> {
|
||||
if (delta.type === "thinking_delta" && delta.thinking) {
|
||||
yield {
|
||||
type: "reasoning",
|
||||
|
|
@ -201,7 +207,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
/**
|
||||
* Handles signature delta events (part of thinking)
|
||||
*/
|
||||
private *handleSignatureDelta(delta: any): Generator<any, void, unknown> {
|
||||
private *handleSignatureDelta(delta: any): Generator<StreamChunk, void, unknown> {
|
||||
if (delta.type === "signature_delta" && delta.signature) {
|
||||
// Signature is part of the thinking process, treat it as reasoning
|
||||
yield {
|
||||
|
|
@ -214,7 +220,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
/**
|
||||
* Handles text delta events
|
||||
*/
|
||||
private *handleTextDelta(delta: any): Generator<any, void, unknown> {
|
||||
private *handleTextDelta(delta: any): Generator<StreamChunk, void, unknown> {
|
||||
if (delta.text) {
|
||||
yield {
|
||||
type: "text",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue