| 51 | } |
| 52 | |
| 53 | export function testFim(api: BaseLlmApi, model: string) { |
| 54 | test("should successfully fim", async () => { |
| 55 | const response = api.fimStream( |
| 56 | { |
| 57 | model: model, |
| 58 | prompt: "This is a ", |
| 59 | suffix: " .", |
| 60 | stream: true, |
| 61 | }, |
| 62 | new AbortController().signal, |
| 63 | ); |
| 64 | |
| 65 | let completion = ""; |
| 66 | for await (const result of response) { |
| 67 | expect(result.choices.length).toBeGreaterThan(0); |
| 68 | expect(typeof result.choices[0].delta.content).toBe("string"); |
| 69 | |
| 70 | completion += result.choices[0].delta.content; |
| 71 | } |
| 72 | |
| 73 | expect(completion.length).toBeGreaterThan(0); |
| 74 | }); |
| 75 | } |
| 76 | |
| 77 | export function testChat( |
| 78 | api: BaseLlmApi, |