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
38 changes: 38 additions & 0 deletions packages/kernel-language-model-service/src/open-v1/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,44 @@
});
});

describe('listModels', () => {

Check failure on line 299 in packages/kernel-language-model-service/src/open-v1/base.test.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (24.x)

Describe is used multiple times in the same describe(suite) block
it('gETs /v1/models and returns model IDs', async () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('gETs /v1/models and returns model IDs', async () => {
it('gets /v1/models and returns model IDs', async () => {

const modelsFetch = makeMockFetch({
data: [{ id: 'model-a' }, { id: 'model-b' }],
});
const modelsService = new OpenV1BaseService(
modelsFetch,
'http://localhost:8080',
'sk-test',
);

const result = await modelsService.listModels();

expect(modelsFetch).toHaveBeenCalledWith(
'http://localhost:8080/v1/models',
expect.any(Object),
);
expect(result).toStrictEqual(['model-a', 'model-b']);
});

it('includes Authorization header when apiKey is set', async () => {
const modelsFetch = makeMockFetch({ data: [{ id: 'model-a' }] });
const modelsService = new OpenV1BaseService(
modelsFetch,
'http://localhost:8080',
'sk-key',
);

await modelsService.listModels();

const [, init] = (modelsFetch as ReturnType<typeof vi.fn>).mock
.calls[0] as [string, RequestInit];
expect((init.headers as Record<string, string>).Authorization).toBe(
'Bearer sk-key',
);
});
});

describe('chat with stream: true', () => {
it('posts to /v1/chat/completions with stream: true in body', async () => {
const streamFetch = makeMockStreamFetch([makeStreamChunk('hi')]);
Expand Down
Loading