Add optional modelID input for custom API Key Providers testing (#315)
* feat: add modelId fallback for provider validation - If /models endpoint unavailable, validate via /chat/completions - Add optional Model ID input in EditCompatibleNodeModal - Improves compatibility with providers lacking /models endpoint * feat: improve provider validation with modelId fallback - Add Model ID input for chat/completions fallback validation - Reorder UI: API Key → Model ID → Check button + Badge - Display detailed BE error messages in FE - Add status-specific error handling (401/403/400/404/5xx) - Add unit tests for error message helpers - Add vitest devDependency
This commit is contained in:
1 parent
1dd5d60724
commit
65af4328fd
4 files changed
+470
-57
No files matched your search
@@ -1987,6 +1987,7 @@ function EditCompatibleNodeModal({ isOpen, node, onSave, onClose, isAnthropic })
|
||||
});
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [checkKey, setCheckKey] = useState("");
|
||||
const [checkModelId, setCheckModelId] = useState("");
|
||||
const [validating, setValidating] = useState(false);
|
||||
const [validationResult, setValidationResult] = useState(null);
|
||||
|
||||
@@ -2030,10 +2031,11 @@ function EditCompatibleNodeModal({ isOpen, node, onSave, onClose, isAnthropic })
|
||||
const res = await fetch("/api/provider-nodes/validate", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
baseUrl: formData.baseUrl,
|
||||
apiKey: checkKey,
|
||||
type: isAnthropic ? "anthropic-compatible" : "openai-compatible"
|
||||
body: JSON.stringify({
|
||||
baseUrl: formData.baseUrl,
|
||||
apiKey: checkKey,
|
||||
type: isAnthropic ? "anthropic-compatible" : "openai-compatible",
|
||||
modelId: checkModelId.trim() || undefined
|
||||
}),
|
||||
});
|
||||
const data = await res.json();
|
||||
@@ -2093,6 +2095,13 @@ function EditCompatibleNodeModal({ isOpen, node, onSave, onClose, isAnthropic })
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Input
|
||||
label="Model ID (optional)"
|
||||
value={checkModelId}
|
||||
onChange={(e) => setCheckModelId(e.target.value)}
|
||||
placeholder="e.g. my-model-id"
|
||||
hint="If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."
|
||||
/>
|
||||
{validationResult && (
|
||||
<Badge variant={validationResult === "success" ? "success" : "error"}>
|
||||
{validationResult === "success" ? "Valid" : "Invalid"}
|
||||
|
||||
Reference in new issue
Block a user