|
| 1 | +import sys |
1 | 2 | import threading |
2 | 3 | from typing import ClassVar, Optional |
3 | 4 |
|
4 | 5 | import httpx |
5 | 6 | from typing_extensions import Self |
6 | 7 |
|
7 | | -from . import types |
| 8 | +from . import __version__, types |
8 | 9 |
|
9 | 10 |
|
10 | 11 | class Client: |
@@ -33,19 +34,19 @@ def __init__( |
33 | 34 | "Please provide an API key via the ASSEMBLYAI_API_KEY environment variable or the global settings." |
34 | 35 | ) |
35 | 36 |
|
| 37 | + vi = sys.version_info |
| 38 | + python_version = f"{vi.major}.{vi.minor}.{vi.micro}" |
| 39 | + user_agent = f"{httpx._client.USER_AGENT} AssemblyAI/1.0 (sdk=Python/{__version__} runtime_env=Python/{python_version})" |
| 40 | + |
| 41 | + headers = {"user-agent": user_agent} |
36 | 42 | if self._settings.api_key: |
37 | | - self._http_client = httpx.Client( |
38 | | - base_url=self.settings.base_url, |
39 | | - headers={ |
40 | | - "authorization": self.settings.api_key, |
41 | | - }, |
42 | | - timeout=self.settings.http_timeout, |
43 | | - ) |
44 | | - else: |
45 | | - self._http_client = httpx.Client( |
46 | | - base_url=self.settings.base_url, |
47 | | - timeout=self.settings.http_timeout, |
48 | | - ) |
| 43 | + headers["authorization"] = self.settings.api_key |
| 44 | + |
| 45 | + self._http_client = httpx.Client( |
| 46 | + base_url=self.settings.base_url, |
| 47 | + headers=headers, |
| 48 | + timeout=self.settings.http_timeout, |
| 49 | + ) |
49 | 50 |
|
50 | 51 | @property |
51 | 52 | def settings(self) -> types.Settings: |
|
0 commit comments