Add support for Azure deployment endpoints (#809)

pull/817/head
Yashwant Jodha 7 months ago committed by GitHub
parent 354e4f243d
commit 713b642d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -132,6 +132,9 @@ async def process_api_requests_from_file(
# infer API endpoint and construct request header
api_endpoint = api_endpoint_from_url(request_url)
request_header = {"Authorization": f"Bearer {api_key}"}
# use api-key header for Azure deployments
if '/deployments' in request_url:
request_header = {"api-key": f"{api_key}"}
# initialize trackers
queue_of_requests_to_retry = asyncio.Queue()
@ -366,6 +369,9 @@ class APIRequest:
def api_endpoint_from_url(request_url):
"""Extract the API endpoint from the request URL."""
match = re.search("^https://[^/]+/v\\d+/(.+)$", request_url)
if match is None:
# for Azure OpenAI deployment urls
match = re.search(r"^https://[^/]+/openai/deployments/[^/]+/(.+?)(\?|$)", request_url)
return match[1]

Loading…
Cancel
Save