diff --git a/server/utils/agents/aibitat/plugins/websocket.js b/server/utils/agents/aibitat/plugins/websocket.js index af691ca552948bd0216fdf7beba973c33f284c03..b6154984d28b6602d0e9d2483080b250efc6a841 100644 --- a/server/utils/agents/aibitat/plugins/websocket.js +++ b/server/utils/agents/aibitat/plugins/websocket.js @@ -48,7 +48,13 @@ const websocket = { name: this.name, setup(aibitat) { aibitat.onError(async (error) => { - console.error(chalk.red(` error: ${error?.message}`)); + if (!!error?.message) { + console.error(chalk.red(` error: ${error.message}`)); + aibitat.introspect( + `Error encountered while running: ${error.message}` + ); + } + if (error instanceof RetryError) { console.error(chalk.red(` retrying in 60 seconds...`)); setTimeout(() => { diff --git a/server/utils/agents/aibitat/providers/anthropic.js b/server/utils/agents/aibitat/providers/anthropic.js index d160d9ab6fceee9ba1c69b9ca530b25a11f38491..5189dc2ef65dee62585f631f392e8ece94e9b2b6 100644 --- a/server/utils/agents/aibitat/providers/anthropic.js +++ b/server/utils/agents/aibitat/providers/anthropic.js @@ -117,10 +117,14 @@ class AnthropicProvider extends Provider { cost, }; } catch (error) { + // If invalid Auth error we need to abort because no amount of waiting + // will make auth better. + if (error instanceof Anthropic.AuthenticationError) throw error; + if ( error instanceof Anthropic.RateLimitError || error instanceof Anthropic.InternalServerError || - error instanceof Anthropic.APIError + error instanceof Anthropic.APIError // Also will catch AuthenticationError!!! ) { throw new RetryError(error.message); } diff --git a/server/utils/agents/aibitat/providers/openai.js b/server/utils/agents/aibitat/providers/openai.js index 82cd7741e26641448843969bd14cc6db59389723..4458afe8ff97fbc2f0a1bb974670b858dd07b23c 100644 --- a/server/utils/agents/aibitat/providers/openai.js +++ b/server/utils/agents/aibitat/providers/openai.js @@ -102,11 +102,14 @@ class OpenAIProvider extends Provider { cost, }; } catch (error) { - console.log(error); + // If invalid Auth error we need to abort because no amount of waiting + // will make auth better. + if (error instanceof OpenAI.AuthenticationError) throw error; + if ( error instanceof OpenAI.RateLimitError || error instanceof OpenAI.InternalServerError || - error instanceof OpenAI.APIError + error instanceof OpenAI.APIError // Also will catch AuthenticationError!!! ) { throw new RetryError(error.message); } diff --git a/server/utils/agents/index.js b/server/utils/agents/index.js index ff66c982b4d4b12ac832e695ba35be0ea46bac33..dd42a6b999583b7cd54747a4c01a888bcae2f75e 100644 --- a/server/utils/agents/index.js +++ b/server/utils/agents/index.js @@ -157,8 +157,8 @@ class AgentHandler { } ) { this.aibitat = new AIbitat({ - provider: "openai", - model: "gpt-3.5-turbo", + provider: this.provider ?? "openai", + model: this.model ?? "gpt-3.5-turbo", chats: await this.#chatHistory(20), handlerProps: { invocation: this.invocation,