mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-16 04:28:38 +00:00
* Chore: Pretier for consistant formatting - TODO: This PR needs to be updated by Saoud after he runs `npm install` & `npm format:fix` and commits the results of the prettier changes. * Revert prettier config * Run npm install * Fix prettier config and ignore package lock * Run format --------- Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
79 lines
2.5 KiB
TypeScript
79 lines
2.5 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 "openai":
|
|
if (
|
|
!apiConfiguration.openAiBaseUrl ||
|
|
!apiConfiguration.openAiApiKey ||
|
|
!apiConfiguration.openAiModelId
|
|
) {
|
|
return "You must provide a valid base URL, API key, and model ID."
|
|
}
|
|
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
|
|
}
|
|
}
|
|
return undefined
|
|
}
|
|
|
|
export function validateModelId(
|
|
apiConfiguration?: ApiConfiguration,
|
|
openRouterModels?: Record<string, ModelInfo>,
|
|
): string | undefined {
|
|
if (apiConfiguration) {
|
|
switch (apiConfiguration.apiProvider) {
|
|
case "openrouter":
|
|
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
|
|
}
|