Skip to content

Commit ba413f2

Browse files
committed
simplify cli args
1 parent 0923888 commit ba413f2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

scripts/realtime_operator.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tempfile
88
import webbrowser
99
from pathlib import Path
10+
from urllib.parse import urljoin
1011

1112
# New imports for template rendering and serving
1213
import jinja2
@@ -108,14 +109,7 @@ def webrtc(
108109
),
109110
host: str = typer.Option("0.0.0.0", "--host", "-h"),
110111
port: int = typer.Option(8080, "--port", "-p"),
111-
web_rtc_url: str = typer.Option(
112-
"https://eastus2.realtimeapi-preview.ai.azure.com/v1/realtimertc", "--webrtc-url", help="WebRTC endpoint URL"
113-
),
114-
sessions_url: str = typer.Option(
115-
"https://YourAzureOpenAIResourceName.openai.azure.com/openai/realtimeapi/sessions?api-version=2025-04-01-preview",
116-
"--sessions-url",
117-
help="Sessions API URL",
118-
),
112+
location: str = typer.Option("eastus2", "--location", help="location for Azure OpenAI"),
119113
deployment: str = typer.Option("gpt-realtime", "--deployment", help="Deployment name"),
120114
voice: str = typer.Option("verse", "--voice", help="Voice name"),
121115
instructions: str = typer.Option(
@@ -147,8 +141,10 @@ def webrtc(
147141

148142
# Use json.dumps to safely embed JS string literals in the template
149143
rendered = jinja2.Template(tpl_text).render(
150-
WEBRTC_URL=json.dumps(web_rtc_url),
151-
SESSIONS_URL=json.dumps(sessions_url),
144+
WEBRTC_URL=json.dumps(f"https://{location}.realtimeapi-preview.ai.azure.com/v1/realtimertc"),
145+
SESSIONS_URL=json.dumps(
146+
urljoin(settings.azure_openai_endpoint, "/openai/realtimeapi/sessions?api-version=2025-04-01-preview")
147+
),
152148
API_KEY=json.dumps(api_key),
153149
DEPLOYMENT=json.dumps(deployment),
154150
VOICE=json.dumps(voice),

0 commit comments

Comments
 (0)