Skip to content

Commit 32a7296

Browse files
authored
Update openai_chat_completions_client.py
based on ray-project#41 Signed-off-by: Jack Hessel <[email protected]>
1 parent 03872a4 commit 32a7296

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/llmperf/ray_clients/openai_chat_completions_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def llm_request(self, request_config: RequestConfig) -> Dict[str, Any]:
5959
if not address.endswith("/"):
6060
address = address + "/"
6161
address += "chat/completions"
62+
if "openai.azure.com" in address:
63+
api_version = os.environ.get("OPENAI_API_VERSION")
64+
if not api_version:
65+
raise ValueError("the environment variable OPENAI_API_VERSION must be set for Azure OpenAI service.")
66+
address = f"{address}?api-version={api_version}"
67+
headers = {"api-key": key} # replace with Authorization: Bearer
6268
try:
6369
with requests.post(
6470
address,

0 commit comments

Comments
 (0)