Skip to content

Commit c67fe6e

Browse files
Add .diff files for fern-ignored files
1 parent 7deb0fb commit c67fe6e

File tree

7 files changed

+1009
-0
lines changed

7 files changed

+1009
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
diff --git a/src/hume/empathic_voice/chat/client.py b/src/hume/empathic_voice/chat/client.py
2+
index 29b967a..8c64403 100644
3+
--- a/src/hume/empathic_voice/chat/client.py
4+
+++ b/src/hume/empathic_voice/chat/client.py
5+
@@ -1,16 +1,18 @@
6+
# This file was auto-generated by Fern from our API Definition.
7+
8+
import typing
9+
+import urllib.parse
10+
from contextlib import asynccontextmanager, contextmanager
11+
12+
-import httpx
13+
+import websockets.exceptions
14+
import websockets.sync.client as websockets_sync_client
15+
from ...core.api_error import ApiError
16+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
17+
+from ...core.jsonable_encoder import jsonable_encoder
18+
+from ...core.query_encoder import encode_query
19+
+from ...core.remove_none_from_dict import remove_none_from_dict
20+
from ...core.request_options import RequestOptions
21+
-from ...core.websocket_compat import InvalidWebSocketStatus, get_status_code
22+
from ...core.serialization import convert_and_respect_annotation_metadata
23+
-from ...core.query_encoder import single_query_encoder
24+
from ..types.connect_session_settings import ConnectSessionSettings
25+
from .raw_client import AsyncRawChatClient, RawChatClient
26+
from .socket_client import AsyncChatSocketClient, ChatSocketClient
27+
@@ -103,7 +105,7 @@ class ChatClient:
28+
29+
api_key : typing.Optional[str]
30+
31+
- session_settings : ConnectSessionSettings
32+
+ session_settings : typing.Optional[ConnectSessionSettings]
33+
34+
request_options : typing.Optional[RequestOptions]
35+
Request-specific configuration.
36+
@@ -113,36 +115,40 @@ class ChatClient:
37+
ChatSocketClient
38+
"""
39+
ws_url = self._raw_client._client_wrapper.get_environment().evi + "/chat"
40+
- query_params = httpx.QueryParams()
41+
- if access_token is not None:
42+
- query_params = query_params.add("access_token", access_token)
43+
- if allow_connection is not None:
44+
- query_params = query_params.add("allow_connection", allow_connection)
45+
- if config_id is not None:
46+
- query_params = query_params.add("config_id", config_id)
47+
- if config_version is not None:
48+
- query_params = query_params.add("config_version", config_version)
49+
- if event_limit is not None:
50+
- query_params = query_params.add("event_limit", event_limit)
51+
- if resumed_chat_group_id is not None:
52+
- query_params = query_params.add("resumed_chat_group_id", resumed_chat_group_id)
53+
- if verbose_transcription is not None:
54+
- query_params = query_params.add("verbose_transcription", verbose_transcription)
55+
- if api_key is not None:
56+
- query_params = query_params.add("api_key", api_key)
57+
- if session_settings is not None:
58+
- flattened_params = single_query_encoder("session_settings", session_settings)
59+
- for param_key, param_value in flattened_params:
60+
- query_params = query_params.add(param_key, param_value)
61+
- ws_url = ws_url + f"?{query_params}"
62+
+ _encoded_query_params = encode_query(
63+
+ jsonable_encoder(
64+
+ remove_none_from_dict(
65+
+ {
66+
+ "access_token": access_token,
67+
+ "allow_connection": allow_connection,
68+
+ "config_id": config_id,
69+
+ "config_version": config_version,
70+
+ "event_limit": event_limit,
71+
+ "resumed_chat_group_id": resumed_chat_group_id,
72+
+ "verbose_transcription": verbose_transcription,
73+
+ "api_key": api_key,
74+
+ "session_settings": convert_and_respect_annotation_metadata(
75+
+ object_=session_settings, annotation=ConnectSessionSettings, direction="write"
76+
+ ),
77+
+ **(
78+
+ request_options.get("additional_query_parameters", {}) or {}
79+
+ if request_options is not None
80+
+ else {}
81+
+ ),
82+
+ }
83+
+ )
84+
+ )
85+
+ )
86+
+ if _encoded_query_params:
87+
+ ws_url = ws_url + "?" + urllib.parse.urlencode(_encoded_query_params)
88+
headers = self._raw_client._client_wrapper.get_headers()
89+
if request_options and "additional_headers" in request_options:
90+
headers.update(request_options["additional_headers"])
91+
try:
92+
with websockets_sync_client.connect(ws_url, additional_headers=headers) as protocol:
93+
yield ChatSocketClient(websocket=protocol)
94+
- except InvalidWebSocketStatus as exc:
95+
- status_code: int = get_status_code(exc)
96+
+ except websockets.exceptions.InvalidStatusCode as exc:
97+
+ status_code: int = exc.status_code
98+
if status_code == 401:
99+
raise ApiError(
100+
status_code=status_code,
101+
@@ -248,38 +254,40 @@ class AsyncChatClient:
102+
AsyncChatSocketClient
103+
"""
104+
ws_url = self._raw_client._client_wrapper.get_environment().evi + "/chat"
105+
- query_params = httpx.QueryParams()
106+
- if access_token is not None:
107+
- query_params = query_params.add("access_token", access_token)
108+
- if allow_connection is not None:
109+
- query_params = query_params.add("allow_connection", allow_connection)
110+
- if config_id is not None:
111+
- query_params = query_params.add("config_id", config_id)
112+
- if config_version is not None:
113+
- query_params = query_params.add("config_version", config_version)
114+
- if event_limit is not None:
115+
- query_params = query_params.add("event_limit", event_limit)
116+
- if resumed_chat_group_id is not None:
117+
- query_params = query_params.add("resumed_chat_group_id", resumed_chat_group_id)
118+
- if verbose_transcription is not None:
119+
- query_params = query_params.add("verbose_transcription", verbose_transcription)
120+
- if api_key is not None:
121+
- query_params = query_params.add("api_key", api_key)
122+
-
123+
- if session_settings is not None:
124+
- flattened_params = single_query_encoder("session_settings", session_settings)
125+
- for param_key, param_value in flattened_params:
126+
- query_params = query_params.add(param_key, param_value)
127+
-
128+
- ws_url = ws_url + f"?{query_params}"
129+
+ _encoded_query_params = encode_query(
130+
+ jsonable_encoder(
131+
+ remove_none_from_dict(
132+
+ {
133+
+ "access_token": access_token,
134+
+ "allow_connection": allow_connection,
135+
+ "config_id": config_id,
136+
+ "config_version": config_version,
137+
+ "event_limit": event_limit,
138+
+ "resumed_chat_group_id": resumed_chat_group_id,
139+
+ "verbose_transcription": verbose_transcription,
140+
+ "api_key": api_key,
141+
+ "session_settings": convert_and_respect_annotation_metadata(
142+
+ object_=session_settings, annotation=ConnectSessionSettings, direction="write"
143+
+ ),
144+
+ **(
145+
+ request_options.get("additional_query_parameters", {}) or {}
146+
+ if request_options is not None
147+
+ else {}
148+
+ ),
149+
+ }
150+
+ )
151+
+ )
152+
+ )
153+
+ if _encoded_query_params:
154+
+ ws_url = ws_url + "?" + urllib.parse.urlencode(_encoded_query_params)
155+
headers = self._raw_client._client_wrapper.get_headers()
156+
if request_options and "additional_headers" in request_options:
157+
headers.update(request_options["additional_headers"])
158+
try:
159+
async with websockets_client_connect(ws_url, extra_headers=headers) as protocol:
160+
yield AsyncChatSocketClient(websocket=protocol)
161+
- except InvalidWebSocketStatus as exc:
162+
- status_code: int = get_status_code(exc)
163+
+ except websockets.exceptions.InvalidStatusCode as exc:
164+
+ status_code: int = exc.status_code
165+
if status_code == 401:
166+
raise ApiError(
167+
status_code=status_code,

0 commit comments

Comments
 (0)