Skip to content

Commit 6f00a11

Browse files
authored
Add embedding support for azure (#34)
1 parent f81253f commit 6f00a11

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

app/services/providers/azure_adapter.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ def process_streaming_chunk(chunk: bytes):
9090
return chunk
9191
return chunk
9292

93-
94-
9593
async def process_completion(
9694
self,
9795
endpoint: str,
@@ -109,6 +107,23 @@ async def process_completion(
109107
}
110108
return await super().process_completion(endpoint, payload, api_key, base_url, query_params)
111109

110+
async def process_embeddings(
111+
self,
112+
endpoint: str,
113+
payload: dict[str, Any],
114+
api_key: str,
115+
) -> Any:
116+
"""Process an embeddings request using Azure API"""
117+
# Azure API requires the model to be in the path
118+
model_id = payload["model"]
119+
del payload["model"]
120+
base_url = f"{self._base_url}/openai/deployments/{model_id}"
121+
122+
query_params = {
123+
"api-version": self.api_version,
124+
}
125+
return await super().process_embeddings(endpoint, payload, api_key, base_url, query_params)
126+
112127
async def list_models(self, api_key: str) -> list[str]:
113128
base_url = f"{self._base_url}/openai"
114129
query_params = {

0 commit comments

Comments
 (0)