diff --git a/src/features/chat/vercelAIChat.ts b/src/features/chat/vercelAIChat.ts index 8400523..087d9d1 100644 --- a/src/features/chat/vercelAIChat.ts +++ b/src/features/chat/vercelAIChat.ts @@ -22,11 +22,15 @@ export async function getVercelAIChatResponse( }) if (!response.ok) { - throw new Error(`API request to ${aiService} failed`) + throw new Error( + `API request to ${aiService} failed with status ${response.status} and body ${await response.text()}` + ) } if (!response.body) { - throw new Error(`API response from ${aiService} is empty`) + throw new Error( + `API response from ${aiService} is empty, status ${response.status}` + ) } const data = await response.json() @@ -58,13 +62,17 @@ export async function getVercelAIChatResponseStream( }) if (!response.ok) { - throw new Error(`API request to ${aiService} failed`) + throw new Error( + `API request to ${aiService} failed with status ${response.status} and body ${await response.text()}` + ) } return new ReadableStream({ async start(controller) { if (!response.body) { - throw new Error(`API response from ${aiService} is empty`) + throw new Error( + `API response from ${aiService} is empty, status ${response.status}` + ) } const reader = response.body.getReader() diff --git a/src/features/slide/slideAIHelpers.ts b/src/features/slide/slideAIHelpers.ts index afc1862..fd18e74 100644 --- a/src/features/slide/slideAIHelpers.ts +++ b/src/features/slide/slideAIHelpers.ts @@ -20,7 +20,9 @@ export const judgeSlide = async ( const apiKey = ss[apiKeyName] if (!apiKey) { - throw new Error('API key not found') + throw new Error( + `API key for ${aiService} is missing. Unable to proceed with the AI service.` + ) } const systemMessage = ` diff --git a/src/features/youtube/conversationContinuityFunctions.ts b/src/features/youtube/conversationContinuityFunctions.ts index 01c83b2..6ab1fee 100644 --- a/src/features/youtube/conversationContinuityFunctions.ts +++ b/src/features/youtube/conversationContinuityFunctions.ts @@ -17,7 +17,9 @@ const getAIConfig = () => { const apiKey = ss[apiKeyName] if (!apiKey) { - throw new Error('API key not found') + throw new Error( + `API key for ${aiService} is missing. Unable to proceed with the AI service.` + ) } return { diff --git a/src/pages/api/aiChat.ts b/src/pages/api/aiChat.ts index e52164e..477469d 100644 --- a/src/pages/api/aiChat.ts +++ b/src/pages/api/aiChat.ts @@ -63,7 +63,7 @@ export default async function handler(req: NextRequest) { model: instance(model), messages: modifiedMessages, }) - debugger + return result } }