(text, options = {})
| 103 | } |
| 104 | |
| 105 | async embedText(text, options = {}) { |
| 106 | const response = await this.createEmbedding({ |
| 107 | model: options.model || this.model, |
| 108 | input: text |
| 109 | }, options); |
| 110 | |
| 111 | const embedding = response.embeddings?.[0] || null; |
| 112 | if (!embedding) { |
| 113 | throw new Error('Embedding response did not include any vectors.'); |
| 114 | } |
| 115 | return embedding; |
| 116 | } |
| 117 | |
| 118 | async embedTexts(texts, options = {}) { |
| 119 | const response = await this.createEmbedding({ |
no test coverage detected