| 28 | } |
| 29 | |
| 30 | export function testRerank(api: BaseLlmApi, model: string) { |
| 31 | test("should successfully rerank", async () => { |
| 32 | const response = await api.rerank({ |
| 33 | model: model, |
| 34 | query: "What is the capital of spain?", |
| 35 | documents: [ |
| 36 | "The capital of spain is Madrid", |
| 37 | "The largest breed of dog is the Great Dane", |
| 38 | ], |
| 39 | }); |
| 40 | expect(response.model).toBe(model); |
| 41 | expect(response.object).toBe("list"); |
| 42 | expect(response.data.length).toEqual(2); |
| 43 | response.data.forEach((val, index) => { |
| 44 | expect(val.index).toBe(index); |
| 45 | expect(typeof val.relevance_score).toBe("number"); |
| 46 | }); |
| 47 | expect(response.data[0].relevance_score).toBeGreaterThan( |
| 48 | response.data[1].relevance_score, |
| 49 | ); |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | export function testFim(api: BaseLlmApi, model: string) { |
| 54 | test("should successfully fim", async () => { |