From e1e188514514c012badecb613c5e72a817729414 Mon Sep 17 00:00:00 2001 From: Harry Smaje Date: Tue, 24 Jun 2025 12:36:41 +0100 Subject: [PATCH] feat: pass through the LLM ID --- README.md | 6 +++++- src/modules/CoreApiRestClient.ts | 15 +++++++++++++++ src/types/PersonaConfig.ts | 5 +++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 25127de..3b92f33 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ First, install the SDK in your project npm install @anam-ai/js-sdk ``` +## Deprecation Notice + +**Important**: The `brainType` field in `PersonaConfig` is deprecated and will be removed in a future version. Please use `llmId` instead. If you are currently using `brainType`, you will see a deprecation warning in the console. Both fields are supported during the transition period. + ## Local development The quickest way to start testing the SDK is to use your API key directly with our SDK and [choose a default persona](#listing-personas) from our predefined examples. @@ -81,7 +85,7 @@ const response = await fetch(`https://api.anam.ai/v1/auth/session-token`, { personaConfig: { name: 'Test Assistant', personaPreset: 'eva', - brainType: 'ANAM_GPT_4O_MINI_V1', + llmId: 'ANAM_GPT_4O_MINI_V1', personality: 'You are a helpful and friendly AI assistant.', systemPrompt: 'You are an AI assistant focused on helping with technical questions.', diff --git a/src/modules/CoreApiRestClient.ts b/src/modules/CoreApiRestClient.ts index 9e7fa0d..fe2b91f 100644 --- a/src/modules/CoreApiRestClient.ts +++ b/src/modules/CoreApiRestClient.ts @@ -44,6 +44,13 @@ export class CoreApiRestClient { this.sessionToken = await this.unsafe_getSessionToken(personaConfig); } + // Check if brainType is being used and log deprecation warning + if (personaConfig && 'brainType' in personaConfig) { + console.warn( + 'Warning: brainType is deprecated and will be removed in a future version. Please use llmId instead.', + ); + } + try { const response = await fetch(`${this.getApiUrl()}/engine/session`, { method: 'POST', @@ -132,6 +139,14 @@ export class CoreApiRestClient { if (!this.apiKey) { throw new Error('No apiKey provided'); } + + // Check if brainType is being used and log deprecation warning + if (personaConfig && 'brainType' in personaConfig) { + console.warn( + 'Warning: brainType is deprecated and will be removed in a future version. Please use llmId instead.', + ); + } + let body: { clientLabel: string; personaConfig?: PersonaConfig } = { clientLabel: 'js-sdk-api-key', }; diff --git a/src/types/PersonaConfig.ts b/src/types/PersonaConfig.ts index d34b004..4cdd619 100644 --- a/src/types/PersonaConfig.ts +++ b/src/types/PersonaConfig.ts @@ -9,7 +9,8 @@ export interface SavedPersonaConfig { export interface CustomPersonaConfig { name: string; personaPreset: string; - brainType: string; + brainType?: string; + llmId?: string; systemPrompt?: string; personality: string; fillerPhrases: string[]; @@ -26,5 +27,5 @@ export function isSavedPersonaConfig( export function isCustomPersonaConfig( personaConfig: PersonaConfig, ): personaConfig is CustomPersonaConfig { - return 'brainType' in personaConfig; + return 'brainType' in personaConfig || 'llmId' in personaConfig; }