fix(litellm): simplify onboarding by removing manual prompts
- Remove manual context window prompt when not auto-detected - Remove 'Enter custom model name' option from model selection - Throw error if model fetch fails instead of prompting for manual entry - Strip litellm/ prefix from API-returned model IDs to fix double prefix
This commit is contained in:
parent
2e0dd2ce72
commit
629c25c0e4
@ -750,54 +750,31 @@ export async function applyAuthChoiceApiProviders(
|
|||||||
label: m.id,
|
label: m.id,
|
||||||
hint: m.maxInputTokens ? `${Math.round(m.maxInputTokens / 1000)}k context` : undefined,
|
hint: m.maxInputTokens ? `${Math.round(m.maxInputTokens / 1000)}k context` : undefined,
|
||||||
}));
|
}));
|
||||||
modelOptions.push({ value: "__custom__", label: "Enter custom model name", hint: undefined });
|
|
||||||
|
|
||||||
const selectedModel = await params.prompter.select({
|
const selectedModel = await params.prompter.select({
|
||||||
message: `Select model (${availableModels.length} available)`,
|
message: `Select model (${availableModels.length} available)`,
|
||||||
options: modelOptions,
|
options: modelOptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (selectedModel === "__custom__") {
|
normalizedModelId = String(selectedModel);
|
||||||
const customModel = await params.prompter.text({
|
const modelInfo = availableModels.find((m) => m.id === normalizedModelId);
|
||||||
message: "Enter model name",
|
if (modelInfo?.maxInputTokens) {
|
||||||
validate: (value) => (value?.trim() ? undefined : "Model name is required"),
|
contextWindow = modelInfo.maxInputTokens;
|
||||||
});
|
}
|
||||||
normalizedModelId = String(customModel).trim();
|
if (modelInfo?.maxOutputTokens) {
|
||||||
} else {
|
maxTokens = modelInfo.maxOutputTokens;
|
||||||
normalizedModelId = String(selectedModel);
|
|
||||||
const modelInfo = availableModels.find((m) => m.id === normalizedModelId);
|
|
||||||
if (modelInfo?.maxInputTokens) {
|
|
||||||
contextWindow = modelInfo.maxInputTokens;
|
|
||||||
}
|
|
||||||
if (modelInfo?.maxOutputTokens) {
|
|
||||||
maxTokens = modelInfo.maxOutputTokens;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fall back to manual model entry
|
// No models available from LiteLLM - fail with error
|
||||||
const defaultModel = process.env.LITELLM_MODEL ?? "gpt-4";
|
throw new Error(
|
||||||
const modelId = await params.prompter.text({
|
"Could not fetch models from LiteLLM. Please ensure your LiteLLM server is running " +
|
||||||
message: "Enter model name (as configured in LiteLLM)",
|
`at ${normalizedBaseUrl} and accessible, or provide the model via --litellm-model flag.`,
|
||||||
initialValue: defaultModel,
|
);
|
||||||
placeholder: defaultModel,
|
|
||||||
validate: (value) => (value?.trim() ? undefined : "Model name is required"),
|
|
||||||
});
|
|
||||||
normalizedModelId = String(modelId).trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If context window wasn't auto-detected, prompt for it (skip in non-interactive mode)
|
// Strip litellm/ prefix if the API returned it (avoid litellm/litellm/model)
|
||||||
if (!contextWindow && !params.opts?.nonInteractive) {
|
if (normalizedModelId.startsWith("litellm/")) {
|
||||||
const contextInput = await params.prompter.text({
|
normalizedModelId = normalizedModelId.slice("litellm/".length);
|
||||||
message: "Enter context window size (tokens)",
|
|
||||||
initialValue: "128000",
|
|
||||||
placeholder: "128000",
|
|
||||||
validate: (value) => {
|
|
||||||
const num = Number(value);
|
|
||||||
if (Number.isNaN(num) || num <= 0) return "Must be a positive number";
|
|
||||||
return undefined;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
contextWindow = Number(contextInput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelRef = `litellm/${normalizedModelId}`;
|
const modelRef = `litellm/${normalizedModelId}`;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user