(modelId: ModelId)
| 97 | * Create a language model instance from a ModelId |
| 98 | */ |
| 99 | export function createModel(modelId: ModelId): LanguageModel { |
| 100 | const config = MODEL_CONFIG[modelId]; |
| 101 | if (!config) { |
| 102 | throw new Error( |
| 103 | `Unknown model: ${modelId}. Supported models: ${getSupportedModels().join(', ')}`, |
| 104 | ); |
| 105 | } |
| 106 | |
| 107 | if (config.provider === 'anthropic') { |
| 108 | return anthropic(config.modelId); |
| 109 | } else if (config.provider === 'baseten') { |
| 110 | return getBasetenProvider()(config.modelId); |
| 111 | } else if (config.provider === 'modal') { |
| 112 | return getModalProvider()(config.modelId); |
| 113 | } else { |
| 114 | return openai(config.modelId); |
| 115 | } |
| 116 | } |
no test coverage detected