* Set up branch * Feat/add sambanova provider (#2142) * feat(api): Add SambaNova provider type definitions - Add 'sambanova' to ApiProvider type - Add sambanovaApiKey to ApiHandlerOptions interface - Add SambaNova model definitions * feat(api): Implement SambaNova provider handler - Create SambanovaHandler class - Implement createMessage and getModel methods - Register the provider in the API factory * feat(ui): Add SambaNova provider UI components - Add SambaNova to provider dropdown - Add UI components for API key and model selection * feat(storage): Update secret storage for SambaNova API key - Update SecretKey type to include sambanovaApiKey - Update getState method to include the SambaNova API key - Update API configuration handler to store the SambaNova API key * feat(sambanova): format fix * feat(sambanova): adding previously untracked files * fix: will ensure that when no model ID is explicitly selected for the Sambanova provider, it will use the default model ID that's already defined in the codebase (Meta-Llama-3.3-70B-Instruct) * fix: changing how the dropdown is created by following existing pattern * fix: changing how the dropdown is created by following existing pattern * fix: added SamanovaHandler to buildApiHandler --------- Co-authored-by: saad.khan.hd <saad.khan@hd.digital> Co-authored-by: Dennis Bartlett <bartlett.dc.1@gmail.com> * support deepseek and qwen models * remove unused imports * Add missing API provider implementation --------- Co-authored-by: saad-noodleseed <saad@noodleseed.com> Co-authored-by: saad.khan.hd <saad.khan@hd.digital> Co-authored-by: Dennis Bartlett <bartlett.dc.1@gmail.com> Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
127 lines
4.1 KiB
TypeScript
127 lines
4.1 KiB
TypeScript
import { ApiConfiguration, openRouterDefaultModelId } from "../../../src/shared/api"
|
|
import { ModelInfo } from "../../../src/shared/api"
|
|
export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): string | undefined {
|
|
if (apiConfiguration) {
|
|
switch (apiConfiguration.apiProvider) {
|
|
case "anthropic":
|
|
if (!apiConfiguration.apiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "bedrock":
|
|
if (!apiConfiguration.awsRegion) {
|
|
return "You must choose a region to use with AWS Bedrock."
|
|
}
|
|
break
|
|
case "openrouter":
|
|
if (!apiConfiguration.openRouterApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "vertex":
|
|
if (!apiConfiguration.vertexProjectId || !apiConfiguration.vertexRegion) {
|
|
return "You must provide a valid Google Cloud Project ID and Region."
|
|
}
|
|
break
|
|
case "gemini":
|
|
if (!apiConfiguration.geminiApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "openai-native":
|
|
if (!apiConfiguration.openAiNativeApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "deepseek":
|
|
if (!apiConfiguration.deepSeekApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "xai":
|
|
if (!apiConfiguration.xaiApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "qwen":
|
|
if (!apiConfiguration.qwenApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "mistral":
|
|
if (!apiConfiguration.mistralApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "cline":
|
|
if (!apiConfiguration.clineApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "openai":
|
|
if (!apiConfiguration.openAiBaseUrl || !apiConfiguration.openAiApiKey || !apiConfiguration.openAiModelId) {
|
|
return "You must provide a valid base URL, API key, and model ID."
|
|
}
|
|
break
|
|
case "requesty":
|
|
if (!apiConfiguration.requestyApiKey || !apiConfiguration.requestyModelId) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "together":
|
|
if (!apiConfiguration.togetherApiKey || !apiConfiguration.togetherModelId) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "ollama":
|
|
if (!apiConfiguration.ollamaModelId) {
|
|
return "You must provide a valid model ID."
|
|
}
|
|
break
|
|
case "lmstudio":
|
|
if (!apiConfiguration.lmStudioModelId) {
|
|
return "You must provide a valid model ID."
|
|
}
|
|
break
|
|
case "vscode-lm":
|
|
if (!apiConfiguration.vsCodeLmModelSelector) {
|
|
return "You must provide a valid model selector."
|
|
}
|
|
break
|
|
case "asksage":
|
|
if (!apiConfiguration.asksageApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
case "sambanova":
|
|
if (!apiConfiguration.sambanovaApiKey) {
|
|
return "You must provide a valid API key or choose a different provider."
|
|
}
|
|
break
|
|
}
|
|
}
|
|
return undefined
|
|
}
|
|
|
|
export function validateModelId(
|
|
apiConfiguration?: ApiConfiguration,
|
|
openRouterModels?: Record<string, ModelInfo>,
|
|
): string | undefined {
|
|
if (apiConfiguration) {
|
|
switch (apiConfiguration.apiProvider) {
|
|
case "openrouter":
|
|
case "cline":
|
|
const modelId = apiConfiguration.openRouterModelId || openRouterDefaultModelId // in case the user hasn't changed the model id, it will be undefined by default
|
|
if (!modelId) {
|
|
return "You must provide a model ID."
|
|
}
|
|
if (openRouterModels && !Object.keys(openRouterModels).includes(modelId)) {
|
|
// even if the model list endpoint failed, extensionstatecontext will always have the default model info
|
|
return "The model ID you provided is not available. Please choose a different model."
|
|
}
|
|
break
|
|
}
|
|
}
|
|
return undefined
|
|
}
|