Skip to content

Commit 25886b2

Browse files
xitzhangXiting Zhang
andauthored
[VoiceLive]Remove hardcoded localhost proxy and guard aiohttp import (#45595)
* Remove hardcoded localhost proxy and guard aiohttp import - Remove debug proxy block that unconditionally set proxy to localhost:8888 - Wrap aiohttp import in try/except with actionable install message * Remove unused __proxy_policy member from _VoiceLiveConnectionManager * Remove unused policies import from azure.core.pipeline --------- Co-authored-by: Xiting Zhang <xitzhang@microsoft.com>
1 parent 3db526d commit 25886b2

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

  • sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/aio

sdk/voicelive/azure-ai-voicelive/azure/ai/voicelive/aio/_patch.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717

1818
# === Third-party ===
1919
from typing_extensions import TypedDict
20-
import aiohttp
20+
21+
try:
22+
import aiohttp
23+
except ImportError as exc:
24+
raise ImportError(
25+
"aiohttp is required for azure-ai-voicelive. "
26+
"Install it with: pip install azure-ai-voicelive[aiohttp]"
27+
) from exc
2128
from azure.ai.voicelive.models._models import (
2229
ClientEventConversationItemCreate,
2330
ClientEventConversationItemDelete,
@@ -35,7 +42,6 @@
3542
from azure.core.credentials import AzureKeyCredential
3643
from azure.core.credentials_async import AsyncTokenCredential
3744
from azure.core.exceptions import AzureError
38-
from azure.core.pipeline import policies
3945

4046
# === Local ===
4147
from ..models import ClientEvent, ServerEvent, RequestSession
@@ -687,7 +693,6 @@ def __init__(
687693
self.__extra_query = extra_query
688694
self.__extra_headers = extra_headers
689695
self.__connection_options = self._map_to_aiohttp_ws_options(connection_options or {})
690-
self.__proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
691696

692697
def _map_to_aiohttp_ws_options(self, options: WebsocketConnectionOptions) -> dict[str, Any]:
693698
"""
@@ -770,12 +775,6 @@ async def __aenter__(self) -> VoiceLiveConnection:
770775
self.__connection_options.setdefault("max_msg_size", 4 * 1024 * 1024)
771776
self.__connection_options.setdefault("heartbeat", 30)
772777

773-
if self.__proxy_policy:
774-
self.__proxy_policy.proxies = {
775-
"http": "http://localhost:8888",
776-
"https": "http://localhost:8888",
777-
}
778-
779778
auth_headers = await self._get_auth_headers()
780779
headers = {**auth_headers, **dict(self.__extra_headers)}
781780

0 commit comments

Comments
 (0)