Skip to content

Commit

Permalink
Update openai_chat_completions_client.py
Browse files Browse the repository at this point in the history
based on ray-project#41

Signed-off-by: Jack Hessel <[email protected]>
  • Loading branch information
jmhessel authored Aug 14, 2024
1 parent 03872a4 commit 32a7296
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/llmperf/ray_clients/openai_chat_completions_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 32a7296

Please sign in to comment.