diff --git a/src/agentic.ts b/src/agentic.ts index 8cd94fc..0f91442 100644 --- a/src/agentic.ts +++ b/src/agentic.ts @@ -56,12 +56,12 @@ export class Agentic { new HumanFeedbackMechanismCLI({ agentic: this }) } - public get openai(): types.openai.OpenAIClient { - return this._openai! + public get openai(): types.openai.OpenAIClient | undefined { + return this._openai } - public get anthropic(): types.anthropic.Client { - return this._anthropic! + public get anthropic(): types.anthropic.Client | undefined { + return this._anthropic } public get defaultHumanFeedbackMechamism() { diff --git a/src/anthropic.ts b/src/anthropic.ts index b0ca8f6..b1dd008 100644 --- a/src/anthropic.ts +++ b/src/anthropic.ts @@ -38,7 +38,13 @@ export class AnthropicChatModel< ...options }) - this._client = this._agentic.anthropic + if (this._agentic.anthropic) { + this._client = this._agentic.anthropic + } else { + throw new Error( + 'AnthropicChatModel requires an Anthropic client to be configured on the Agentic runtime' + ) + } } protected override async _createChatCompletion( diff --git a/src/openai.ts b/src/openai.ts index d37cdef..9785341 100644 --- a/src/openai.ts +++ b/src/openai.ts @@ -29,7 +29,13 @@ export class OpenAIChatModel< ...options }) - this._client = this._agentic.openai + if (this._agentic.openai) { + this._client = this._agentic.openai + } else { + throw new Error( + 'OpenAIChatModel requires an OpenAI client to be configured on the Agentic runtime' + ) + } } protected override async _createChatCompletion(