(chunks: string[])
| 41 | } |
| 42 | |
| 43 | protected async _embed(chunks: string[]): Promise<number[][]> { |
| 44 | const resp = await this.fetch(NCompass.embeddingsApiEndpoint, { |
| 45 | method: "POST", |
| 46 | body: JSON.stringify({ |
| 47 | input: chunks, |
| 48 | model: this.model, |
| 49 | ...this.extraBodyProperties(), |
| 50 | }), |
| 51 | headers: { |
| 52 | Authorization: `Bearer ${this.apiKey}`, |
| 53 | "Content-Type": "application/json", |
| 54 | }, |
| 55 | }); |
| 56 | |
| 57 | if (!resp.ok) { |
| 58 | throw new Error(await resp.text()); |
| 59 | } |
| 60 | |
| 61 | const data = (await resp.json()) as any; |
| 62 | return data.data.map((result: { embedding: number[] }) => result.embedding); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | export default NCompass; |
nothing calls this directly
no test coverage detected