hilus 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hilus-0.2.0/MANIFEST.in +11 -0
- hilus-0.2.0/PKG-INFO +348 -0
- hilus-0.2.0/pyproject.toml +121 -0
- hilus-0.2.0/sdk/hilus/LICENSE +202 -0
- hilus-0.2.0/sdk/hilus/README.md +300 -0
- hilus-0.2.0/sdk/hilus/__init__.py +72 -0
- hilus-0.2.0/sdk/hilus/_client_support.py +55 -0
- hilus-0.2.0/sdk/hilus/_registry.py +53 -0
- hilus-0.2.0/sdk/hilus/_stt_mixin.py +146 -0
- hilus-0.2.0/sdk/hilus/api_url.py +106 -0
- hilus-0.2.0/sdk/hilus/audio.py +432 -0
- hilus-0.2.0/sdk/hilus/cli/__init__.py +0 -0
- hilus-0.2.0/sdk/hilus/cli/_generated_runtime.py +1906 -0
- hilus-0.2.0/sdk/hilus/cli/api_client.py +846 -0
- hilus-0.2.0/sdk/hilus/cli/commands/__init__.py +0 -0
- hilus-0.2.0/sdk/hilus/cli/commands/checkout.py +150 -0
- hilus-0.2.0/sdk/hilus/cli/commands/clone.py +86 -0
- hilus-0.2.0/sdk/hilus/cli/commands/docs_cmd.py +79 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/__init__.py +42 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/browser.py +2269 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/connectorgateway.py +119 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/google.py +365 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/platform.py +17963 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/slack.py +151 -0
- hilus-0.2.0/sdk/hilus/cli/commands/generated/stripe.py +336 -0
- hilus-0.2.0/sdk/hilus/cli/commands/init.py +190 -0
- hilus-0.2.0/sdk/hilus/cli/commands/login.py +77 -0
- hilus-0.2.0/sdk/hilus/cli/commands/mount_cmd.py +449 -0
- hilus-0.2.0/sdk/hilus/cli/commands/new.py +175 -0
- hilus-0.2.0/sdk/hilus/cli/commands/sdk_cmd.py +283 -0
- hilus-0.2.0/sdk/hilus/cli/commands/switch.py +139 -0
- hilus-0.2.0/sdk/hilus/cli/git_credential.py +97 -0
- hilus-0.2.0/sdk/hilus/cli/main.py +874 -0
- hilus-0.2.0/sdk/hilus/cli/mount.py +3446 -0
- hilus-0.2.0/sdk/hilus/cli/paths.py +210 -0
- hilus-0.2.0/sdk/hilus/cli/utils.py +645 -0
- hilus-0.2.0/sdk/hilus/errors.py +231 -0
- hilus-0.2.0/sdk/hilus/examples/async_job.py +41 -0
- hilus-0.2.0/sdk/hilus/examples/known_voices.py +59 -0
- hilus-0.2.0/sdk/hilus/examples/quickstart.py +43 -0
- hilus-0.2.0/sdk/hilus/examples/repo_edit_and_test.py +43 -0
- hilus-0.2.0/sdk/hilus/examples/streaming_events.py +31 -0
- hilus-0.2.0/sdk/hilus/generated/__init__.py +28 -0
- hilus-0.2.0/sdk/hilus/generated/browser.py +2200 -0
- hilus-0.2.0/sdk/hilus/generated/google.py +519 -0
- hilus-0.2.0/sdk/hilus/generated/models.py +15463 -0
- hilus-0.2.0/sdk/hilus/generated/platform.py +22124 -0
- hilus-0.2.0/sdk/hilus/generated/slack.py +332 -0
- hilus-0.2.0/sdk/hilus/generated/stripe.py +273 -0
- hilus-0.2.0/sdk/hilus/hql/__init__.py +18 -0
- hilus-0.2.0/sdk/hilus/hql/ast.py +953 -0
- hilus-0.2.0/sdk/hilus/hql/parser.py +1960 -0
- hilus-0.2.0/sdk/hilus/log.py +514 -0
- hilus-0.2.0/sdk/hilus/oauth.py +386 -0
- hilus-0.2.0/sdk/hilus/py.typed +0 -0
- hilus-0.2.0/sdk/hilus/service_client.py +785 -0
- hilus-0.2.0/sdk/hilus/speech/__init__.py +163 -0
- hilus-0.2.0/sdk/hilus/speech/__main__.py +5 -0
- hilus-0.2.0/sdk/hilus/speech/bench/__init__.py +1 -0
- hilus-0.2.0/sdk/hilus/speech/bench/__main__.py +5 -0
- hilus-0.2.0/sdk/hilus/speech/bench/cli.py +304 -0
- hilus-0.2.0/sdk/hilus/speech/bench/client.py +116 -0
- hilus-0.2.0/sdk/hilus/speech/bench/dataset.py +129 -0
- hilus-0.2.0/sdk/hilus/speech/bench/judge.py +57 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/__init__.py +121 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/_common.py +52 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/_socket.py +112 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/assemblyai.py +194 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/cartesia.py +88 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/deepgram.py +191 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/elevenlabs.py +244 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/hilus.py +98 -0
- hilus-0.2.0/sdk/hilus/speech/bench/providers/speechmatics.py +149 -0
- hilus-0.2.0/sdk/hilus/speech/bench/report.py +54 -0
- hilus-0.2.0/sdk/hilus/speech/bench/run.py +107 -0
- hilus-0.2.0/sdk/hilus/speech/bench/scoring.py +187 -0
- hilus-0.2.0/sdk/hilus/speech/bench/submit.py +109 -0
- hilus-0.2.0/sdk/hilus/speech/compare.py +695 -0
- hilus-0.2.0/sdk/hilus/speech/diarization_evaluation.py +246 -0
- hilus-0.2.0/sdk/hilus/speech/formats.py +202 -0
- hilus-0.2.0/sdk/hilus/speech/hypothesis.py +67 -0
- hilus-0.2.0/sdk/hilus/speech/inverse_normalize.py +379 -0
- hilus-0.2.0/sdk/hilus/speech/labels.py +316 -0
- hilus-0.2.0/sdk/hilus/speech/lattice.py +251 -0
- hilus-0.2.0/sdk/hilus/speech/metrics.py +1439 -0
- hilus-0.2.0/sdk/hilus/speech/scorecard.py +325 -0
- hilus-0.2.0/sdk/hilus/speech/severity.py +93 -0
- hilus-0.2.0/sdk/hilus/speech/streaming.py +523 -0
- hilus-0.2.0/sdk/hilus/speech/submission.py +292 -0
- hilus-0.2.0/sdk/hilus/speech/tasks.py +116 -0
- hilus-0.2.0/sdk/hilus/speech/text.py +490 -0
- hilus-0.2.0/sdk/hilus/stt.py +583 -0
- hilus-0.2.0/sdk/hilus/ws.py +306 -0
- hilus-0.2.0/sdk/hilus.egg-info/PKG-INFO +348 -0
- hilus-0.2.0/sdk/hilus.egg-info/SOURCES.txt +98 -0
- hilus-0.2.0/sdk/hilus.egg-info/dependency_links.txt +1 -0
- hilus-0.2.0/sdk/hilus.egg-info/entry_points.txt +3 -0
- hilus-0.2.0/sdk/hilus.egg-info/requires.txt +30 -0
- hilus-0.2.0/sdk/hilus.egg-info/top_level.txt +1 -0
- hilus-0.2.0/setup.cfg +4 -0
hilus-0.2.0/MANIFEST.in
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# The source archive of the public `hilus` package carries only the package
|
|
2
|
+
# itself. Without this, setuptools adds the monorepo's top-level tests/ (server
|
|
3
|
+
# tests) and the root README.md, which are internal.
|
|
4
|
+
prune tests
|
|
5
|
+
exclude README.md
|
|
6
|
+
prune sdk/hilus/tests
|
|
7
|
+
prune sdk/hilus/cli/tests
|
|
8
|
+
include sdk/hilus/README.md
|
|
9
|
+
include sdk/hilus/py.typed
|
|
10
|
+
include sdk/hilus/LICENSE
|
|
11
|
+
global-exclude __pycache__ *.py[cod] .DS_Store
|
hilus-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hilus
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python SDK and command-line tool for Hilus: query an organization's data, configure and test its AI agents, stream live calls and conversations, and work on its code.
|
|
5
|
+
Author: Hilus
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://hilus.ai
|
|
8
|
+
Project-URL: Documentation, https://api.hilus.ai/Platform/docs
|
|
9
|
+
Keywords: hilus,ai agents,voice agents,api,sdk,cli,hql
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Environment :: Console
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: requests>=2.28
|
|
22
|
+
Requires-Dist: websocket-client>=1.6
|
|
23
|
+
Requires-Dist: websockets>=13.0
|
|
24
|
+
Requires-Dist: pydantic>=2.0
|
|
25
|
+
Requires-Dist: PyJWT[crypto]>=2.10
|
|
26
|
+
Requires-Dist: click>=8.1
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Requires-Dist: tabulate>=0.9
|
|
29
|
+
Requires-Dist: fusepy>=3.0
|
|
30
|
+
Provides-Extra: speech
|
|
31
|
+
Requires-Dist: numpy>=1.24; extra == "speech"
|
|
32
|
+
Requires-Dist: pydantic>=2.0; extra == "speech"
|
|
33
|
+
Requires-Dist: requests>=2.28; extra == "speech"
|
|
34
|
+
Requires-Dist: websockets>=12.0; extra == "speech"
|
|
35
|
+
Provides-Extra: opus
|
|
36
|
+
Requires-Dist: opuslib>=3.0; extra == "opus"
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
39
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
40
|
+
Requires-Dist: responses>=0.24; extra == "dev"
|
|
41
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-mock>=3.0; extra == "dev"
|
|
43
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
44
|
+
Requires-Dist: openapi-spec-validator>=0.9; extra == "dev"
|
|
45
|
+
Requires-Dist: moto>=5; extra == "dev"
|
|
46
|
+
Requires-Dist: pillow>=10; extra == "dev"
|
|
47
|
+
Requires-Dist: pydub>=0.25; extra == "dev"
|
|
48
|
+
|
|
49
|
+
# hilus
|
|
50
|
+
|
|
51
|
+
**The Python SDK and command-line tool for [Hilus](https://hilus.ai).**
|
|
52
|
+
|
|
53
|
+
Hilus runs AI agents that answer an organization's calls, web chat, email and
|
|
54
|
+
text messages, and act in the systems the organization already uses. This
|
|
55
|
+
package is how developers work with an organization on Hilus from code and
|
|
56
|
+
from the terminal:
|
|
57
|
+
|
|
58
|
+
- **Read and query its data:** conversations, calls, messages and every other
|
|
59
|
+
record, with typed models and HQL, a SQL-like query language.
|
|
60
|
+
- **Configure its agents:** agents, workflows, documents and forms are
|
|
61
|
+
versioned on branches and promoted to live through reviewed changesets.
|
|
62
|
+
- **Follow what happens live:** stream a call's events or a conversation as
|
|
63
|
+
it unfolds.
|
|
64
|
+
- **Test agents before they go live:** simulate whole conversations, replay a
|
|
65
|
+
reply, run saved tests.
|
|
66
|
+
- **Work on the organization's own code:** every organization has a git
|
|
67
|
+
repository; clone it, change it on a branch, run its tests, ship it with a
|
|
68
|
+
changeset.
|
|
69
|
+
|
|
70
|
+
One install gives you both:
|
|
71
|
+
|
|
72
|
+
- **`hilus` (Python):** typed clients generated from the API itself, one
|
|
73
|
+
method per operation with documented parameters, pydantic responses,
|
|
74
|
+
streaming, retries and typed errors.
|
|
75
|
+
- **`hilus` (CLI):** every API operation as a command, plus sign-in, `hilus
|
|
76
|
+
clone` and a live view of the organization's configuration as files.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install hilus
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Python 3.10 or newer. Full documentation, every operation and guide:
|
|
83
|
+
<https://api.hilus.ai/Platform/docs>.
|
|
84
|
+
|
|
85
|
+
## Sign in
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
hilus login # opens the browser; sign in, or create an account there
|
|
89
|
+
hilus context whoami
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`hilus login` signs you in through the browser, the way other CLIs do: no
|
|
93
|
+
key to copy. It stores a refresh token owner-only in
|
|
94
|
+
`~/.hilus/credentials.yaml`, and the CLI and the SDK renew the short-lived
|
|
95
|
+
access key themselves from then on. `hilus logout` revokes it. `hilus init`
|
|
96
|
+
does the same sign-in and also asks for your default organization and
|
|
97
|
+
branch. On a machine without a browser, `hilus login --no-browser` prints
|
|
98
|
+
the URL to open on another device; after you sign in there, the page shows a
|
|
99
|
+
code to paste back into the terminal.
|
|
100
|
+
|
|
101
|
+
The SDK uses that sign-in with no configuration: `PlatformClient()`.
|
|
102
|
+
|
|
103
|
+
**CI, servers and other automation** use an API key instead: create one on
|
|
104
|
+
the dashboard's Developer page, <https://app.hilus.ai/settings/developer>,
|
|
105
|
+
and set `HILUS_API_TOKEN` and `HILUS_ORG` (and `HILUS_API_URL` for a
|
|
106
|
+
non-production deployment), or store it with `echo "$KEY" | hilus init
|
|
107
|
+
--token -`. Never put a key on a command line. No account yet? Create one at
|
|
108
|
+
<https://app.hilus.ai/signup>.
|
|
109
|
+
|
|
110
|
+
If a call fails because you are not signed in, or because the credential was
|
|
111
|
+
refused (expired, revoked), the error says which and what to do.
|
|
112
|
+
|
|
113
|
+
An organization is a tenant: every call acts in one, sent as the
|
|
114
|
+
`X-Hilus-Schema` header. A key may be allowed several; pass
|
|
115
|
+
`organization=` (SDK) or `hilus context switch "<Org>"` (CLI) to choose.
|
|
116
|
+
|
|
117
|
+
## First call (SDK)
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from hilus import PlatformClient
|
|
121
|
+
|
|
122
|
+
client = PlatformClient() # from the environment, else from `hilus init`
|
|
123
|
+
# or, explicitly: PlatformClient(base="https://api.hilus.ai", auth_token="<api key>", organization="<org id>")
|
|
124
|
+
|
|
125
|
+
me = client.admin.whoami() # WhoamiUser
|
|
126
|
+
rows = client.query.run_hql(hql="Call | status = 'active' | limit 5").rows
|
|
127
|
+
agents = client.entities.list("Agent", limit=5) # EntityListResponse
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Precedence is explicit argument, then environment, then the stored sign-in.
|
|
131
|
+
An explicit token is never paired with the stored organization, and a token
|
|
132
|
+
stored for one API URL is refused for another: a staging key cannot reach
|
|
133
|
+
production by accident.
|
|
134
|
+
|
|
135
|
+
## Errors, retries and timeouts
|
|
136
|
+
|
|
137
|
+
Every failed call raises a typed exception with the HTTP context:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from hilus import AccessDeniedError, AuthError, HilusApiError, RateLimitError, TransportError
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
client.entities.get("Agent", "missing")
|
|
144
|
+
except AuthError: # 401, or no token at all
|
|
145
|
+
...
|
|
146
|
+
except AccessDeniedError as e: # 403; e.denial_reason when a gateway refused
|
|
147
|
+
...
|
|
148
|
+
except RateLimitError as e: # 429 after the retries; e.retry_after in seconds
|
|
149
|
+
...
|
|
150
|
+
except TransportError as e: # no HTTP answer: DNS, connection, TLS, timeout (e.__cause__ is the requests error)
|
|
151
|
+
...
|
|
152
|
+
except HilusApiError as e: # anything else: e.status_code, e.body, e.request_id
|
|
153
|
+
print(e.status_code, e.body, e.request_id)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Idempotent requests (GET, or any call with `idempotent=True` on
|
|
157
|
+
`_request`) are retried up to `max_retries=3` times on 429/502/503/504 and
|
|
158
|
+
on transport failures, honouring `Retry-After`, with exponential backoff
|
|
159
|
+
capped at 30 s. Writes are never retried.
|
|
160
|
+
|
|
161
|
+
The client's `timeout=` (60 s) is the read timeout of a request; every
|
|
162
|
+
method also takes `request_timeout=`. Routes the server allows longer (a
|
|
163
|
+
test run, a workspace command) wait at least the server's own limit, so
|
|
164
|
+
`client.repos.repo_test(...)` does not time out on the client side.
|
|
165
|
+
|
|
166
|
+
## Streaming
|
|
167
|
+
|
|
168
|
+
Server-Sent Events routes are iterators; WebSocket routes return a
|
|
169
|
+
`FrameStream` to iterate and `send` on:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from hilus import BrowserClient, PlatformClient, StreamTimeout
|
|
173
|
+
from hilus.generated.models import WSCallEventsConfigEvent
|
|
174
|
+
|
|
175
|
+
for entry in BrowserClient().stream_actions(session_id, since=0): # SSE: ActionLogEntry frames
|
|
176
|
+
print(entry.id, entry.type)
|
|
177
|
+
|
|
178
|
+
client = PlatformClient(ws_timeout=120) # idle limit; None waits for the server
|
|
179
|
+
with client.calls.call_events_stream(call_id) as frames:
|
|
180
|
+
frames.send(WSCallEventsConfigEvent(type="config"))
|
|
181
|
+
for frame in frames: # typed by the frame's `type`
|
|
182
|
+
print(frame.type)
|
|
183
|
+
print(frames.close_code, frames.close_reason) # set when the server closed
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
A dropped GET stream is reopened once from the last event id; a frame type
|
|
187
|
+
newer than this client is yielded as a dict instead of ending the stream;
|
|
188
|
+
idle past `ws_timeout` raises `StreamTimeout`.
|
|
189
|
+
|
|
190
|
+
## Live transcription
|
|
191
|
+
|
|
192
|
+
`client.stt.listen` streams audio to the live transcription socket and
|
|
193
|
+
yields what was said, and by whom, as it is said. It sends the audio as
|
|
194
|
+
binary frames at the pace it was spoken, sends `finalize` at the end, and
|
|
195
|
+
stops after `closed`:
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from hilus import PlatformClient
|
|
199
|
+
from hilus.audio import Audio
|
|
200
|
+
from hilus.stt import Identity, KnownPerson, Transcript
|
|
201
|
+
|
|
202
|
+
client = PlatformClient()
|
|
203
|
+
ann = KnownPerson(id="u-17", name="Ann", voiceprints=[held_print]) # a voiceprint you kept from an earlier stream
|
|
204
|
+
|
|
205
|
+
with client.stt.listen(Audio.wav("call.wav"), known=[ann], voiceprints="data") as live:
|
|
206
|
+
for event in live:
|
|
207
|
+
match event:
|
|
208
|
+
case Transcript(is_final=True):
|
|
209
|
+
print(f"speaker {event.speaker}: {event.text}")
|
|
210
|
+
case Identity(status="identified"):
|
|
211
|
+
print(f"speaker {event.speaker} is {event.known_id}")
|
|
212
|
+
# live.add_known(...), live.remove_known(...), live.update(keyterms=[...]) change it while it runs
|
|
213
|
+
new_prints = live.voiceprints # speaker -> voiceprint, to keep
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- Audio: `Audio.wav(path_or_file)` (rate, width and channels from the
|
|
217
|
+
header), `Audio.pcm(bytes, sample_rate)` (what `tts.speak_stream(format="pcm")`
|
|
218
|
+
returns), `Audio.mulaw` / `Audio.alaw` for phone audio, `Audio.numpy(array,
|
|
219
|
+
sample_rate)`, `Audio.join(parts, gap=)`; or an iterable of byte chunks
|
|
220
|
+
(a microphone, a phone line), sent as they arrive. `realtime=False` sends
|
|
221
|
+
a recording as fast as the socket takes it.
|
|
222
|
+
- Opus, to save bandwidth (`pip install "hilus[opus]"`):
|
|
223
|
+
`client.stt.listen(Audio.wav("call.wav"), encoding="opus", bitrate=24000)`
|
|
224
|
+
sends 20 ms Opus packets, about 134 kB a minute of speech against 1.92 MB
|
|
225
|
+
of 16 kHz PCM; `Audio.opus_packets(packets)` sends packets you already
|
|
226
|
+
have as they are. PCM stays the default: Opus is lossy.
|
|
227
|
+
- `async with client.stt.alisten(...) as live: async for event in live: ...`
|
|
228
|
+
is the same for asyncio, and takes async iterables.
|
|
229
|
+
- A refused config raises `hilus.StreamError` on entering, before any audio
|
|
230
|
+
is sent; an `error` frame mid-stream is yielded; a stream that fails raises
|
|
231
|
+
`StreamError`. The low-level socket is still `client.stt.stream()`
|
|
232
|
+
(`FrameStream.send_bytes` sends binary frames).
|
|
233
|
+
|
|
234
|
+
`examples/known_voices.py` is the whole round trip: two of the platform's
|
|
235
|
+
voices make a first call, which collects a voiceprint, and a second, which
|
|
236
|
+
recognizes that person by your own id.
|
|
237
|
+
|
|
238
|
+
## Background work
|
|
239
|
+
|
|
240
|
+
Routes that run in the background by default (`clinical.clinical_consult`,
|
|
241
|
+
`lab.simulate`, ...) answer `202` while the server works. With the default
|
|
242
|
+
`wait=True` the method polls until the result is ready (`wait_timeout`
|
|
243
|
+
seconds at most, `poll_interval` seconds at first, backing off to five);
|
|
244
|
+
with `wait=False` it returns a `PendingExecution` to poll yourself:
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
pending = client.clinical.clinical_consult(case_synopsis="...", species="dog", wait=False)
|
|
248
|
+
outcome = client.jobs.poll_async(pending.async_id) # {"status": "pending" | "completed" | "failed", "result": ...}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Logging from your code
|
|
252
|
+
|
|
253
|
+
`hilus.log.get_logger` gives you a standard Python logger whose lines go to
|
|
254
|
+
Hilus, where your organization's members read them as `Log` (the
|
|
255
|
+
dashboard's Logs page, or `hilus query run-hql --hql "Log | ..."`):
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from hilus.log import get_logger
|
|
259
|
+
|
|
260
|
+
log = get_logger("acme.sync") # any dotted name not under `hilus`
|
|
261
|
+
log.info("synced %s visits", 12, extra={"clinic": "north", "rows": 12})
|
|
262
|
+
try:
|
|
263
|
+
sync()
|
|
264
|
+
except Exception:
|
|
265
|
+
log.exception("sync failed") # the traceback is part of the message
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Everything in `extra=` becomes the line's `data` (strings, numbers and
|
|
269
|
+
bools; anything else is sent as its `str`), so any key works, `message`
|
|
270
|
+
included. The loggers sit in a tree of their own: your own `logging`
|
|
271
|
+
configuration neither repeats nor stops their lines.
|
|
272
|
+
|
|
273
|
+
Lines are queued and sent in the background with the client's usual
|
|
274
|
+
credentials, at most 500 per request or after a second; `log.info` never
|
|
275
|
+
waits on the network and never raises. A busy or unreachable server is
|
|
276
|
+
retried; up to 10,000 waiting lines are kept, and if older ones had to be
|
|
277
|
+
dropped the next batch says how many. Lines still queued are sent at exit
|
|
278
|
+
(waiting five seconds at most); call `hilus.log.flush()` yourself before
|
|
279
|
+
`os._exit` or at the end of a short job. Set `HILUS_LOG_ECHO=1` to also
|
|
280
|
+
print every line to stderr. To send a standard-library logger's lines too,
|
|
281
|
+
attach a `hilus.log.HilusHandler()` to it.
|
|
282
|
+
|
|
283
|
+
## Examples
|
|
284
|
+
|
|
285
|
+
The package ships runnable examples in `hilus/examples/` (find them with
|
|
286
|
+
`python -c "import hilus, os; print(os.path.join(os.path.dirname(hilus.__file__), 'examples'))"`):
|
|
287
|
+
`quickstart.py`, `streaming_events.py`, `known_voices.py` (live
|
|
288
|
+
transcription that recognizes your own people), `async_job.py` and
|
|
289
|
+
`repo_edit_and_test.py` (change code on a branch, run its tests, open a
|
|
290
|
+
changeset). Every organization's own repository (`hilus clone`) starts with
|
|
291
|
+
more under `examples/`.
|
|
292
|
+
|
|
293
|
+
## CLI
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
hilus init # sign in (once)
|
|
297
|
+
hilus context whoami # organization, branch, API, masked token
|
|
298
|
+
hilus query run-hql --hql "Agent | select id, name | limit 5"
|
|
299
|
+
hilus entities list --entity-type Agent --limit 5
|
|
300
|
+
hilus docs --query "changesets" # the docs, no sign-in needed
|
|
301
|
+
hilus repos tree --depth 1
|
|
302
|
+
hilus clone # the organization's repository, plain git afterwards
|
|
303
|
+
hilus workspaces run --command "pytest -q" --branch feature/try
|
|
304
|
+
hilus workspaces steps # what ran, what it printed
|
|
305
|
+
hilus mount up # the organization's entities as a YAML filesystem
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
`hilus --help` lists every group; each command's `--help` is the reference
|
|
309
|
+
(generated from the same route docstrings the API docs use). Errors print
|
|
310
|
+
one line and exit 1; with `--format json` they are `{"success": false,
|
|
311
|
+
"error": ...}` on stdout. Set `HILUS_DEBUG=1` to see every request.
|
|
312
|
+
|
|
313
|
+
`hilus clone` configures the clone with `credential.<api host>.helper =
|
|
314
|
+
git-credential-hilus`, which mints a one-hour password from the stored
|
|
315
|
+
sign-in whenever git asks, so `git pull`/`git push` work in any editor and
|
|
316
|
+
no token is written to disk. The helper answers only for the API host.
|
|
317
|
+
|
|
318
|
+
## Typed clients
|
|
319
|
+
|
|
320
|
+
`hilus.generated` holds one typed client per service, rendered from the
|
|
321
|
+
served OpenAPI and AsyncAPI documents (`python -m Hilus.scripts.render_sdk_py`
|
|
322
|
+
in the monorepo; CI fails when the committed files are stale). Nested
|
|
323
|
+
mounts are attributes, routes are methods with the documented parameters,
|
|
324
|
+
responses are pydantic models (`extra="allow"`: a field the server adds
|
|
325
|
+
tomorrow does not break today's client), SSE routes yield typed frames,
|
|
326
|
+
WebSocket routes return a `FrameStream`, and routes answering raw bytes
|
|
327
|
+
(audio, HTML) return `bytes`.
|
|
328
|
+
|
|
329
|
+
`hilus sdk gen` writes a `hilus_types/` package with one pydantic model per
|
|
330
|
+
entity type of the organization (fields, nested models, `EntityRef`, tool
|
|
331
|
+
names), meant to be committed next to your code; `hilus sdk gen --check`
|
|
332
|
+
reports drift.
|
|
333
|
+
|
|
334
|
+
## What's in the package
|
|
335
|
+
|
|
336
|
+
| Import | What |
|
|
337
|
+
|---|---|
|
|
338
|
+
| `hilus.PlatformClient`, `hilus.BrowserClient`, ... | Generated typed clients, one per service. |
|
|
339
|
+
| `hilus.ServiceClient` | The typed HTTP base the clients share; subclass it for a service of your own. |
|
|
340
|
+
| `hilus.errors` | `HilusApiError` and its subclasses. |
|
|
341
|
+
| `hilus.stt`, `hilus.audio` | Live transcription: `client.stt.listen` / `alisten`, its frames under short names, and `Audio` sources. |
|
|
342
|
+
| `hilus.hql` | Parser for HQL, the query language of `query.run_hql`. |
|
|
343
|
+
| `hilus.log` | `get_logger`: log from your own code to your organization's `Log`. |
|
|
344
|
+
| `hilus.cli.main` | The `hilus` click entry point (programmatic launching). |
|
|
345
|
+
|
|
346
|
+
## License
|
|
347
|
+
|
|
348
|
+
Apache License 2.0 (the `LICENSE` file in the package). The license covers this package (the SDK and CLI); the Hilus platform it talks to is a hosted service under its own terms.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hilus"
|
|
7
|
+
# Placeholder: the "Release hilus" workflow stamps the released version at build time.
|
|
8
|
+
version = "0.2.0"
|
|
9
|
+
description = "Python SDK and command-line tool for Hilus: query an organization's data, configure and test its AI agents, stream live calls and conversations, and work on its code."
|
|
10
|
+
readme = "sdk/hilus/README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
license = { text = "Apache-2.0" }
|
|
13
|
+
authors = [{ name = "Hilus" }]
|
|
14
|
+
keywords = ["hilus", "ai agents", "voice agents", "api", "sdk", "cli", "hql"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Environment :: Console",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
# Baseline deps are the SDK surface plus Google OAuth signing. CLI
|
|
27
|
+
# deps (click, pyyaml, tabulate, fusepy) are also baseline because
|
|
28
|
+
# `import hilus.cli.main` needs them. If a future split is useful,
|
|
29
|
+
# move them to `[project.optional-dependencies].cli` and mark the
|
|
30
|
+
# top-level `sdk/hilus/__init__.py` SDK surface as lazy-import-only
|
|
31
|
+
# from CLI modules.
|
|
32
|
+
dependencies = [
|
|
33
|
+
"requests>=2.28",
|
|
34
|
+
"websocket-client>=1.6",
|
|
35
|
+
# The asyncio socket (``hilus.ws.AsyncFrameSocket``, ``client.stt.alisten``).
|
|
36
|
+
"websockets>=13.0",
|
|
37
|
+
"pydantic>=2.0",
|
|
38
|
+
"PyJWT[crypto]>=2.10",
|
|
39
|
+
"click>=8.1",
|
|
40
|
+
"pyyaml>=6.0",
|
|
41
|
+
"tabulate>=0.9",
|
|
42
|
+
"fusepy>=3.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
# The speech benchmark runner (``hilus.speech``; hilus.speech.REQUIREMENTS).
|
|
47
|
+
speech = ["numpy>=1.24", "pydantic>=2.0", "requests>=2.28", "websockets>=12.0"]
|
|
48
|
+
# Opus for the live transcription socket (``client.stt.listen(..., encoding="opus")``, ``hilus.audio.OpusEncoder``):
|
|
49
|
+
# opuslib binds libopus, which the system provides (apt install libopus0, brew install opus).
|
|
50
|
+
opus = ["opuslib>=3.0"]
|
|
51
|
+
dev = [
|
|
52
|
+
"mypy>=1.8",
|
|
53
|
+
"pytest>=7.0",
|
|
54
|
+
"responses>=0.24",
|
|
55
|
+
"types-requests",
|
|
56
|
+
"pytest-mock>=3.0",
|
|
57
|
+
"ruff>=0.1",
|
|
58
|
+
"openapi-spec-validator>=0.9",
|
|
59
|
+
"moto>=5",
|
|
60
|
+
"pillow>=10",
|
|
61
|
+
# hilus.speech.labels.write_call takes a pydub segment; its test builds one.
|
|
62
|
+
"pydub>=0.25",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[project.scripts]
|
|
66
|
+
hilus = "hilus.cli.main:cli"
|
|
67
|
+
# The git credential helper `hilus clone` installs in a clone.
|
|
68
|
+
git-credential-hilus = "hilus.cli.git_credential:main"
|
|
69
|
+
|
|
70
|
+
[project.urls]
|
|
71
|
+
Homepage = "https://hilus.ai"
|
|
72
|
+
Documentation = "https://api.hilus.ai/Platform/docs"
|
|
73
|
+
|
|
74
|
+
[tool.setuptools.packages.find]
|
|
75
|
+
# The public package lives under ``sdk/`` so that ``hilus/`` never sits
|
|
76
|
+
# beside the server-side ``Hilus/`` on a case-insensitive filesystem.
|
|
77
|
+
where = ["sdk"]
|
|
78
|
+
# Only the `hilus` tree ships. The server-side `Hilus/` library package
|
|
79
|
+
# builds separately as part of the deploy pipeline; `pip install hilus`
|
|
80
|
+
# gets ONLY the public surface, even though both trees live in one repo.
|
|
81
|
+
include = ["hilus*"]
|
|
82
|
+
exclude = ["hilus.tests*", "hilus.cli.tests*"]
|
|
83
|
+
|
|
84
|
+
[tool.setuptools.package-data]
|
|
85
|
+
hilus = ["py.typed", "LICENSE"]
|
|
86
|
+
|
|
87
|
+
# Pytest prepends `default::DeprecationWarning`, which shadows the same
|
|
88
|
+
# ignore filters installed in Hilus/__init__.py at import time. Keep these
|
|
89
|
+
# in sync with that module.
|
|
90
|
+
[tool.pytest.ini_options]
|
|
91
|
+
filterwarnings = [
|
|
92
|
+
"ignore:Using extra keyword arguments on `Field` is deprecated:DeprecationWarning",
|
|
93
|
+
"ignore:Support for class-based `config` is deprecated:DeprecationWarning",
|
|
94
|
+
# Known field shadows; keep in sync with _ALLOWED_FIELD_SHADOWS in
|
|
95
|
+
# Hilus/entities/base_entity.py (test_field_shadows.py checks the list).
|
|
96
|
+
'ignore:Field name "summary" in "Form" shadows an attribute in parent "BaseEntity":UserWarning',
|
|
97
|
+
'ignore:Field name "branch" in "AgentTestRun" shadows an attribute in parent "BaseEntity":UserWarning',
|
|
98
|
+
'ignore:Field name "branch" in "SimulationTestRun" shadows an attribute in parent "BaseEntity":UserWarning',
|
|
99
|
+
'ignore:Field name "branch" in "Workspace" shadows an attribute in parent "BaseEntity":UserWarning',
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[tool.mypy]
|
|
103
|
+
python_version = "3.12"
|
|
104
|
+
# Check both the public ``hilus`` SDK and the server-side ``Hilus``
|
|
105
|
+
# tree. The plan's CI step runs mypy across the whole tree but only
|
|
106
|
+
# fails on ``[return-value]`` / ``[arg-type]`` / ``[call-arg]`` —
|
|
107
|
+
# those map to "handler isn't producing the declared response type".
|
|
108
|
+
# Other categories show up as red squigglies in Pylance/IDE so devs
|
|
109
|
+
# can see them while editing, but they don't gate merges yet.
|
|
110
|
+
files = ["Hilus", "sdk/hilus"]
|
|
111
|
+
ignore_missing_imports = true
|
|
112
|
+
follow_imports = "silent"
|
|
113
|
+
check_untyped_defs = true
|
|
114
|
+
cache_dir = ".mypy_cache"
|
|
115
|
+
warn_unused_ignores = true
|
|
116
|
+
disallow_untyped_decorators = true
|
|
117
|
+
plugins = ["pydantic.mypy"]
|
|
118
|
+
|
|
119
|
+
[[tool.mypy.overrides]]
|
|
120
|
+
module = ["requests.*", "fusepy.*", "tabulate.*", "yaml.*"]
|
|
121
|
+
ignore_missing_imports = true
|