|
| 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 | + ) |
0 commit comments