deeptrust-ai 0.0.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.
- deeptrust_ai-0.0.1/.github/workflows/ci.yml +23 -0
- deeptrust_ai-0.0.1/.github/workflows/release.yml +49 -0
- deeptrust_ai-0.0.1/.gitignore +21 -0
- deeptrust_ai-0.0.1/CONTRIBUTING.md +40 -0
- deeptrust_ai-0.0.1/LICENSE +202 -0
- deeptrust_ai-0.0.1/PKG-INFO +249 -0
- deeptrust_ai-0.0.1/README.md +224 -0
- deeptrust_ai-0.0.1/dev/server.py +182 -0
- deeptrust_ai-0.0.1/examples/README.md +51 -0
- deeptrust_ai-0.0.1/examples/analysis.py +513 -0
- deeptrust_ai-0.0.1/examples/demo-ui/index.html +13 -0
- deeptrust_ai-0.0.1/examples/demo-ui/package-lock.json +2149 -0
- deeptrust_ai-0.0.1/examples/demo-ui/package.json +26 -0
- deeptrust_ai-0.0.1/examples/demo-ui/public/favicon.png +0 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/App.tsx +459 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/CallShell.tsx +267 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/ElevenCall.tsx +297 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/MicCheck.tsx +162 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/Panel.tsx +402 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/labels.ts +57 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/main.tsx +8 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/servers.ts +38 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/styles.css +694 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/types.ts +161 -0
- deeptrust_ai-0.0.1/examples/demo-ui/src/vite-env.d.ts +10 -0
- deeptrust_ai-0.0.1/examples/demo-ui/tsconfig.json +14 -0
- deeptrust_ai-0.0.1/examples/demo-ui/vite.config.ts +10 -0
- deeptrust_ai-0.0.1/examples/dev_nudge_db.py +181 -0
- deeptrust_ai-0.0.1/examples/elevenlabs/.env.example +10 -0
- deeptrust_ai-0.0.1/examples/elevenlabs/README.md +150 -0
- deeptrust_ai-0.0.1/examples/elevenlabs/main.py +263 -0
- deeptrust_ai-0.0.1/examples/elevenlabs/pyproject.toml +16 -0
- deeptrust_ai-0.0.1/examples/elevenlabs/server.py +623 -0
- deeptrust_ai-0.0.1/examples/elevenlabs/tunnel.sh +36 -0
- deeptrust_ai-0.0.1/examples/elevenlabs-webhook/.env.example +15 -0
- deeptrust_ai-0.0.1/examples/elevenlabs-webhook/README.md +166 -0
- deeptrust_ai-0.0.1/examples/elevenlabs-webhook/customer_webhook.py +232 -0
- deeptrust_ai-0.0.1/examples/elevenlabs-webhook/pyproject.toml +14 -0
- deeptrust_ai-0.0.1/examples/livekit/.env.example +15 -0
- deeptrust_ai-0.0.1/examples/livekit/README.md +77 -0
- deeptrust_ai-0.0.1/examples/livekit/main.py +309 -0
- deeptrust_ai-0.0.1/examples/livekit/pyproject.toml +21 -0
- deeptrust_ai-0.0.1/examples/livekit/server.py +275 -0
- deeptrust_ai-0.0.1/justfile +57 -0
- deeptrust_ai-0.0.1/pyproject.toml +71 -0
- deeptrust_ai-0.0.1/src/deeptrust/__init__.py +8 -0
- deeptrust_ai-0.0.1/src/deeptrust/_http.py +151 -0
- deeptrust_ai-0.0.1/src/deeptrust/_version.py +1 -0
- deeptrust_ai-0.0.1/src/deeptrust/agents/__init__.py +127 -0
- deeptrust_ai-0.0.1/src/deeptrust/agents/_session.py +181 -0
- deeptrust_ai-0.0.1/src/deeptrust/agents/elevenlabs.py +164 -0
- deeptrust_ai-0.0.1/src/deeptrust/agents/livekit.py +117 -0
- deeptrust_ai-0.0.1/src/deeptrust/errors.py +74 -0
- deeptrust_ai-0.0.1/src/deeptrust/py.typed +0 -0
- deeptrust_ai-0.0.1/src/deeptrust/types.py +189 -0
- deeptrust_ai-0.0.1/tests/test_adapters.py +246 -0
- deeptrust_ai-0.0.1/tests/test_session.py +379 -0
- deeptrust_ai-0.0.1/uv.lock +2710 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python: ["3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v5
|
|
17
|
+
with:
|
|
18
|
+
enable-cache: true
|
|
19
|
+
- run: uv sync --all-extras --group dev --python ${{ matrix.python }}
|
|
20
|
+
- run: uv run ruff check src tests
|
|
21
|
+
- run: uv run ruff format --check src tests
|
|
22
|
+
- run: uv run mypy
|
|
23
|
+
- run: uv run pytest -q
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
# Publishes on a tag. No API token anywhere: PyPI trusted publishing exchanges
|
|
4
|
+
# this workflow's OIDC identity for a short-lived upload token, so nothing
|
|
5
|
+
# long-lived exists to leak.
|
|
6
|
+
#
|
|
7
|
+
# One-time setup, before the first tag:
|
|
8
|
+
# 1. pypi.org -> Your projects -> Publishing -> Add a pending publisher
|
|
9
|
+
# 2. project deeptrust-ai, owner deeptrust-ai, repo deeptrust-python,
|
|
10
|
+
# workflow release.yml, environment pypi
|
|
11
|
+
# 3. Create a `pypi` environment on the repo and restrict it to tags
|
|
12
|
+
#
|
|
13
|
+
# Then: git tag v0.1.0 && git push origin v0.1.0
|
|
14
|
+
|
|
15
|
+
on:
|
|
16
|
+
push:
|
|
17
|
+
tags: ["v*"]
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
build:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: astral-sh/setup-uv@v5
|
|
25
|
+
- run: uv sync --all-extras --group dev
|
|
26
|
+
# A tag that ships a failing build is worse than a late release.
|
|
27
|
+
- run: uv run ruff check src tests
|
|
28
|
+
- run: uv run mypy
|
|
29
|
+
- run: uv run pytest -q
|
|
30
|
+
- run: uv build
|
|
31
|
+
# Proves the wheel imports on its own rather than from the source tree.
|
|
32
|
+
- run: uv run --isolated --no-project --with dist/*.whl python -c "import deeptrust; print(deeptrust.__version__)"
|
|
33
|
+
- uses: actions/upload-artifact@v4
|
|
34
|
+
with:
|
|
35
|
+
name: dist
|
|
36
|
+
path: dist/
|
|
37
|
+
|
|
38
|
+
publish:
|
|
39
|
+
needs: build
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
environment: pypi
|
|
42
|
+
permissions:
|
|
43
|
+
id-token: write
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: dist
|
|
48
|
+
path: dist/
|
|
49
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
.venv/
|
|
4
|
+
dist/
|
|
5
|
+
build/
|
|
6
|
+
*.egg-info/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
.env
|
|
11
|
+
.DS_Store
|
|
12
|
+
|
|
13
|
+
# Examples resolve the SDK from this checkout and keep their own lockfiles out
|
|
14
|
+
# of it; each README says how to run them.
|
|
15
|
+
examples/*/.venv/
|
|
16
|
+
examples/*/uv.lock
|
|
17
|
+
examples/*/.env
|
|
18
|
+
|
|
19
|
+
# The example UI is a Vite app
|
|
20
|
+
examples/demo-ui/node_modules/
|
|
21
|
+
examples/demo-ui/dist/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
just install # uv sync, adapters and dev tools included
|
|
5
|
+
just check # lint, types, tests. what CI runs
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
`just` on its own lists everything else.
|
|
9
|
+
|
|
10
|
+
## What goes where
|
|
11
|
+
|
|
12
|
+
`src/deeptrust/types.py` holds the request and response shapes. They match the
|
|
13
|
+
API's own vocabulary, so a field renamed here is an API change rather than a
|
|
14
|
+
local one.
|
|
15
|
+
|
|
16
|
+
`src/deeptrust/_http.py` is transport only: base URL, auth header, retries, and
|
|
17
|
+
turning error responses into exceptions. It knows nothing about analyses or
|
|
18
|
+
verdicts.
|
|
19
|
+
|
|
20
|
+
`src/deeptrust/agents/` is the public surface. Two methods, `analyze` and
|
|
21
|
+
`check`, plus the adapters.
|
|
22
|
+
|
|
23
|
+
## Adapters
|
|
24
|
+
|
|
25
|
+
An adapter translates a platform's events into turns, and a nudge into whatever
|
|
26
|
+
that platform accepts. It should not interpret findings or make policy
|
|
27
|
+
decisions.
|
|
28
|
+
|
|
29
|
+
Where a platform cannot do something, document the limit rather than emulating
|
|
30
|
+
it. ElevenLabs contextual updates cannot interrupt a reply, so that adapter
|
|
31
|
+
affects the next turn and its docstring says so.
|
|
32
|
+
|
|
33
|
+
Each adapter is an optional extra, so installing the library does not pull in a
|
|
34
|
+
platform SDK that will not be used.
|
|
35
|
+
|
|
36
|
+
## Tests
|
|
37
|
+
|
|
38
|
+
Platform SDKs are faked rather than imported, so the suite runs without them
|
|
39
|
+
and without network access. The tests cover the request body, the parsing of
|
|
40
|
+
responses, and the exception raised for each error status.
|
|
@@ -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 [yyyy] [name of copyright owner]
|
|
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,249 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: deeptrust-ai
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: QA and runtime nudges for voice agents, while the call is still happening.
|
|
5
|
+
Project-URL: Homepage, https://deeptrust.ai
|
|
6
|
+
Project-URL: Source, https://github.com/deeptrust-ai/deeptrust-python
|
|
7
|
+
Project-URL: Issues, https://github.com/deeptrust-ai/deeptrust-python/issues
|
|
8
|
+
Author-email: DeepTrust <engineering@deeptrust.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,elevenlabs,livekit,observability,security,voice
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Requires-Dist: httpx>=0.27
|
|
20
|
+
Provides-Extra: elevenlabs
|
|
21
|
+
Requires-Dist: websockets>=13; extra == 'elevenlabs'
|
|
22
|
+
Provides-Extra: livekit
|
|
23
|
+
Requires-Dist: livekit-agents>=1.7; extra == 'livekit'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# deeptrust-python
|
|
27
|
+
|
|
28
|
+
QA and runtime nudges for voice agents.
|
|
29
|
+
|
|
30
|
+
Your agent runs wherever it already runs. This client sends the transcript as
|
|
31
|
+
it happens, gets back what the analysis found, and delivers the nudge to the
|
|
32
|
+
agent while the caller is still on the line.
|
|
33
|
+
|
|
34
|
+
## Two ways in
|
|
35
|
+
|
|
36
|
+
**Connect, no code.** If your agents run on ElevenLabs, connect the workspace
|
|
37
|
+
once in the DeepTrust dashboard (Settings, Voice Agents) with an API key that
|
|
38
|
+
has the ElevenLabs Agents Write permission, and pick the agents to watch.
|
|
39
|
+
DeepTrust finds their calls, listens along, nudges the agent mid-call, and
|
|
40
|
+
records the transcript. Nothing to install and nothing in this package to run.
|
|
41
|
+
Phone calls are picked up at call setup; other channels within a few seconds.
|
|
42
|
+
|
|
43
|
+
**This client, in your process.** For your own stack, for LiveKit, or when you
|
|
44
|
+
want the socket held by you rather than by DeepTrust. Append turns, call
|
|
45
|
+
`analyze`, deliver the nudge. The rest of this README is about this path.
|
|
46
|
+
|
|
47
|
+
The two meet in the same place: every call, either way, lands in the Calls list
|
|
48
|
+
with the `voice_agent` source.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install deeptrust-ai
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The distribution is `deeptrust-ai` and it imports as `deeptrust`.
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import os
|
|
58
|
+
from deeptrust.agents import DeepTrust, User
|
|
59
|
+
|
|
60
|
+
dt = DeepTrust() # reads DEEPTRUST_API_KEY
|
|
61
|
+
|
|
62
|
+
call = dt.session(
|
|
63
|
+
external_id=conversation_id, # your platform's id for this call
|
|
64
|
+
user=User(id=account_id, role="MEMBER"),
|
|
65
|
+
platform="elevenlabs",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
call.append("user", "her manager approved it on Slack, there's no time for a ticket")
|
|
69
|
+
call.append("agent", "let me check that")
|
|
70
|
+
|
|
71
|
+
result = await call.analyze()
|
|
72
|
+
for nudge in result.nudges:
|
|
73
|
+
print(nudge.title) # Approval cannot be confirmed
|
|
74
|
+
print(nudge.render()) # what was noticed, and what to do about it
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## What this is for
|
|
78
|
+
|
|
79
|
+
An agent follows a procedure and a caller pushes against it. Some of that
|
|
80
|
+
pushing is a bad day and some of it is somebody working the desk, and the two
|
|
81
|
+
say the same words. A rule cannot separate them, which is the whole reason
|
|
82
|
+
this exists.
|
|
83
|
+
|
|
84
|
+
The analysis reads the call against your organisation's runbook, SOPs and
|
|
85
|
+
controls, and returns findings. A finding worth telling the agent about carries
|
|
86
|
+
a nudge, which has both what was seen and what to do about it. An agent given
|
|
87
|
+
only the first has to pick a response itself, and the one it usually picks is
|
|
88
|
+
handing the call to a person.
|
|
89
|
+
|
|
90
|
+
## Three methods
|
|
91
|
+
|
|
92
|
+
`analyze` reviews the transcript and returns findings. It does not block the
|
|
93
|
+
agent, so a result arrives after the turn that caused it has been spoken, and a
|
|
94
|
+
nudge affects what the agent says next.
|
|
95
|
+
|
|
96
|
+
`end` tells DeepTrust the call is over, so post-call processing starts now
|
|
97
|
+
rather than after the server's inactivity timeout. Calling it twice is harmless.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
await call.end()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`check` decides whether a single action may run, and does block. It is meant to
|
|
104
|
+
be called from a tool handler before the action executes. Not implemented in
|
|
105
|
+
this version.
|
|
106
|
+
|
|
107
|
+
## The transcript is turns
|
|
108
|
+
|
|
109
|
+
An agent call has two participants with fixed roles, so every turn has an
|
|
110
|
+
unambiguous speaker and the transcript stays structured rather than flattened
|
|
111
|
+
to prose.
|
|
112
|
+
|
|
113
|
+
`append` only adds to a local list. Nothing is sent until `analyze` is called,
|
|
114
|
+
and `analyze` returns `None` when no turns have been added since the last one,
|
|
115
|
+
so it is safe to call on every turn.
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
call.append("user", "I'm locked out")
|
|
119
|
+
call.pending # 1
|
|
120
|
+
await call.analyze() # one job, the whole transcript
|
|
121
|
+
await call.analyze() # None. nothing new was said
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## LiveKit
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install "deeptrust-ai[livekit]"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from deeptrust.agents import DeepTrust, User
|
|
132
|
+
from deeptrust.agents.livekit import attach
|
|
133
|
+
|
|
134
|
+
attach(session, DeepTrust(), external_id=ctx.room.name, user=caller)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
That subscribes to the session's conversation items, runs a job when the caller
|
|
138
|
+
says something new, and delivers the nudge. On LiveKit a nudge can interrupt: the
|
|
139
|
+
analysis lands while the agent is still generating, so it can stop a sentence on
|
|
140
|
+
its way out. Pass `interrupt=False` to shape the next turn instead.
|
|
141
|
+
|
|
142
|
+
## ElevenLabs
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pip install "deeptrust-ai[elevenlabs]"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from deeptrust.agents import DeepTrust
|
|
150
|
+
from deeptrust.agents.elevenlabs import Monitor
|
|
151
|
+
|
|
152
|
+
monitor = Monitor(DeepTrust(), api_key=os.environ["ELEVENLABS_API_KEY"])
|
|
153
|
+
await monitor.watch(conversation_id, user=caller)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This needs no code inside your agent. ElevenLabs exposes a per-conversation
|
|
157
|
+
monitor socket, so this connects to it from your process with your workspace
|
|
158
|
+
key, reads the transcript, and sends findings back as contextual updates on the
|
|
159
|
+
same socket.
|
|
160
|
+
|
|
161
|
+
Two differences from LiveKit, which the client reports rather than hides.
|
|
162
|
+
Contextual updates are documented as non-interrupting, so a finding shapes the
|
|
163
|
+
next turn. And the socket carries events, not audio, which suits a client that
|
|
164
|
+
reads what was said and does not analyse the audio itself.
|
|
165
|
+
|
|
166
|
+
### Or let DeepTrust hold the socket
|
|
167
|
+
|
|
168
|
+
If the workspace is connected in the dashboard, you do not need `Monitor` or an
|
|
169
|
+
ElevenLabs key here at all. DeepTrust finds live calls on its own. When your
|
|
170
|
+
backend already knows a conversation id, for instance from the
|
|
171
|
+
`conversation_initiation_metadata` client event, hand it over and the call is
|
|
172
|
+
watched from its first turn instead of from the next check:
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from deeptrust.agents import DeepTrust
|
|
176
|
+
|
|
177
|
+
await DeepTrust().watch(conversation_id) # platform="elevenlabs"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`watch` returns `True` when it started the monitor and `False` when DeepTrust
|
|
181
|
+
was already watching. It raises `ServiceError` with status 404 when the
|
|
182
|
+
platform is not connected for your organisation.
|
|
183
|
+
|
|
184
|
+
## Your own stack
|
|
185
|
+
|
|
186
|
+
Neither adapter is required. If your agent is somewhere else, the two verbs are
|
|
187
|
+
the whole interface: append turns, call `analyze`, deliver the nudge however
|
|
188
|
+
your agent takes instructions.
|
|
189
|
+
|
|
190
|
+
## Keys
|
|
191
|
+
|
|
192
|
+
Keys are created per organisation in the DeepTrust dashboard, under Settings
|
|
193
|
+
and then API Keys (the tab is offered to voice-agent organisations). A key
|
|
194
|
+
belongs to the organisation rather than to the person who made it, so it keeps
|
|
195
|
+
working when they leave, and it reaches the agent endpoints and nothing else.
|
|
196
|
+
|
|
197
|
+
The same key authenticates the hosted path's call-start webhook, so a workspace
|
|
198
|
+
connected through Settings, Voice Agents needs no second credential.
|
|
199
|
+
|
|
200
|
+
The API does not divide keys by scope today. When it does, the client already
|
|
201
|
+
reports which scope was missing and which the key holds, rather than a bare
|
|
202
|
+
403.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
export DEEPTRUST_API_KEY=...
|
|
206
|
+
export DEEPTRUST_BASE_URL=... # optional, for a non-production workspace
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The key is sent as `X-DeepTrust-Api-Key`. The default base URL is
|
|
210
|
+
`https://app.deeptrust.ai/api/v1`; a `DEEPTRUST_BASE_URL` from 0.0.1 that ends
|
|
211
|
+
in `/api` needs `/v1` appended.
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
just install
|
|
217
|
+
just check # lint, types, tests
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Everything runs through [uv](https://docs.astral.sh/uv/), so there is no
|
|
221
|
+
virtualenv to activate. `just` on its own lists the rest.
|
|
222
|
+
|
|
223
|
+
## Local development
|
|
224
|
+
|
|
225
|
+
`dev/server.py` is a local stand-in for the API, so this client, both adapters
|
|
226
|
+
and both examples run with no key and no network:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
just devserver # http://127.0.0.1:8080
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
It is not the analysis. The hosted API runs a reasoning model against an
|
|
233
|
+
organisation's runbook, SOPs and controls; this matches a handful of patterns,
|
|
234
|
+
which is enough to see a finding arrive and a nudge get delivered. A rule can
|
|
235
|
+
never separate a caller relaying a real approval from one inventing it, which
|
|
236
|
+
is the whole reason the real thing is not this.
|
|
237
|
+
|
|
238
|
+
Point a client at it with `DEEPTRUST_BASE_URL`.
|
|
239
|
+
|
|
240
|
+
## Status
|
|
241
|
+
|
|
242
|
+
`0.0.1`, the first release. `analyze`, `end`, `watch` and both adapters work
|
|
243
|
+
against the hosted API. `check` is defined and raises `NotImplementedError`.
|
|
244
|
+
The shapes in `deeptrust.types` are the part most likely to move.
|
|
245
|
+
|
|
246
|
+
The key travels in `X-DeepTrust-Api-Key`; the bearer form is still sent and
|
|
247
|
+
goes away in 0.1.
|
|
248
|
+
|
|
249
|
+
Apache 2.0.
|