Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 the example persona config shown below.
Expand Down Expand Up @@ -84,7 +88,7 @@ const response = await fetch(`https://api.anam.ai/v1/auth/session-token`, {
name: 'Cara',
avatarId: '30fa96d0-26c4-4e55-94a0-517025942e18',
voiceId: '6bfbe25a-979d-40f3-a92b-5394170af54b',
brainType: 'ANAM_GPT_4O_MINI_V1',
llmId: '<LLM ID HERE>',
systemPrompt:
"[STYLE] Reply in natural speech without formatting. Add pauses using '...' and very occasionally a disfluency. [PERSONALITY] You are Cara, a helpful assistant.",
},
Expand Down
15 changes: 15 additions & 0 deletions src/modules/CoreApiRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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.',
);
}
Comment on lines +51 to +55
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation warning logic is duplicated in two methods. Consider extracting this into a private method to avoid code duplication.

Suggested change
if (personaConfig && 'brainType' in personaConfig) {
console.warn(
'Warning: brainType is deprecated and will be removed in a future version. Please use llmId instead.',
);
}
this._logDeprecationWarningForBrainType(personaConfig);

Copilot uses AI. Check for mistakes.

try {
const response = await fetch(`${this.getApiUrl()}/engine/session`, {
method: 'POST',
Expand Down Expand Up @@ -139,6 +146,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',
};
Expand Down
4 changes: 2 additions & 2 deletions src/types/PersonaConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface CustomPersonaConfig {
name: string;
avatarId: string;
voiceId: string;
brainType: string;
llmId?: string;
systemPrompt?: string;
maxSessionLengthSeconds?: number;
languageCode?: string;
Expand All @@ -14,5 +14,5 @@ export interface CustomPersonaConfig {
export function isCustomPersonaConfig(
personaConfig: PersonaConfig,
): personaConfig is CustomPersonaConfig {
return 'brainType' in personaConfig;
return 'brainType' in personaConfig || 'llmId' in personaConfig;
}