Skip to content

Commit e63b6d3

Browse files
Add .diff files for fern-ignored files
1 parent 8a95c05 commit e63b6d3

8 files changed

Lines changed: 1165 additions & 0 deletions

File tree

src/hume/client.py.diff

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
diff --git a/src/hume/client.py b/src/hume/client.py
2+
index 560c36a..b0b19e6 100644
3+
--- a/src/hume/client.py
4+
+++ b/src/hume/client.py
5+
@@ -1,94 +1,25 @@
6+
-# THIS FILE IS MANUALLY MAINTAINED: see .fernignore
7+
+# This file was auto-generated by Fern from our API Definition.
8+
9+
import typing
10+
11+
import httpx
12+
-
13+
from .base_client import AsyncBaseHumeClient, BaseHumeClient
14+
-
15+
+from .core.logging import LogConfig, Logger
16+
from .environment import HumeClientEnvironment
17+
18+
19+
-def _base_url_to_environment(base_url: str) -> HumeClientEnvironment:
20+
- if base_url.startswith("http://"):
21+
- return HumeClientEnvironment(
22+
- base=base_url,
23+
- evi=base_url.replace("http://", "ws://") + "/v0/evi",
24+
- tts=base_url.replace("http://", "ws://") + "/v0/tts",
25+
- stream=base_url.replace("http://", "ws://") + "/v0/stream",
26+
- )
27+
- elif base_url.startswith("https://"):
28+
- return HumeClientEnvironment(
29+
- base=base_url,
30+
- evi=base_url.replace("https://", "wss://") + "/v0/evi",
31+
- tts=base_url.replace("https://", "wss://") + "/v0/tts",
32+
- stream=base_url.replace("https://", "wss://") + "/v0/stream",
33+
- )
34+
- else:
35+
- # Assume https if no protocol specified
36+
- return HumeClientEnvironment(
37+
- base="https://" + base_url,
38+
- evi="wss://" + base_url + "/v0/evi",
39+
- tts="wss://" + base_url + "/v0/tts",
40+
- stream="wss://" + base_url + "/v0/stream",
41+
- )
42+
-
43+
-
44+
class HumeClient(BaseHumeClient):
45+
- """
46+
- Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
47+
-
48+
- Parameters
49+
- ----------
50+
- base_url : typing.Optional[str]
51+
- The base URL to use for requests from the client. If provided, this will be converted
52+
- to a HumeClientEnvironment. Can be a full URL (http://... or https://...) or just
53+
- a hostname (which will default to https://).
54+
- environment : typing.Optional[HumeClientEnvironment]
55+
- The environment to use for requests from the client. from .environment import HumeClientEnvironment
56+
- Defaults to None, which will use HumeClientEnvironment.PROD. Cannot be specified together with base_url.
57+
- api_key : typing.Optional[str]
58+
- timeout : typing.Optional[float]
59+
- The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
60+
-
61+
- follow_redirects : typing.Optional[bool]
62+
- Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
63+
-
64+
- httpx_client : typing.Optional[httpx.Client]
65+
- The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
66+
-
67+
- Examples
68+
- --------
69+
- from hume.client import HumeClient
70+
-
71+
- client = HumeClient(
72+
- api_key="YOUR_API_KEY",
73+
- )
74+
- """
75+
-
76+
def __init__(
77+
self,
78+
*,
79+
- base_url: typing.Optional[str] = None,
80+
- environment: typing.Optional[HumeClientEnvironment] = None,
81+
+ environment: HumeClientEnvironment = HumeClientEnvironment.PROD,
82+
api_key: typing.Optional[str] = None,
83+
headers: typing.Optional[typing.Dict[str, str]] = None,
84+
timeout: typing.Optional[float] = None,
85+
follow_redirects: typing.Optional[bool] = True,
86+
- httpx_client: typing.Optional[httpx.Client] = None
87+
+ httpx_client: typing.Optional[httpx.Client] = None,
88+
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
89+
):
90+
- # Error if both base_url and environment are specified
91+
- if base_url is not None and environment is not None:
92+
- raise ValueError("Cannot specify both 'base_url' and 'environment'. Please use only one.")
93+
-
94+
- # Convert base_url string to environment if provided
95+
- if base_url is not None:
96+
- environment = _base_url_to_environment(base_url)
97+
-
98+
- # Default to PROD if neither base_url nor environment was provided
99+
- if environment is None:
100+
- environment = HumeClientEnvironment.PROD
101+
-
102+
super().__init__(
103+
environment=environment,
104+
api_key=api_key,
105+
@@ -96,59 +27,22 @@ class HumeClient(BaseHumeClient):
106+
timeout=timeout,
107+
follow_redirects=follow_redirects,
108+
httpx_client=httpx_client,
109+
+ logging=logging,
110+
)
111+
112+
113+
class AsyncHumeClient(AsyncBaseHumeClient):
114+
- """
115+
- Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
116+
- Parameters
117+
- ----------
118+
- base_url : typing.Optional[str]
119+
- The base URL to use for requests from the client. If provided, this will be converted
120+
- to a HumeClientEnvironment. Can be a full URL (http://... or https://...) or just
121+
- a hostname (which will default to https://).
122+
- environment : typing.Optional[HumeClientEnvironment]
123+
- The environment to use for requests from the client. from .environment import HumeClientEnvironment
124+
- Defaults to None, which will use HumeClientEnvironment.PROD. Cannot be specified together with base_url.
125+
- api_key : typing.Optional[str]
126+
- timeout : typing.Optional[float]
127+
- The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
128+
- follow_redirects : typing.Optional[bool]
129+
- Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
130+
- httpx_client : typing.Optional[httpx.AsyncClient]
131+
- The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
132+
- Examples
133+
- --------
134+
- from hume.client import AsyncHumeClient
135+
- client = AsyncHumeClient(
136+
- api_key="YOUR_API_KEY",
137+
- )
138+
- """
139+
-
140+
def __init__(
141+
self,
142+
*,
143+
- base_url: typing.Optional[str] = None,
144+
- environment: typing.Optional[HumeClientEnvironment] = None,
145+
- headers: typing.Optional[typing.Dict[str, str]] = None,
146+
+ environment: HumeClientEnvironment = HumeClientEnvironment.PROD,
147+
api_key: typing.Optional[str] = None,
148+
+ headers: typing.Optional[typing.Dict[str, str]] = None,
149+
timeout: typing.Optional[float] = None,
150+
follow_redirects: typing.Optional[bool] = True,
151+
- httpx_client: typing.Optional[httpx.AsyncClient] = None
152+
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
153+
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
154+
):
155+
- # Error if both base_url and environment are specified
156+
- if base_url is not None and environment is not None:
157+
- raise ValueError("Cannot specify both 'base_url' and 'environment'. Please use only one.")
158+
-
159+
- # Convert base_url string to environment if provided
160+
- if base_url is not None:
161+
- environment = _base_url_to_environment(base_url)
162+
-
163+
- # Default to PROD if neither base_url nor environment was provided
164+
- if environment is None:
165+
- environment = HumeClientEnvironment.PROD
166+
-
167+
super().__init__(
168+
environment=environment,
169+
api_key=api_key,
170+
@@ -156,4 +50,5 @@ class AsyncHumeClient(AsyncBaseHumeClient):
171+
timeout=timeout,
172+
follow_redirects=follow_redirects,
173+
httpx_client=httpx_client,
174+
+ logging=logging,
175+
)
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
diff --git a/src/hume/empathic_voice/chat/client.py b/src/hume/empathic_voice/chat/client.py
2+
index 29b967a..95ee45a 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.sync.client as websockets_sync_client
14+
from ...core.api_error import ApiError
15+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
16+
+from ...core.jsonable_encoder import jsonable_encoder
17+
+from ...core.query_encoder import encode_query
18+
+from ...core.remove_none_from_dict import remove_none_from_dict
19+
from ...core.request_options import RequestOptions
20+
-from ...core.websocket_compat import InvalidWebSocketStatus, get_status_code
21+
from ...core.serialization import convert_and_respect_annotation_metadata
22+
-from ...core.query_encoder import single_query_encoder
23+
+from ...core.websocket_compat import InvalidWebSocketStatus, get_status_code
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,28 +115,32 @@ 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+
@@ -248,30 +254,32 @@ class AsyncChatClient:
92+
AsyncChatSocketClient
93+
"""
94+
ws_url = self._raw_client._client_wrapper.get_environment().evi + "/chat"
95+
- query_params = httpx.QueryParams()
96+
- if access_token is not None:
97+
- query_params = query_params.add("access_token", access_token)
98+
- if allow_connection is not None:
99+
- query_params = query_params.add("allow_connection", allow_connection)
100+
- if config_id is not None:
101+
- query_params = query_params.add("config_id", config_id)
102+
- if config_version is not None:
103+
- query_params = query_params.add("config_version", config_version)
104+
- if event_limit is not None:
105+
- query_params = query_params.add("event_limit", event_limit)
106+
- if resumed_chat_group_id is not None:
107+
- query_params = query_params.add("resumed_chat_group_id", resumed_chat_group_id)
108+
- if verbose_transcription is not None:
109+
- query_params = query_params.add("verbose_transcription", verbose_transcription)
110+
- if api_key is not None:
111+
- query_params = query_params.add("api_key", api_key)
112+
-
113+
- if session_settings is not None:
114+
- flattened_params = single_query_encoder("session_settings", session_settings)
115+
- for param_key, param_value in flattened_params:
116+
- query_params = query_params.add(param_key, param_value)
117+
-
118+
- ws_url = ws_url + f"?{query_params}"
119+
+ _encoded_query_params = encode_query(
120+
+ jsonable_encoder(
121+
+ remove_none_from_dict(
122+
+ {
123+
+ "access_token": access_token,
124+
+ "allow_connection": allow_connection,
125+
+ "config_id": config_id,
126+
+ "config_version": config_version,
127+
+ "event_limit": event_limit,
128+
+ "resumed_chat_group_id": resumed_chat_group_id,
129+
+ "verbose_transcription": verbose_transcription,
130+
+ "api_key": api_key,
131+
+ "session_settings": convert_and_respect_annotation_metadata(
132+
+ object_=session_settings, annotation=ConnectSessionSettings, direction="write"
133+
+ ),
134+
+ **(
135+
+ request_options.get("additional_query_parameters", {}) or {}
136+
+ if request_options is not None
137+
+ else {}
138+
+ ),
139+
+ }
140+
+ )
141+
+ )
142+
+ )
143+
+ if _encoded_query_params:
144+
+ ws_url = ws_url + "?" + urllib.parse.urlencode(_encoded_query_params)
145+
headers = self._raw_client._client_wrapper.get_headers()
146+
if request_options and "additional_headers" in request_options:
147+
headers.update(request_options["additional_headers"])

0 commit comments

Comments
 (0)