Anaplian support library for fetching the context window size for various models
npm install @anaplian/model-context-sizeA lightweight utility module for managing and retrieving context window sizes for various language models.
---
- Provides context size information for large language models.
- Includes type safety for model names.
---
``bash`
npm install @anaplian/model-context-size
---
`typescript`
import {
getModelContextSize,
isModelSupported,
} from '@anaplian/model-context-size';
`typescript\${modelName} is supported.
const modelName = 'gpt-4';
if (isModelSupported(modelName)) {
console.log();\${modelName} is not supported.
} else {
console.log();`
}
`typescriptContext size for \${modelName}: \${contextSize} tokens
const modelName = 'gpt-4';
if (isModelSupported(modelName)) {
const contextSize = getModelContextSize(modelName);
console.log();`
}
---
#### isModelSupported(modelName: string): boolean
Description:
Checks whether the given model name is supported.
Parameters:
- modelName _(string)_ - The name of the model to check.
Returns:
- boolean - true if the model is supported, otherwise false.
---
#### getModelContextSize(modelName: SupportedModelName): number
Description:
Retrieves the context window size (in tokens) for the specified model.
Parameters:
- modelName _(SupportedModelName)_ - The supported model name.
Returns:
- number` - The context size in tokens.
---
This project is licensed under the MIT License.