Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@
}
]
},
"sdkVersion": "0.13.9"
"sdkVersion": "0.13.10"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dynamic = ["version"]

[tool.poetry]
name = "hume"
version = "0.13.9"
version = "0.13.10"
description = "A Python SDK for Hume AI"
readme = "README.md"
authors = []
Expand Down
175 changes: 175 additions & 0 deletions src/hume/client.py.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
diff --git a/src/hume/client.py b/src/hume/client.py
index 560c36a..b0b19e6 100644
--- a/src/hume/client.py
+++ b/src/hume/client.py
@@ -1,94 +1,25 @@
-# THIS FILE IS MANUALLY MAINTAINED: see .fernignore
+# This file was auto-generated by Fern from our API Definition.

import typing

import httpx
-
from .base_client import AsyncBaseHumeClient, BaseHumeClient
-
+from .core.logging import LogConfig, Logger
from .environment import HumeClientEnvironment


-def _base_url_to_environment(base_url: str) -> HumeClientEnvironment:
- if base_url.startswith("http://"):
- return HumeClientEnvironment(
- base=base_url,
- evi=base_url.replace("http://", "ws://") + "/v0/evi",
- tts=base_url.replace("http://", "ws://") + "/v0/tts",
- stream=base_url.replace("http://", "ws://") + "/v0/stream",
- )
- elif base_url.startswith("https://"):
- return HumeClientEnvironment(
- base=base_url,
- evi=base_url.replace("https://", "wss://") + "/v0/evi",
- tts=base_url.replace("https://", "wss://") + "/v0/tts",
- stream=base_url.replace("https://", "wss://") + "/v0/stream",
- )
- else:
- # Assume https if no protocol specified
- return HumeClientEnvironment(
- base="https://" + base_url,
- evi="wss://" + base_url + "/v0/evi",
- tts="wss://" + base_url + "/v0/tts",
- stream="wss://" + base_url + "/v0/stream",
- )
-
-
class HumeClient(BaseHumeClient):
- """
- 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.
-
- Parameters
- ----------
- base_url : typing.Optional[str]
- The base URL to use for requests from the client. If provided, this will be converted
- to a HumeClientEnvironment. Can be a full URL (http://... or https://...) or just
- a hostname (which will default to https://).
- environment : typing.Optional[HumeClientEnvironment]
- The environment to use for requests from the client. from .environment import HumeClientEnvironment
- Defaults to None, which will use HumeClientEnvironment.PROD. Cannot be specified together with base_url.
- api_key : typing.Optional[str]
- timeout : typing.Optional[float]
- 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.
-
- follow_redirects : typing.Optional[bool]
- Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
-
- httpx_client : typing.Optional[httpx.Client]
- 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.
-
- Examples
- --------
- from hume.client import HumeClient
-
- client = HumeClient(
- api_key="YOUR_API_KEY",
- )
- """
-
def __init__(
self,
*,
- base_url: typing.Optional[str] = None,
- environment: typing.Optional[HumeClientEnvironment] = None,
+ environment: HumeClientEnvironment = HumeClientEnvironment.PROD,
api_key: typing.Optional[str] = None,
headers: typing.Optional[typing.Dict[str, str]] = None,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
- httpx_client: typing.Optional[httpx.Client] = None
+ httpx_client: typing.Optional[httpx.Client] = None,
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
):
- # Error if both base_url and environment are specified
- if base_url is not None and environment is not None:
- raise ValueError("Cannot specify both 'base_url' and 'environment'. Please use only one.")
-
- # Convert base_url string to environment if provided
- if base_url is not None:
- environment = _base_url_to_environment(base_url)
-
- # Default to PROD if neither base_url nor environment was provided
- if environment is None:
- environment = HumeClientEnvironment.PROD
-
super().__init__(
environment=environment,
api_key=api_key,
@@ -96,59 +27,22 @@ class HumeClient(BaseHumeClient):
timeout=timeout,
follow_redirects=follow_redirects,
httpx_client=httpx_client,
+ logging=logging,
)


class AsyncHumeClient(AsyncBaseHumeClient):
- """
- 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.
- Parameters
- ----------
- base_url : typing.Optional[str]
- The base URL to use for requests from the client. If provided, this will be converted
- to a HumeClientEnvironment. Can be a full URL (http://... or https://...) or just
- a hostname (which will default to https://).
- environment : typing.Optional[HumeClientEnvironment]
- The environment to use for requests from the client. from .environment import HumeClientEnvironment
- Defaults to None, which will use HumeClientEnvironment.PROD. Cannot be specified together with base_url.
- api_key : typing.Optional[str]
- timeout : typing.Optional[float]
- 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.
- follow_redirects : typing.Optional[bool]
- Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
- httpx_client : typing.Optional[httpx.AsyncClient]
- 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.
- Examples
- --------
- from hume.client import AsyncHumeClient
- client = AsyncHumeClient(
- api_key="YOUR_API_KEY",
- )
- """
-
def __init__(
self,
*,
- base_url: typing.Optional[str] = None,
- environment: typing.Optional[HumeClientEnvironment] = None,
- headers: typing.Optional[typing.Dict[str, str]] = None,
+ environment: HumeClientEnvironment = HumeClientEnvironment.PROD,
api_key: typing.Optional[str] = None,
+ headers: typing.Optional[typing.Dict[str, str]] = None,
timeout: typing.Optional[float] = None,
follow_redirects: typing.Optional[bool] = True,
- httpx_client: typing.Optional[httpx.AsyncClient] = None
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
):
- # Error if both base_url and environment are specified
- if base_url is not None and environment is not None:
- raise ValueError("Cannot specify both 'base_url' and 'environment'. Please use only one.")
-
- # Convert base_url string to environment if provided
- if base_url is not None:
- environment = _base_url_to_environment(base_url)
-
- # Default to PROD if neither base_url nor environment was provided
- if environment is None:
- environment = HumeClientEnvironment.PROD
-
super().__init__(
environment=environment,
api_key=api_key,
@@ -156,4 +50,5 @@ class AsyncHumeClient(AsyncBaseHumeClient):
timeout=timeout,
follow_redirects=follow_redirects,
httpx_client=httpx_client,
+ logging=logging,
)
4 changes: 2 additions & 2 deletions src/hume/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def get_headers(self) -> typing.Dict[str, str]:
import platform

headers: typing.Dict[str, str] = {
"User-Agent": "hume/0.13.9",
"User-Agent": "hume/0.13.10",
"X-Fern-Language": "Python",
"X-Fern-Runtime": f"python/{platform.python_version()}",
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
"X-Fern-SDK-Name": "hume",
"X-Fern-SDK-Version": "0.13.9",
"X-Fern-SDK-Version": "0.13.10",
**(self.get_custom_headers() or {}),
}
if self.api_key is not None:
Expand Down
147 changes: 147 additions & 0 deletions src/hume/empathic_voice/chat/client.py.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
diff --git a/src/hume/empathic_voice/chat/client.py b/src/hume/empathic_voice/chat/client.py
index 29b967a..95ee45a 100644
--- a/src/hume/empathic_voice/chat/client.py
+++ b/src/hume/empathic_voice/chat/client.py
@@ -1,16 +1,18 @@
# This file was auto-generated by Fern from our API Definition.

import typing
+import urllib.parse
from contextlib import asynccontextmanager, contextmanager

-import httpx
import websockets.sync.client as websockets_sync_client
from ...core.api_error import ApiError
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
+from ...core.jsonable_encoder import jsonable_encoder
+from ...core.query_encoder import encode_query
+from ...core.remove_none_from_dict import remove_none_from_dict
from ...core.request_options import RequestOptions
-from ...core.websocket_compat import InvalidWebSocketStatus, get_status_code
from ...core.serialization import convert_and_respect_annotation_metadata
-from ...core.query_encoder import single_query_encoder
+from ...core.websocket_compat import InvalidWebSocketStatus, get_status_code
from ..types.connect_session_settings import ConnectSessionSettings
from .raw_client import AsyncRawChatClient, RawChatClient
from .socket_client import AsyncChatSocketClient, ChatSocketClient
@@ -103,7 +105,7 @@ class ChatClient:

api_key : typing.Optional[str]

- session_settings : ConnectSessionSettings
+ session_settings : typing.Optional[ConnectSessionSettings]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.
@@ -113,28 +115,32 @@ class ChatClient:
ChatSocketClient
"""
ws_url = self._raw_client._client_wrapper.get_environment().evi + "/chat"
- query_params = httpx.QueryParams()
- if access_token is not None:
- query_params = query_params.add("access_token", access_token)
- if allow_connection is not None:
- query_params = query_params.add("allow_connection", allow_connection)
- if config_id is not None:
- query_params = query_params.add("config_id", config_id)
- if config_version is not None:
- query_params = query_params.add("config_version", config_version)
- if event_limit is not None:
- query_params = query_params.add("event_limit", event_limit)
- if resumed_chat_group_id is not None:
- query_params = query_params.add("resumed_chat_group_id", resumed_chat_group_id)
- if verbose_transcription is not None:
- query_params = query_params.add("verbose_transcription", verbose_transcription)
- if api_key is not None:
- query_params = query_params.add("api_key", api_key)
- if session_settings is not None:
- flattened_params = single_query_encoder("session_settings", session_settings)
- for param_key, param_value in flattened_params:
- query_params = query_params.add(param_key, param_value)
- ws_url = ws_url + f"?{query_params}"
+ _encoded_query_params = encode_query(
+ jsonable_encoder(
+ remove_none_from_dict(
+ {
+ "access_token": access_token,
+ "allow_connection": allow_connection,
+ "config_id": config_id,
+ "config_version": config_version,
+ "event_limit": event_limit,
+ "resumed_chat_group_id": resumed_chat_group_id,
+ "verbose_transcription": verbose_transcription,
+ "api_key": api_key,
+ "session_settings": convert_and_respect_annotation_metadata(
+ object_=session_settings, annotation=ConnectSessionSettings, direction="write"
+ ),
+ **(
+ request_options.get("additional_query_parameters", {}) or {}
+ if request_options is not None
+ else {}
+ ),
+ }
+ )
+ )
+ )
+ if _encoded_query_params:
+ ws_url = ws_url + "?" + urllib.parse.urlencode(_encoded_query_params)
headers = self._raw_client._client_wrapper.get_headers()
if request_options and "additional_headers" in request_options:
headers.update(request_options["additional_headers"])
@@ -248,30 +254,32 @@ class AsyncChatClient:
AsyncChatSocketClient
"""
ws_url = self._raw_client._client_wrapper.get_environment().evi + "/chat"
- query_params = httpx.QueryParams()
- if access_token is not None:
- query_params = query_params.add("access_token", access_token)
- if allow_connection is not None:
- query_params = query_params.add("allow_connection", allow_connection)
- if config_id is not None:
- query_params = query_params.add("config_id", config_id)
- if config_version is not None:
- query_params = query_params.add("config_version", config_version)
- if event_limit is not None:
- query_params = query_params.add("event_limit", event_limit)
- if resumed_chat_group_id is not None:
- query_params = query_params.add("resumed_chat_group_id", resumed_chat_group_id)
- if verbose_transcription is not None:
- query_params = query_params.add("verbose_transcription", verbose_transcription)
- if api_key is not None:
- query_params = query_params.add("api_key", api_key)
-
- if session_settings is not None:
- flattened_params = single_query_encoder("session_settings", session_settings)
- for param_key, param_value in flattened_params:
- query_params = query_params.add(param_key, param_value)
-
- ws_url = ws_url + f"?{query_params}"
+ _encoded_query_params = encode_query(
+ jsonable_encoder(
+ remove_none_from_dict(
+ {
+ "access_token": access_token,
+ "allow_connection": allow_connection,
+ "config_id": config_id,
+ "config_version": config_version,
+ "event_limit": event_limit,
+ "resumed_chat_group_id": resumed_chat_group_id,
+ "verbose_transcription": verbose_transcription,
+ "api_key": api_key,
+ "session_settings": convert_and_respect_annotation_metadata(
+ object_=session_settings, annotation=ConnectSessionSettings, direction="write"
+ ),
+ **(
+ request_options.get("additional_query_parameters", {}) or {}
+ if request_options is not None
+ else {}
+ ),
+ }
+ )
+ )
+ )
+ if _encoded_query_params:
+ ws_url = ws_url + "?" + urllib.parse.urlencode(_encoded_query_params)
headers = self._raw_client._client_wrapper.get_headers()
if request_options and "additional_headers" in request_options:
headers.update(request_options["additional_headers"])
Loading
Loading