Skip to content

Commit

Permalink
Adding user agent to python client. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
glecaros authored Oct 3, 2024
1 parent 8a8ed91 commit 90b10df
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "rtclient"
version = "0.4.2"
version = "0.4.3"
description = "A client for the RT API"
authors = ["Microsoft Corporation"]

Expand Down
6 changes: 5 additions & 1 deletion python/rtclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def __init__(
self._azure_deployment = azure_deployment
self.request_id: Optional[uuid.UUID] = None

def _user_agent(self):
return "ms-rtclient-0.4.3"

def _get_auth(self):
if self._token_credential:
scopes = ["https://cognitiveservices.azure.com/.default"]
Expand All @@ -149,7 +152,7 @@ async def connect(self):
self.request_id = uuid.uuid4()
if self._is_azure_openai:
auth_headers = self._get_auth()
headers = {"x-ms-client-request-id": str(self.request_id), **auth_headers}
headers = {"x-ms-client-request-id": str(self.request_id), "User-Agent": self._user_agent(), **auth_headers}
self.ws = await self._session.ws_connect(
"/openai/realtime",
headers=headers,
Expand All @@ -159,6 +162,7 @@ async def connect(self):
headers = {
"Authorization": f"Bearer {self._key_credential.key}",
"openai-beta": "realtime=v1",
"User-Agent": self._user_agent(),
}
self.ws = await self._session.ws_connect("/v1/realtime", headers=headers, params={"model": self._model})

Expand Down
2 changes: 1 addition & 1 deletion python/samples/download-wheel.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$Owner = "Azure-Samples"
$Repo = "aoai-realtime-audio-sdk"
$Filter = "-py3-none-any.whl"
$Release = "py/v0.4.2"
$Release = "py/v0.4.3"
$OutputDir = "."

$apiUrl = "https://api.github.com/repos/$Owner/$Repo/releases/tags/$Release"
Expand Down
2 changes: 1 addition & 1 deletion python/samples/download-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
OWNER="Azure-Samples"
REPO="aoai-realtime-audio-sdk"
FILTER="-py3-none-any.whl"
RELEASE="py/v0.4.2"
RELEASE="py/v0.4.3"
OUTPUT_DIR="."

API_URL="https://api.github.com/repos/$OWNER/$REPO/releases/tags/$RELEASE"
Expand Down

0 comments on commit 90b10df

Please sign in to comment.