| 121 | } |
| 122 | |
| 123 | function buildAzureOpenAIProvider( |
| 124 | deployment: string, |
| 125 | apiKey: string, |
| 126 | endpoint: string, |
| 127 | apiVersion: string |
| 128 | ): ResolvedProvider['buildRequest'] { |
| 129 | return (inputs) => ({ |
| 130 | apiUrl: `${endpoint}/openai/deployments/${deployment}/embeddings?api-version=${apiVersion}`, |
| 131 | headers: { |
| 132 | 'api-key': apiKey, |
| 133 | 'Content-Type': 'application/json', |
| 134 | }, |
| 135 | body: { |
| 136 | input: inputs, |
| 137 | encoding_format: 'float', |
| 138 | dimensions: EMBEDDING_DIMENSIONS, |
| 139 | }, |
| 140 | parse: (json) => { |
| 141 | const data = json as { data: Array<{ embedding: number[] }> } |
| 142 | return data.data.map((item) => item.embedding) |
| 143 | }, |
| 144 | }) |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Gemini does NOT auto-normalize embeddings when `outputDimensionality` is set below the |