Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion typescript/tests/model.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function makeErrorResponse(status, statusText, retryAfterSec = null) {

let capturedRequests = [];
let mockResponses = [];
const nativeFetch = globalThis.fetch;

function setupFetch(responses) {
capturedRequests = [];
Expand All @@ -91,7 +92,7 @@ function setupFetch(responses) {
}

function teardownFetch() {
delete globalThis.fetch;
globalThis.fetch = nativeFetch;
capturedRequests = [];
mockResponses = [];
}
Expand Down Expand Up @@ -343,6 +344,20 @@ describe("createOpenAILanguageModel (Responses API path)", () => {
// createLanguageModel env-var routing
// ---------------------------------------------------------------------------

describe("createLanguageModel live API integration", () => {
test("calls the configured API when live tests are explicitly enabled", {
skip: process.env.TYPECHAT_LIVE_TESTS !== "1" || !process.env.OPENAI_API_KEY || !process.env.OPENAI_MODEL,
}, async () => {
const model = createLanguageModel(process.env);
model.timeoutMs = 30_000;
model.retryMaxAttempts = 0;
const result = await model.complete("Reply with the single word: pong");
assert.equal(result.success, true, result.message);
assert.equal(typeof result.data, "string");
assert.notEqual(result.data.trim(), "");
});
});

describe("createLanguageModel environment variable routing", () => {
after(teardownFetch);

Expand Down