(request, options = {})
| 78 | } |
| 79 | |
| 80 | async createEmbedding(request, options = {}) { |
| 81 | const normalized = normalizeEmbeddingRequest(request); |
| 82 | const model = options.model || normalized.model || this.model; |
| 83 | if (!model) { |
| 84 | throw new Error('Embedding request is missing a model id.'); |
| 85 | } |
| 86 | |
| 87 | const { backendOptions, ...restOptions } = options; |
| 88 | if (backendOptions && this.backend?.configure) { |
| 89 | this.backend.configure(backendOptions); |
| 90 | } |
| 91 | |
| 92 | const backendOptionsResolved = { |
| 93 | ...restOptions, |
| 94 | backendId: options.backendId || normalized.backend_id || normalized.backendId || this.backendId |
| 95 | }; |
| 96 | |
| 97 | const response = await this.backend.createEmbedding({ |
| 98 | ...normalized, |
| 99 | model |
| 100 | }, backendOptionsResolved); |
| 101 | |
| 102 | return normalizeEmbeddingResponse(response, { model }); |
| 103 | } |
| 104 | |
| 105 | async embedText(text, options = {}) { |
| 106 | const response = await this.createEmbedding({ |
no test coverage detected