Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import Anthropic from '@anthropic-ai/sdk';
import * as Sentry from '@sentry/node';
import express from 'express';

const PORT = 3333;

function startMockAnthropicServer() {
const app = express();
app.use(express.json());
Expand Down Expand Up @@ -50,7 +48,7 @@ function startMockAnthropicServer() {
},
});
});
return app.listen(PORT);
return app.listen();
}

async function run() {
Expand All @@ -59,7 +57,7 @@ async function run() {
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
const client = new Anthropic({
apiKey: 'mock-api-key',
baseURL: `http://localhost:${PORT}/anthropic`,
baseURL: `http://localhost:${server.address().port}/anthropic`,
});

// First test: basic message completion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { GoogleGenAI } from '@google/genai';
import * as Sentry from '@sentry/node';
import express from 'express';

const PORT = 3333;

function startMockGoogleGenAIServer() {
const app = express();
app.use(express.json());
Expand Down Expand Up @@ -39,7 +37,7 @@ function startMockGoogleGenAIServer() {
});
});

return app.listen(PORT);
return app.listen();
}

async function run() {
Expand All @@ -48,7 +46,7 @@ async function run() {
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
const client = new GoogleGenAI({
apiKey: 'mock-api-key',
httpOptions: { baseUrl: `http://localhost:${PORT}` },
httpOptions: { baseUrl: `http://localhost:${server.address().port}` },
});

// Test 1: chats.create and sendMessage flow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import express from 'express';
import OpenAI from 'openai';

const PORT = 3333;

function startMockOpenAiServer() {
const app = express();
app.use(express.json());
Expand Down Expand Up @@ -31,14 +29,14 @@ function startMockOpenAiServer() {
},
});
});
return app.listen(PORT);
return app.listen();
}

async function run() {
const server = startMockOpenAiServer();

const client = new OpenAI({
baseURL: `http://localhost:${PORT}/openai`,
baseURL: `http://localhost:${server.address().port}/openai`,
apiKey: 'mock-api-key',
});

Expand Down
Loading