Skip to content

Commit

Permalink
test: timeout for embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcadams committed Nov 8, 2023
1 parent 544a636 commit 1208da4
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/openai/embedding.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@ const hopfield = hop.client(openai).provider(openAIClient);
const embeddings = hopfield.embedding();
const multipleEmbeddings = hopfield.embedding('text-embedding-ada-002', 3);

test('should respond with embedding', async () => {
const response = await embeddings.get({
input: ['hopfield'],
});
test(
'should respond with embedding',
async () => {
const response = await embeddings.get({
input: ['hopfield'],
});

expect(response.model).toMatchInlineSnapshot('"text-embedding-ada-002-v2"');
expect(response.data[0].embedding[0]).toBeCloseTo(-0.0073666335, 2);
expect(response.data[0].embedding[1535]).toBeCloseTo(-0.0013278616, 2);
});
expect(response.model).toMatchInlineSnapshot('"text-embedding-ada-002-v2"');
expect(response.data[0].embedding[0]).toBeCloseTo(-0.0073666335, 2);
expect(response.data[0].embedding[1535]).toBeCloseTo(-0.0013278616, 2);
},
{ timeout: 10_000 },
);

test('should respond with multiple embeddings', async () => {
const response = await multipleEmbeddings.get({
input: ['ready', 'set', 'hopfield'],
});
test(
'should respond with multiple embeddings',
async () => {
const response = await multipleEmbeddings.get({
input: ['ready', 'set', 'hopfield'],
});

expect(response.model).toMatchInlineSnapshot('"text-embedding-ada-002-v2"');
expect(response.data[0].embedding[0]).toBeCloseTo(-0.009482461, 2);
expect(response.data[2].embedding[0]).toBeCloseTo(-0.0073666335, 2);
});
expect(response.model).toMatchInlineSnapshot('"text-embedding-ada-002-v2"');
expect(response.data[0].embedding[0]).toBeCloseTo(-0.009482461, 2);
expect(response.data[2].embedding[0]).toBeCloseTo(-0.0073666335, 2);
},
{ timeout: 10_000 },
);

1 comment on commit 1208da4

@vercel
Copy link

@vercel vercel bot commented on 1208da4 Nov 8, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.