(
connection: LlmConnection,
apiKey: string,
model?: string,
options: ConnectionTestOptions = {},
)
| 66 | } |
| 67 | |
| 68 | export async function testConnection( |
| 69 | connection: LlmConnection, |
| 70 | apiKey: string, |
| 71 | model?: string, |
| 72 | options: ConnectionTestOptions = {}, |
| 73 | ): Promise<ConnectionTestResult> { |
| 74 | const t0 = Date.now(); |
| 75 | const configuredTimeoutMs = options.timeoutMs; |
| 76 | const timeoutMs = |
| 77 | typeof configuredTimeoutMs === 'number' && |
| 78 | Number.isFinite(configuredTimeoutMs) && |
| 79 | configuredTimeoutMs > 0 |
| 80 | ? Math.floor(configuredTimeoutMs) |
| 81 | : CONNECTION_TEST_TIMEOUT_MS; |
| 82 | try { |
| 83 | return await testConnectionStrict(connection, apiKey, model, options.fetch, t0, timeoutMs); |
| 84 | } catch (error) { |
| 85 | return connectionTestFailure(error, t0, true); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | export async function runConnectionTestEffect( |
| 90 | connection: ConnectionEffectConnection, |
no test coverage detected