From 7b94c1c2c3a3642cd5556a2f9b0acbd6ec513534 Mon Sep 17 00:00:00 2001 From: Jack Hessel Date: Wed, 14 Aug 2024 14:56:57 -0700 Subject: [PATCH] Update openai_chat_completions_client.py merged from https://github.com/ray-project/llmperf/pull/41 Signed-off-by: Jack Hessel --- src/llmperf/ray_clients/openai_chat_completions_client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/llmperf/ray_clients/openai_chat_completions_client.py b/src/llmperf/ray_clients/openai_chat_completions_client.py index f2e0a91..3f9ace2 100644 --- a/src/llmperf/ray_clients/openai_chat_completions_client.py +++ b/src/llmperf/ray_clients/openai_chat_completions_client.py @@ -59,6 +59,12 @@ def llm_request(self, request_config: RequestConfig) -> Dict[str, Any]: if not address.endswith("/"): address = address + "/" address += "chat/completions" + if "openai.azure.com" in address: + api_version = os.environ.get("OPENAI_API_VERSION") + if not api_version: + raise ValueError("the environment variable OPENAI_API_VERSION must be set for Azure OpenAI service.") + address = f"{address}?api-version={api_version}" + headers = {"api-key": key} # replace with Authorization: Bearer try: with requests.post( address,