mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 00:16:29 +02:00
Merge 13882f7c98 into 51f2ad6e8a
This commit is contained in:
commit
b4f875ea03
1 changed files with 20 additions and 1 deletions
|
|
@ -76,7 +76,18 @@ export async function testModelConnection(
|
||||||
timeoutMs?: number,
|
timeoutMs?: number,
|
||||||
): Promise<{ success: boolean; error?: string }> {
|
): Promise<{ success: boolean; error?: string }> {
|
||||||
const isLocal = providerConfig.flavor === "ollama" || providerConfig.flavor === "openai-compatible";
|
const isLocal = providerConfig.flavor === "ollama" || providerConfig.flavor === "openai-compatible";
|
||||||
const effectiveTimeout = timeoutMs ?? (isLocal ? 60000 : 8000);
|
// Cloud providers can occasionally take >8s for a small prompt, especially via aggregators like OpenRouter.
|
||||||
|
// Prefer a more forgiving default to avoid false negatives while still keeping the UI responsive.
|
||||||
|
let effectiveTimeout = timeoutMs;
|
||||||
|
if (effectiveTimeout == null) {
|
||||||
|
if (isLocal) {
|
||||||
|
effectiveTimeout = 60000;
|
||||||
|
} else if (providerConfig.flavor === "openrouter") {
|
||||||
|
effectiveTimeout = 60000;
|
||||||
|
} else {
|
||||||
|
effectiveTimeout = 20000;
|
||||||
|
}
|
||||||
|
}
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), effectiveTimeout);
|
const timeout = setTimeout(() => controller.abort(), effectiveTimeout);
|
||||||
try {
|
try {
|
||||||
|
|
@ -91,6 +102,14 @@ export async function testModelConnection(
|
||||||
});
|
});
|
||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
controller.signal.aborted ||
|
||||||
|
(error instanceof Error &&
|
||||||
|
(error.name === "AbortError" || /aborted/i.test(error.message)))
|
||||||
|
) {
|
||||||
|
return { success: false, error: `Connection test timed out after ${Math.round(effectiveTimeout / 1000)}s` };
|
||||||
|
}
|
||||||
|
|
||||||
const message = error instanceof Error ? error.message : "Connection test failed";
|
const message = error instanceof Error ? error.message : "Connection test failed";
|
||||||
return { success: false, error: message };
|
return { success: false, error: message };
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue