interhumanai 0.4.1__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.
- interhumanai-0.4.1/.gitignore +244 -0
- interhumanai-0.4.1/CHANGELOG.md +31 -0
- interhumanai-0.4.1/LICENSE +202 -0
- interhumanai-0.4.1/PKG-INFO +222 -0
- interhumanai-0.4.1/README.md +196 -0
- interhumanai-0.4.1/pyproject.toml +44 -0
- interhumanai-0.4.1/src/interhumanai/__init__.py +181 -0
- interhumanai-0.4.1/src/interhumanai/_http.py +73 -0
- interhumanai-0.4.1/src/interhumanai/_session_socket.py +314 -0
- interhumanai-0.4.1/src/interhumanai/_version.py +3 -0
- interhumanai-0.4.1/src/interhumanai/auth.py +242 -0
- interhumanai-0.4.1/src/interhumanai/client.py +120 -0
- interhumanai-0.4.1/src/interhumanai/config.py +52 -0
- interhumanai-0.4.1/src/interhumanai/errors.py +56 -0
- interhumanai-0.4.1/src/interhumanai/py.typed +0 -0
- interhumanai-0.4.1/src/interhumanai/realtime.py +239 -0
- interhumanai-0.4.1/src/interhumanai/stream.py +338 -0
- interhumanai-0.4.1/src/interhumanai/types.py +162 -0
- interhumanai-0.4.1/src/interhumanai/upload.py +110 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.pyc
|
|
6
|
+
|
|
7
|
+
# C extensions
|
|
8
|
+
*.so
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
.Python
|
|
12
|
+
node_modules/
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
# Usually these files are written by a python script from a template
|
|
33
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py.cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
cover/
|
|
55
|
+
test_results.csv
|
|
56
|
+
benchmark_results/
|
|
57
|
+
load_test_results/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
*.ipynb
|
|
85
|
+
.ipynb_checkpoints
|
|
86
|
+
|
|
87
|
+
# IPython
|
|
88
|
+
profile_default/
|
|
89
|
+
ipython_config.py
|
|
90
|
+
|
|
91
|
+
# pyenv
|
|
92
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
93
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
94
|
+
# .python-version
|
|
95
|
+
|
|
96
|
+
# pipenv
|
|
97
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
98
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
99
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
100
|
+
# install all needed dependencies.
|
|
101
|
+
#Pipfile.lock
|
|
102
|
+
|
|
103
|
+
# UV
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
#uv.lock
|
|
108
|
+
|
|
109
|
+
# poetry
|
|
110
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
111
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
112
|
+
# commonly ignored for libraries.
|
|
113
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
114
|
+
#poetry.lock
|
|
115
|
+
#poetry.toml
|
|
116
|
+
|
|
117
|
+
# pdm
|
|
118
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
119
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
120
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
121
|
+
#pdm.lock
|
|
122
|
+
#pdm.toml
|
|
123
|
+
.pdm-python
|
|
124
|
+
.pdm-build/
|
|
125
|
+
|
|
126
|
+
# pixi
|
|
127
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
128
|
+
#pixi.lock
|
|
129
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
130
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
131
|
+
.pixi
|
|
132
|
+
|
|
133
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
134
|
+
__pypackages__/
|
|
135
|
+
|
|
136
|
+
# Celery stuff
|
|
137
|
+
celerybeat-schedule
|
|
138
|
+
celerybeat.pid
|
|
139
|
+
|
|
140
|
+
# SageMath parsed files
|
|
141
|
+
*.sage.py
|
|
142
|
+
|
|
143
|
+
# Environments
|
|
144
|
+
*.env
|
|
145
|
+
.envrc
|
|
146
|
+
.venv
|
|
147
|
+
env/
|
|
148
|
+
venv/
|
|
149
|
+
ENV/
|
|
150
|
+
env.bak/
|
|
151
|
+
venv.bak/
|
|
152
|
+
|
|
153
|
+
# Spyder project settings
|
|
154
|
+
.spyderproject
|
|
155
|
+
.spyproject
|
|
156
|
+
|
|
157
|
+
# Rope project settings
|
|
158
|
+
.ropeproject
|
|
159
|
+
|
|
160
|
+
# mkdocs documentation
|
|
161
|
+
/site
|
|
162
|
+
|
|
163
|
+
# mypy
|
|
164
|
+
.mypy_cache/
|
|
165
|
+
.dmypy.json
|
|
166
|
+
dmypy.json
|
|
167
|
+
|
|
168
|
+
# Pyre type checker
|
|
169
|
+
.pyre/
|
|
170
|
+
|
|
171
|
+
# pytype static type analyzer
|
|
172
|
+
.pytype/
|
|
173
|
+
|
|
174
|
+
# Cython debug symbols
|
|
175
|
+
cython_debug/
|
|
176
|
+
|
|
177
|
+
# PyCharm
|
|
178
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
179
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
180
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
181
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
182
|
+
#.idea/
|
|
183
|
+
|
|
184
|
+
# Abstra
|
|
185
|
+
# Abstra is an AI-powered process automation framework.
|
|
186
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
187
|
+
# Learn more at https://abstra.io/docs
|
|
188
|
+
.abstra/
|
|
189
|
+
|
|
190
|
+
# Visual Studio Code
|
|
191
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
192
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
193
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
194
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
195
|
+
.vscode/
|
|
196
|
+
|
|
197
|
+
# Ruff stuff:
|
|
198
|
+
.ruff_cache/
|
|
199
|
+
|
|
200
|
+
# PyPI configuration file
|
|
201
|
+
.pypirc
|
|
202
|
+
|
|
203
|
+
# Cursor
|
|
204
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
205
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
206
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
207
|
+
.cursorignore
|
|
208
|
+
.cursorindexingignore
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Media files
|
|
216
|
+
*.mp4
|
|
217
|
+
*.webm
|
|
218
|
+
*.avi
|
|
219
|
+
*.mov
|
|
220
|
+
*.mkv
|
|
221
|
+
*.wmv
|
|
222
|
+
*.flv
|
|
223
|
+
*.mpeg
|
|
224
|
+
*.mpg
|
|
225
|
+
# Track bundled video fixtures used by the post-deploy e2e suite —
|
|
226
|
+
# see tests/fixtures/videos/e2e/README.md.
|
|
227
|
+
!tests/fixtures/videos/e2e/*.mp4
|
|
228
|
+
!tests/fixtures/videos/e2e/*.webm
|
|
229
|
+
|
|
230
|
+
# Mac specific files
|
|
231
|
+
.DS_Store
|
|
232
|
+
|
|
233
|
+
# AI agent
|
|
234
|
+
.agent/
|
|
235
|
+
.agents/
|
|
236
|
+
settings.local.json
|
|
237
|
+
# Transient git worktrees created for isolated agent runs
|
|
238
|
+
.claude/worktrees/
|
|
239
|
+
|
|
240
|
+
# Pulumi
|
|
241
|
+
.pulumi/
|
|
242
|
+
|
|
243
|
+
# Build metadata (generated at Docker build time)
|
|
244
|
+
version.json
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `interhumanai` are documented here. The package follows
|
|
4
|
+
[Semantic Versioning](https://semver.org/) and is versioned in lockstep with
|
|
5
|
+
the TypeScript SDK (`@interhumanai/sdk`): both packages always carry the same
|
|
6
|
+
version and release together.
|
|
7
|
+
|
|
8
|
+
## 0.4.1
|
|
9
|
+
|
|
10
|
+
Initial release (numbered 0.4.1 to align with the TypeScript SDK's current
|
|
11
|
+
version under the lockstep policy).
|
|
12
|
+
|
|
13
|
+
- `InterhumanClient` — top-level asyncio client with managed token refresh
|
|
14
|
+
(API key credentials) or pre-issued bearer tokens.
|
|
15
|
+
- `AuthClient` — `POST /v1/auth` token minting, plus `POST /v1/client_tokens`
|
|
16
|
+
and `POST /v1/client_tokens/revoke` for short-lived, capped client tokens.
|
|
17
|
+
- `UploadClient` — `POST /v1/upload/analyze` multipart upload with typed
|
|
18
|
+
`AnalysisResult` (signals, engagement, feedback, conversation quality).
|
|
19
|
+
- `StreamClient` — `WS /v1/stream/analyze` live sessions: binary video chunks,
|
|
20
|
+
session config, graceful `session.close` drain, and typed server events via
|
|
21
|
+
`async for` (signals, engagement, conversation quality, feedback, coverage,
|
|
22
|
+
errors).
|
|
23
|
+
- `RealtimeClient` — `WS /v0/real-time/analyze` live sessions: analysis-group
|
|
24
|
+
and synthesis configuration, client transcripts (`transcript.updated`), and
|
|
25
|
+
typed transcript/synthesis output events.
|
|
26
|
+
- Public enums matching the API contract: `Scope`, `SignalType`, `Probability`,
|
|
27
|
+
`EngagementLevel`, `GoalDimension`, `IncludeFlag`, `AnalysisGroup`,
|
|
28
|
+
`SynthesisFrequency`.
|
|
29
|
+
- Typed errors: `InterhumanAPIError` (canonical `error_id` / `correlation_id` /
|
|
30
|
+
`link` fields) and `InterhumanConfigError`; unknown server event types are
|
|
31
|
+
surfaced as `UnknownEvent` instead of failing the session.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2017-2022 Yann Hamon
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: interhumanai
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: First-party Python SDK for the Interhuman API: upload, stream, and real-time social-signal analysis.
|
|
5
|
+
Project-URL: Homepage, https://docs.interhuman.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/interhumanai/interhuman-api
|
|
7
|
+
Project-URL: Changelog, https://github.com/interhumanai/interhuman-api/blob/main/sdk/python/CHANGELOG.md
|
|
8
|
+
Author: Interhuman AI
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: analysis,interhuman,sdk,social-signals,video
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx>=0.27.0
|
|
23
|
+
Requires-Dist: pydantic>=2.7.0
|
|
24
|
+
Requires-Dist: websockets>=13.0
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Interhuman Python SDK
|
|
28
|
+
|
|
29
|
+
`interhumanai` is the first-party Python client for the
|
|
30
|
+
[Interhuman API](https://docs.interhuman.ai). It wraps authentication, client
|
|
31
|
+
tokens, video upload analysis, and the live stream and real-time WebSocket
|
|
32
|
+
protocols behind a typed, asyncio-first API — no hand-rolled token exchange,
|
|
33
|
+
multipart bodies, or WebSocket envelope parsing.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install interhumanai
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Requires Python 3.10+. Runtime dependencies: `httpx`, `websockets`, `pydantic`.
|
|
42
|
+
|
|
43
|
+
The SDK is asyncio-first: every network call is a coroutine. Use `asyncio.run()`
|
|
44
|
+
in scripts and top-level `await` in notebooks. The live stream and real-time
|
|
45
|
+
surfaces are inherently event-driven, so a single async API keeps every surface
|
|
46
|
+
consistent (and mirrors the promise-based TypeScript SDK).
|
|
47
|
+
|
|
48
|
+
## Quickstart
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import asyncio
|
|
52
|
+
from interhumanai import InterhumanClient
|
|
53
|
+
|
|
54
|
+
async def main() -> None:
|
|
55
|
+
client = InterhumanClient(key_id="...", key_secret="...")
|
|
56
|
+
result = await client.upload.analyze("meeting.mp4")
|
|
57
|
+
for signal in result.signals:
|
|
58
|
+
print(signal.type.value, signal.start, signal.end)
|
|
59
|
+
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Authentication
|
|
64
|
+
|
|
65
|
+
Two ways to authenticate:
|
|
66
|
+
|
|
67
|
+
- **API key credentials** (`key_id` + `key_secret`): the client exchanges them
|
|
68
|
+
at `POST /v1/auth` for a short-lived bearer token and refreshes it
|
|
69
|
+
automatically before expiry.
|
|
70
|
+
- **Pre-issued token** (`access_token`): a JWT or client token used as-is.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from interhumanai import InterhumanClient, Scope
|
|
74
|
+
|
|
75
|
+
# Managed credentials (recommended for servers)
|
|
76
|
+
client = InterhumanClient(key_id="...", key_secret="...", scopes=[Scope.UPLOAD, Scope.STREAM])
|
|
77
|
+
|
|
78
|
+
# Pre-issued bearer token
|
|
79
|
+
client = InterhumanClient(access_token="eyJ...")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The standalone `AuthClient` exposes the token endpoints directly, and
|
|
83
|
+
`TokenManager` / `StaticTokenProvider` are available when you need to plug a
|
|
84
|
+
custom token source into the lower-level clients.
|
|
85
|
+
|
|
86
|
+
## Client tokens (browser / untrusted clients)
|
|
87
|
+
|
|
88
|
+
Mint short-lived, capped tokens server-side so untrusted clients never see the
|
|
89
|
+
API key:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from interhumanai import AuthClient, Scope
|
|
93
|
+
|
|
94
|
+
auth = AuthClient()
|
|
95
|
+
token = await auth.create_client_token(
|
|
96
|
+
api_key="ih_...",
|
|
97
|
+
scopes=[Scope.STREAM],
|
|
98
|
+
expires_in=300, # clamped to 60-3600 seconds by the API
|
|
99
|
+
max_concurrent=1,
|
|
100
|
+
max_video_seconds=600,
|
|
101
|
+
allowed_origins=["https://app.example.com"],
|
|
102
|
+
)
|
|
103
|
+
await auth.revoke_client_token(api_key="ih_...", token=token.access_token)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Upload API
|
|
107
|
+
|
|
108
|
+
Analyze a complete video file (mp4, avi, mov, mkv, mpeg-ts, or webm; at least
|
|
109
|
+
3 seconds, at most 32 MB):
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from interhumanai import GoalDimension, IncludeFlag
|
|
113
|
+
|
|
114
|
+
result = await client.upload.analyze(
|
|
115
|
+
"meeting.mp4", # path, bytes, or file object
|
|
116
|
+
include=[IncludeFlag.CONVERSATION_QUALITY_OVERALL], # optional sections
|
|
117
|
+
goal_dimensions=[GoalDimension.CLARITY], # enables feedback
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The typed `AnalysisResult` carries `signals`, `engagement_state`, and — when
|
|
122
|
+
requested — `feedback` and `conversation_quality`.
|
|
123
|
+
|
|
124
|
+
## Stream API
|
|
125
|
+
|
|
126
|
+
One `StreamClient` handles one live session against `WS /v1/stream/analyze`.
|
|
127
|
+
Send binary WebM or fragmented-MP4 chunks and consume typed events with
|
|
128
|
+
`async for`:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from interhumanai import IncludeFlag, SignalDetectedEvent
|
|
132
|
+
|
|
133
|
+
async with client.stream() as session:
|
|
134
|
+
await session.wait_for_session_ready()
|
|
135
|
+
await session.update_config(include=[IncludeFlag.CONVERSATION_QUALITY_OVERALL])
|
|
136
|
+
await session.send_video(first_chunk) # first chunk carries the container header
|
|
137
|
+
await session.request_close() # graceful drain; close() tears down immediately
|
|
138
|
+
async for event in session:
|
|
139
|
+
if isinstance(event, SignalDetectedEvent):
|
|
140
|
+
print(event.data.signal_type.value, event.data.start)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Iteration ends when the connection closes; `session.close_info` then holds the
|
|
144
|
+
close code and reason. Event types this SDK version does not know arrive as
|
|
145
|
+
`UnknownEvent` instead of failing the session.
|
|
146
|
+
|
|
147
|
+
## Real-Time API
|
|
148
|
+
|
|
149
|
+
`RealtimeClient` targets `WS /v0/real-time/analyze` — a temporary `v0` public
|
|
150
|
+
release that accepts either the stream or the realtime scope. On top of the
|
|
151
|
+
stream protocol it adds multi-track analysis configuration, client transcripts,
|
|
152
|
+
and transcript/synthesis output (it never emits engagement or
|
|
153
|
+
conversation-quality events):
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from interhumanai import AnalysisGroup, SynthesisFrequency, SynthesisGeneratedEvent, TranscriptSegment
|
|
157
|
+
|
|
158
|
+
async with client.realtime() as session:
|
|
159
|
+
await session.wait_for_session_ready()
|
|
160
|
+
await session.update_config(
|
|
161
|
+
analysis_groups=[AnalysisGroup.AUDIO, AnalysisGroup.VISUAL],
|
|
162
|
+
synthesis_frequency=SynthesisFrequency.MEDIUM,
|
|
163
|
+
synthesis_prompt="Coach the presenter.", # non-empty prompt enables synthesis
|
|
164
|
+
)
|
|
165
|
+
await session.send_transcript([TranscriptSegment(start=0.0, end=2.0, text="Hi.", speaker=0)])
|
|
166
|
+
async for event in session:
|
|
167
|
+
if isinstance(event, SynthesisGeneratedEvent):
|
|
168
|
+
print(event.data.text)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Errors
|
|
172
|
+
|
|
173
|
+
Three surfaces, mirroring the API:
|
|
174
|
+
|
|
175
|
+
- `InterhumanAPIError` — raised for non-2xx HTTP responses (with `status`,
|
|
176
|
+
`error_id`, `correlation_id`, `link`) and for transport failures
|
|
177
|
+
(`status == 0`).
|
|
178
|
+
- `InterhumanConfigError` — raised for client-side misuse before any network
|
|
179
|
+
call (missing credentials, sending on a closed session, double connect).
|
|
180
|
+
- WebSocket `error` **envelopes** are delivered as `ErrorEvent`s through
|
|
181
|
+
iteration, not raised — fatal ones are followed by the connection closing.
|
|
182
|
+
|
|
183
|
+
## Environments
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
InterhumanClient(key_id=..., key_secret=...) # production (default): api.interhuman.ai
|
|
187
|
+
InterhumanClient(key_id=..., key_secret=..., environment="staging") # staging-api.interhuman.ai
|
|
188
|
+
InterhumanClient(key_id=..., key_secret=..., base_url="http://localhost:8080") # local override
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
WebSocket URLs are derived automatically (`https://` → `wss://`).
|
|
192
|
+
|
|
193
|
+
## Examples
|
|
194
|
+
|
|
195
|
+
Runnable scripts for every flow live in [`examples/`](examples/): `auth.py`,
|
|
196
|
+
`client_tokens.py`, `upload.py`, `stream.py`, and `realtime.py`.
|
|
197
|
+
|
|
198
|
+
## Development
|
|
199
|
+
|
|
200
|
+
The SDK lives in the [interhuman-api](https://github.com/interhumanai/interhuman-api)
|
|
201
|
+
repository under `sdk/python/`. Its tests live in `tests/sdk/python/` and run
|
|
202
|
+
with the repository's main suite:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
uv run pytest tests/sdk/python
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Releasing
|
|
209
|
+
|
|
210
|
+
This package is versioned in **lockstep** with the TypeScript SDK
|
|
211
|
+
(`@interhumanai/sdk`): both always carry the same version and release together
|
|
212
|
+
from a single workflow. Publishing is automatic and deploy-gated: bump
|
|
213
|
+
`__version__` in `src/interhumanai/_version.py` **and** the `version` in
|
|
214
|
+
`sdk/typescript/package.json` to the same value (semver), add a `CHANGELOG.md`
|
|
215
|
+
entry to each package, and merge to `main`. After the `Deploy` workflow
|
|
216
|
+
succeeds, the `SDK release` workflow builds, tests, and publishes both packages
|
|
217
|
+
(idempotently per registry), then tags the commit `sdk-v<version>`. See
|
|
218
|
+
[`docs/sdk-release.md`](../../docs/sdk-release.md) for details.
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
Apache-2.0
|