From 3aae552167222c5fc4cc5d6c289674439590b726 Mon Sep 17 00:00:00 2001 From: AC Date: Sun, 6 Apr 2025 21:50:33 +0800 Subject: [PATCH] Refactor Bedrock API Configuration Check and Improve ChatActions Logging - Removed redundant Bedrock configuration check in the API handler for cleaner code. - Enhanced logging in `ChatActions` to provide clearer feedback when an unknown provider ID is encountered, defaulting to OpenAI when necessary. --- app/api/bedrock/index.ts | 7 ------- app/components/chat.tsx | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/api/bedrock/index.ts b/app/api/bedrock/index.ts index d716ca595..8f1ab2dcd 100644 --- a/app/api/bedrock/index.ts +++ b/app/api/bedrock/index.ts @@ -59,13 +59,6 @@ export async function handle( try { const config = getServerSideConfig(); - if (!config.isBedrock) { - // This check might be redundant due to getAwsCredentials, but good practice - return NextResponse.json( - { error: true, msg: "AWS Bedrock is not configured properly" }, - { status: 500 }, - ); - } const bedrockRegion = config.bedrockRegion as string; const bedrockEndpoint = config.bedrockEndpoint; diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 95cfa4747..ad38801ed 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -720,9 +720,10 @@ export function ChatActions(props: { targetProvider = upperProvider as ServiceProvider; } else { console.error( - `[ChatActions] Unknown provider ID: ${providerId}`, + `[ChatActions] Unknown provider ID: ${providerId}. Falling back to OpenAI.`, ); // Handle error or fallback if needed + targetProvider = ServiceProvider.OpenAI; // Fallback for unrecognized provider } } else { // Handle case where providerId is missing, maybe default to OpenAI?