Praxos-python 0.1.6__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.
- praxos_python-0.1.6/.gitignore +177 -0
- praxos_python-0.1.6/LICENSE +201 -0
- praxos_python-0.1.6/PKG-INFO +11 -0
- praxos_python-0.1.6/README.md +1 -0
- praxos_python-0.1.6/pyproject.toml +11 -0
- praxos_python-0.1.6/src/praxos_python/__init__.py +28 -0
- praxos_python-0.1.6/src/praxos_python/client.py +136 -0
- praxos_python-0.1.6/src/praxos_python/config.py +39 -0
- praxos_python-0.1.6/src/praxos_python/exceptions.py +20 -0
- praxos_python-0.1.6/src/praxos_python/models/__init__.py +10 -0
- praxos_python-0.1.6/src/praxos_python/models/context.py +14 -0
- praxos_python-0.1.6/src/praxos_python/models/environment.py +120 -0
- praxos_python-0.1.6/src/praxos_python/models/ontology.py +20 -0
- praxos_python-0.1.6/src/praxos_python/models/source.py +29 -0
- praxos_python-0.1.6/src/praxos_python/types/__init__.py +0 -0
- praxos_python-0.1.6/src/praxos_python/types/message.py +44 -0
- praxos_python-0.1.6/src/praxos_python/utils.py +32 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
|
175
|
+
|
|
176
|
+
.vscode/
|
|
177
|
+
tests/*
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Praxos-python
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: Python SDK for Praxos
|
|
5
|
+
Author-email: Masoud Kermani Poor <masoud@praxos.ai>
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: httpx
|
|
8
|
+
Requires-Dist: pydantic
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# Praxos
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Praxos
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "Praxos-python"
|
|
3
|
+
version = "0.1.6"
|
|
4
|
+
description = "Python SDK for Praxos"
|
|
5
|
+
authors = [{ name = "Masoud Kermani Poor", email = "masoud@praxos.ai" }]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
dependencies = ["pydantic", "httpx"]
|
|
8
|
+
|
|
9
|
+
[build-system]
|
|
10
|
+
requires = ["hatchling"]
|
|
11
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Praxos Python SDK
|
|
3
|
+
"""
|
|
4
|
+
from .config import ClientConfig, DEFAULT_BASE_URL, SDK_VERSION
|
|
5
|
+
from .exceptions import APIError
|
|
6
|
+
|
|
7
|
+
# Client Imports
|
|
8
|
+
from .client import SyncClient
|
|
9
|
+
|
|
10
|
+
# Model/Resource Imports (these are the classes users will interact with)
|
|
11
|
+
from .models import (
|
|
12
|
+
SyncEnvironment,
|
|
13
|
+
SyncSource,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
# Config and Exceptions
|
|
19
|
+
'ClientConfig',
|
|
20
|
+
'DEFAULT_BASE_URL',
|
|
21
|
+
'SDK_VERSION',
|
|
22
|
+
'APIError',
|
|
23
|
+
|
|
24
|
+
# Sync components
|
|
25
|
+
'SyncClient',
|
|
26
|
+
'SyncEnvironment',
|
|
27
|
+
'SyncSource',
|
|
28
|
+
]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# my_api_sdk/sync_client.py
|
|
2
|
+
import httpx
|
|
3
|
+
from typing import Dict, Any, Optional, List
|
|
4
|
+
|
|
5
|
+
from .config import ClientConfig
|
|
6
|
+
from .exceptions import APIError, APIKeyInvalidError
|
|
7
|
+
from .utils import parse_httpx_error, handle_response_content
|
|
8
|
+
from .models import SyncEnvironment, SyncOntology
|
|
9
|
+
from pydantic import BaseModel
|
|
10
|
+
from typing import Type, Union
|
|
11
|
+
from pydantic import TypeAdapter
|
|
12
|
+
|
|
13
|
+
class SyncClient:
|
|
14
|
+
"""Synchronous client for interacting with the API."""
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
api_key: str,
|
|
18
|
+
base_url: Optional[str] = None,
|
|
19
|
+
params: Optional[Dict[str, Any]] = None,
|
|
20
|
+
timeout: float = 10.0,
|
|
21
|
+
):
|
|
22
|
+
self.config = ClientConfig(
|
|
23
|
+
api_key=api_key, base_url=base_url, timeout=timeout, params=params
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
self._http_client = httpx.Client(
|
|
27
|
+
base_url=self.config.base_url,
|
|
28
|
+
headers=self.config.common_headers,
|
|
29
|
+
timeout=self.config.timeout,
|
|
30
|
+
params=self.config.params,
|
|
31
|
+
**self.config.httpx_settings
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
self.validate_api_key()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _request(
|
|
38
|
+
self,
|
|
39
|
+
method: str,
|
|
40
|
+
endpoint: str,
|
|
41
|
+
params: Optional[Dict[str, Any]] = None,
|
|
42
|
+
json_data: Optional[Dict[str, Any]] = None,
|
|
43
|
+
data: Optional[Dict[str, Any]] = None,
|
|
44
|
+
files: Optional[Dict[str, Any]] = None
|
|
45
|
+
) -> Dict[str, Any]:
|
|
46
|
+
try:
|
|
47
|
+
response = self._http_client.request(
|
|
48
|
+
method,
|
|
49
|
+
url=endpoint.lstrip('/'),
|
|
50
|
+
params=params,
|
|
51
|
+
json=json_data if not files and not data else None,
|
|
52
|
+
data=data,
|
|
53
|
+
files=files
|
|
54
|
+
)
|
|
55
|
+
response.raise_for_status()
|
|
56
|
+
return handle_response_content(response)
|
|
57
|
+
except httpx.HTTPStatusError as e:
|
|
58
|
+
raise parse_httpx_error(e) from e
|
|
59
|
+
except httpx.RequestError as e:
|
|
60
|
+
raise APIError(status_code=0, message=f"Request failed: {str(e)}") from e
|
|
61
|
+
|
|
62
|
+
def validate_api_key(self) -> None:
|
|
63
|
+
"""Validates the API key."""
|
|
64
|
+
self._request("GET", "api-token-validataion")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def create_environment(self, name: str, description: str=None, ontologies: List[Union[SyncOntology, str]]=None) -> SyncEnvironment:
|
|
68
|
+
"""Creates an environment."""
|
|
69
|
+
|
|
70
|
+
if not name:
|
|
71
|
+
raise ValueError("Environment name is required")
|
|
72
|
+
|
|
73
|
+
ontology_ids = [ontology.id if isinstance(ontology, SyncOntology) else ontology for ontology in ontologies] if ontologies else None
|
|
74
|
+
|
|
75
|
+
response_data = self._request("POST", "environment", json_data={"name": name, "description": description, "ontology_ids": ontology_ids})
|
|
76
|
+
return SyncEnvironment(client=self, **response_data)
|
|
77
|
+
|
|
78
|
+
def get_environments(self) -> List[SyncEnvironment]:
|
|
79
|
+
"""Retrieves all environments."""
|
|
80
|
+
response_data = self._request("GET", "environment")
|
|
81
|
+
return [SyncEnvironment(client=self, **env) for env in response_data]
|
|
82
|
+
|
|
83
|
+
def get_environment(self, id: str=None, name: str=None) -> SyncEnvironment:
|
|
84
|
+
"""Retrieves an environment by name or id."""
|
|
85
|
+
|
|
86
|
+
if id is None and name is None:
|
|
87
|
+
raise ValueError("Either id or name must be provided")
|
|
88
|
+
|
|
89
|
+
if id:
|
|
90
|
+
response_data = self._request("GET", "environment", params={"id": id})
|
|
91
|
+
else:
|
|
92
|
+
response_data = self._request("GET", "environment", params={"name": name})
|
|
93
|
+
return SyncEnvironment(client=self, **response_data)
|
|
94
|
+
|
|
95
|
+
def create_ontology(self, name: str, schemas: List[Type[BaseModel]], description: str=None) -> SyncOntology:
|
|
96
|
+
"""Creates an ontology."""
|
|
97
|
+
if not name:
|
|
98
|
+
raise ValueError("Ontology name is required")
|
|
99
|
+
|
|
100
|
+
if not schemas:
|
|
101
|
+
raise ValueError("At least one schema is required")
|
|
102
|
+
|
|
103
|
+
if not isinstance(schemas, list):
|
|
104
|
+
raise ValueError("Schemas must be a list")
|
|
105
|
+
|
|
106
|
+
json_schema = TypeAdapter(Union[tuple(schemas)]).json_schema()
|
|
107
|
+
response_data = self._request("POST", "ontology", json_data={"name": name, "description": description, "schemas": json_schema})
|
|
108
|
+
return SyncOntology(client=self, **response_data)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def get_ontology(self, id: str=None, name: str=None) -> SyncOntology:
|
|
112
|
+
"""Retrieves an ontology by name or id."""
|
|
113
|
+
|
|
114
|
+
if id is None and name is None:
|
|
115
|
+
raise ValueError("Either id or name must be provided")
|
|
116
|
+
|
|
117
|
+
if id:
|
|
118
|
+
response_data = self._request("GET", "ontology", params={"id": id})
|
|
119
|
+
else:
|
|
120
|
+
response_data = self._request("GET", "ontology", params={"name": name})
|
|
121
|
+
return SyncOntology(client=self, **response_data)
|
|
122
|
+
|
|
123
|
+
def get_ontologies(self) -> List[SyncOntology]:
|
|
124
|
+
"""Retrieves all ontologies."""
|
|
125
|
+
response_data = self._request("GET", "ontology")
|
|
126
|
+
return [SyncOntology(client=self, **ontology) for ontology in response_data]
|
|
127
|
+
|
|
128
|
+
def close(self) -> None:
|
|
129
|
+
"""Closes the underlying httpx client."""
|
|
130
|
+
self._http_client.close()
|
|
131
|
+
|
|
132
|
+
def __enter__(self) -> 'SyncClient':
|
|
133
|
+
return self
|
|
134
|
+
|
|
135
|
+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
|
136
|
+
self.close()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from typing import Optional, Dict, Any, Union
|
|
2
|
+
import httpx
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
if sys.version_info >= (3, 8):
|
|
7
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
8
|
+
else:
|
|
9
|
+
from importlib_metadata import version, PackageNotFoundError
|
|
10
|
+
|
|
11
|
+
SDK_VERSION = version("Praxos-python")
|
|
12
|
+
except PackageNotFoundError:
|
|
13
|
+
SDK_VERSION = "0.0.0-dev"
|
|
14
|
+
|
|
15
|
+
DEFAULT_BASE_URL = "https://api.praxos.ai/"
|
|
16
|
+
|
|
17
|
+
class ClientConfig:
|
|
18
|
+
"""Configuration settings for API clients."""
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
api_key: str,
|
|
22
|
+
base_url: Optional[str] = None,
|
|
23
|
+
timeout: float = 10.0,
|
|
24
|
+
params: Optional[Dict[str, Any]] = None,
|
|
25
|
+
httpx_settings: Optional[Dict[str, Any]] = None
|
|
26
|
+
):
|
|
27
|
+
if not api_key:
|
|
28
|
+
raise ValueError("API key is required.")
|
|
29
|
+
|
|
30
|
+
self.api_key = api_key
|
|
31
|
+
self.base_url = httpx.URL(base_url or DEFAULT_BASE_URL)
|
|
32
|
+
self.timeout = timeout
|
|
33
|
+
self.params = params or {}
|
|
34
|
+
self.httpx_settings = httpx_settings or {}
|
|
35
|
+
|
|
36
|
+
self.common_headers = {
|
|
37
|
+
"api-key": f"{self.api_key}",
|
|
38
|
+
"User-Agent": f"Praxos Python SDK/{SDK_VERSION}"
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# my_api_sdk/exceptions.py
|
|
2
|
+
class APIError(Exception):
|
|
3
|
+
"""Custom exception for API errors."""
|
|
4
|
+
def __init__(self, status_code: int, message: str, response_data: dict = None, **kwargs):
|
|
5
|
+
self.status_code = status_code
|
|
6
|
+
self.message = message
|
|
7
|
+
self.response_data = response_data or {}
|
|
8
|
+
super().__init__(f"API Error {status_code}: {message}")
|
|
9
|
+
|
|
10
|
+
def __str__(self):
|
|
11
|
+
return f"APIError(status_code={self.status_code}, message='{self.message}', details={self.response_data})"
|
|
12
|
+
|
|
13
|
+
class APIKeyInvalidError(APIError):
|
|
14
|
+
"""Exception raised when the API token/key is invalid."""
|
|
15
|
+
def __init__(self, message: str = "Invalid API token", **kwargs):
|
|
16
|
+
super().__init__(status_code=401, message=message, **kwargs)
|
|
17
|
+
|
|
18
|
+
def __str__(self):
|
|
19
|
+
return f"APIKeyInvalidError: {self.message}"
|
|
20
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
|
|
3
|
+
class Context:
|
|
4
|
+
"""A context object."""
|
|
5
|
+
def __init__(self, score: float, data: Dict[str, Any], sentence: str):
|
|
6
|
+
self.score = score
|
|
7
|
+
self.data = data
|
|
8
|
+
self.sentence = sentence
|
|
9
|
+
|
|
10
|
+
def __repr__(self) -> str:
|
|
11
|
+
return f"<Context score={self.score} data={self.data} sentence={self.sentence}>"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import TYPE_CHECKING, List, Dict, Any
|
|
3
|
+
from .source import SyncSource
|
|
4
|
+
from ..exceptions import APIError
|
|
5
|
+
from .context import Context
|
|
6
|
+
from ..types.message import Message
|
|
7
|
+
|
|
8
|
+
ACCEPTABLE_SOURCE_EXTENSIONS_TO_CONTENT_TYPE = {
|
|
9
|
+
"pdf": "application/pdf",
|
|
10
|
+
"json": "application/json",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class BaseEnvironmentAttributes:
|
|
14
|
+
"""
|
|
15
|
+
Base attributes for an Environment resource.
|
|
16
|
+
Ensures consistent initialization with core fields.
|
|
17
|
+
"""
|
|
18
|
+
def __init__(self, id: str, name: str, created_at: str, description: str, **kwargs):
|
|
19
|
+
self.id = id
|
|
20
|
+
self.name = name
|
|
21
|
+
self.created_at = created_at
|
|
22
|
+
self.description = description
|
|
23
|
+
|
|
24
|
+
class SyncEnvironment(BaseEnvironmentAttributes):
|
|
25
|
+
"""Represents a synchronous Environment resource."""
|
|
26
|
+
def __init__(self, client, id: str, name: str, created_at: str, description: str, **data: Any):
|
|
27
|
+
super().__init__(id=id, name=name, created_at=created_at, description=description, **data)
|
|
28
|
+
self._client = client
|
|
29
|
+
|
|
30
|
+
def __repr__(self) -> str:
|
|
31
|
+
return f"<SyncEnvironment id='{self.id}' name='{self.name}'>"
|
|
32
|
+
|
|
33
|
+
def get_context(self, query: str, top_k: int = 1) -> Context|List[Context]:
|
|
34
|
+
"""Gets context for an LLM."""
|
|
35
|
+
# print(f"SDK (Sync Env: {self.name}): API to get context for query '{query}'...") # For debugging
|
|
36
|
+
response_data = self._client._request(
|
|
37
|
+
"POST", f"/search", json_data={"query": query, "top_k": top_k, "environment_id": self.id}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
contexts = []
|
|
41
|
+
for context in response_data["hits"]:
|
|
42
|
+
contexts.append(Context(score=context["score"], data=context["data"], sentence=context["sentence"]))
|
|
43
|
+
|
|
44
|
+
if top_k == 1:
|
|
45
|
+
return contexts[0]
|
|
46
|
+
else:
|
|
47
|
+
return contexts
|
|
48
|
+
|
|
49
|
+
def add_conversation(self, messages: List[Message|Dict[str, str]], name: str=None, description: str=None) -> SyncSource:
|
|
50
|
+
"""Adds a conversation source."""
|
|
51
|
+
if len(messages) == 0:
|
|
52
|
+
raise ValueError("Messages must be a non-empty list")
|
|
53
|
+
|
|
54
|
+
messages = [Message.from_dict(message) if isinstance(message, dict) else message for message in messages]
|
|
55
|
+
|
|
56
|
+
payload = {
|
|
57
|
+
"messages": [message.to_dict() for message in messages],
|
|
58
|
+
"description": description
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if name:
|
|
62
|
+
payload["name"] = name
|
|
63
|
+
|
|
64
|
+
response_data = self._client._request("POST", f"/sources", params={"type": "conversation", "environment_id": self.id}, json_data=payload)
|
|
65
|
+
return SyncSource(client=self._client, **response_data)
|
|
66
|
+
|
|
67
|
+
def add_file(self, path: str, name: str=None, description: str=None) -> SyncSource:
|
|
68
|
+
"""Adds a file source."""
|
|
69
|
+
global ACCEPTABLE_SOURCE_EXTENSIONS_TO_CONTENT_TYPE
|
|
70
|
+
|
|
71
|
+
if not os.path.exists(path):
|
|
72
|
+
raise FileNotFoundError(f"File not found: {path}")
|
|
73
|
+
|
|
74
|
+
file_extension = path.split('.')[-1]
|
|
75
|
+
if file_extension not in ACCEPTABLE_SOURCE_EXTENSIONS_TO_CONTENT_TYPE:
|
|
76
|
+
raise ValueError(f"File extension {file_extension} is not supported. Supported extensions are: {', '.join(ACCEPTABLE_SOURCE_EXTENSIONS_TO_CONTENT_TYPE.keys())}")
|
|
77
|
+
|
|
78
|
+
if name is None:
|
|
79
|
+
name = '.'.join(os.path.basename(path).split('.')[:-1])
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
with open(path, 'rb') as f:
|
|
83
|
+
files = {'file': (name, f, ACCEPTABLE_SOURCE_EXTENSIONS_TO_CONTENT_TYPE[file_extension])}
|
|
84
|
+
form_data = {"type": "file", "name": name, "description": description}
|
|
85
|
+
response_data = self._client._request(
|
|
86
|
+
"POST", f"sources", params={"environment_id": self.id}, data=form_data, files=files
|
|
87
|
+
)
|
|
88
|
+
return SyncSource(client=self._client, **response_data)
|
|
89
|
+
except FileNotFoundError:
|
|
90
|
+
raise ValueError(f"File not found: {path}")
|
|
91
|
+
except Exception as e:
|
|
92
|
+
raise APIError(status_code=0, message=f"Sync file upload failed: {str(e)}") from e
|
|
93
|
+
|
|
94
|
+
def add_business_data(self, data: Dict[str, Any], name: str=None, description: str=None) -> SyncSource:
|
|
95
|
+
"""Adds business data source."""
|
|
96
|
+
payload = {
|
|
97
|
+
"data": data,
|
|
98
|
+
"name": name,
|
|
99
|
+
"description": description
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
response_data = self._client._request("POST", f"/sources", params={"environment_id": self.id}, json_data=payload)
|
|
103
|
+
return SyncSource(client=self._client, **response_data)
|
|
104
|
+
|
|
105
|
+
def get_sources(self) -> List[SyncSource]:
|
|
106
|
+
"""Gets all sources for the environment."""
|
|
107
|
+
response_data = self._client._request("GET", f"/sources", params={"environment_id": self.id})
|
|
108
|
+
return [SyncSource(client=self._client, **source) for source in response_data]
|
|
109
|
+
|
|
110
|
+
def get_source(self, id: str=None, name: str=None) -> SyncSource:
|
|
111
|
+
"""Gets a source for the environment."""
|
|
112
|
+
if id is None and name is None:
|
|
113
|
+
raise ValueError("Either id or name must be provided")
|
|
114
|
+
|
|
115
|
+
if id:
|
|
116
|
+
response_data = self._client._request("GET", f"/sources", params={"environment_id": self.id, "id": id})
|
|
117
|
+
else:
|
|
118
|
+
response_data = self._client._request("GET", f"/sources", params={"environment_id": self.id, "name": name})
|
|
119
|
+
|
|
120
|
+
return SyncSource(client=self._client, **response_data)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
class BaseOntologyAttributes:
|
|
4
|
+
"""
|
|
5
|
+
Base attributes for an Ontology resource.
|
|
6
|
+
Ensures consistent initialization with core fields.
|
|
7
|
+
"""
|
|
8
|
+
def __init__(self, id: str, name: str, description: str, **kwargs):
|
|
9
|
+
self.id = id
|
|
10
|
+
self.name = name
|
|
11
|
+
self.description = description
|
|
12
|
+
|
|
13
|
+
class SyncOntology(BaseOntologyAttributes):
|
|
14
|
+
"""Represents an Ontology resource."""
|
|
15
|
+
def __init__(self, client, id: str, name: str, description: str, **data: Any):
|
|
16
|
+
super().__init__(id=id, name=name, description=description, **data)
|
|
17
|
+
self._client = client
|
|
18
|
+
|
|
19
|
+
def __repr__(self) -> str:
|
|
20
|
+
return f"<Ontology id='{self.id}' name='{self.name}'>"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
|
|
3
|
+
class BaseSourceAttributes:
|
|
4
|
+
"""
|
|
5
|
+
Base attributes for a Source resource.
|
|
6
|
+
Ensures consistent initialization with core fields.
|
|
7
|
+
"""
|
|
8
|
+
def __init__(self, id: str, environment_id: str, name: str, created_at: str, description: str, **kwargs):
|
|
9
|
+
self.id = id
|
|
10
|
+
self.name = name
|
|
11
|
+
self.created_at = created_at
|
|
12
|
+
self._environment_id = environment_id
|
|
13
|
+
self.description = description
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SyncSource(BaseSourceAttributes):
|
|
17
|
+
"""Represents a synchronous Source resource."""
|
|
18
|
+
def __init__(self, client, id: str, environment_id: str, name: str, created_at: str, description: str, **data: Any):
|
|
19
|
+
super().__init__(id=id, environment_id=environment_id, name=name, created_at=created_at, description=description, **data)
|
|
20
|
+
self._client = client
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __repr__(self) -> str:
|
|
24
|
+
return f"<SyncSource id='{self.id}' name='{self.name}'>"
|
|
25
|
+
|
|
26
|
+
def get_status(self) -> str:
|
|
27
|
+
"""Gets the status of the source."""
|
|
28
|
+
response_data = self._client._request("GET", f"/sources", params={"environment_id": self._environment_id, "id": self.id})
|
|
29
|
+
return response_data.get("status", "unknown")
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
class Message(BaseModel):
|
|
6
|
+
content: str = Field(
|
|
7
|
+
description="The content of the message",
|
|
8
|
+
min_length=1
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
role: typing.Optional[str] = Field(
|
|
12
|
+
description="The role of the message sender (e.g., 'user', 'assistant', 'system')",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
timestamp: datetime = Field(
|
|
16
|
+
description="The timestamp when the message was created",
|
|
17
|
+
default_factory=datetime.now
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def to_dict(self) -> dict:
|
|
21
|
+
return {
|
|
22
|
+
"content": self.content,
|
|
23
|
+
"role": self.role,
|
|
24
|
+
"timestamp": self.timestamp.isoformat()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def from_dict(cls, data: dict) -> "Message":
|
|
29
|
+
"""
|
|
30
|
+
Create a Message instance from a dictionary.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
data (dict): Dictionary containing message data with keys:
|
|
34
|
+
- content (str): The message content
|
|
35
|
+
- role (str, optional): The role of the message sender
|
|
36
|
+
- timestamp (str, optional): ISO format timestamp string
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Message: A new Message instance
|
|
40
|
+
"""
|
|
41
|
+
if "timestamp" in data:
|
|
42
|
+
data["timestamp"] = datetime.fromisoformat(data["timestamp"])
|
|
43
|
+
return cls(**data)
|
|
44
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
from .exceptions import APIError, APIKeyInvalidError
|
|
4
|
+
|
|
5
|
+
def parse_httpx_error(e: httpx.HTTPStatusError) -> APIError:
|
|
6
|
+
"""Helper to parse HTTPStatusError into APIError."""
|
|
7
|
+
error_message = str(e)
|
|
8
|
+
response_data = {}
|
|
9
|
+
try:
|
|
10
|
+
error_details = e.response.json()
|
|
11
|
+
response_data = error_details
|
|
12
|
+
if isinstance(error_details, dict):
|
|
13
|
+
error_message = error_details.get("message", error_details.get("error", str(e)))
|
|
14
|
+
|
|
15
|
+
except Exception:
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
if e.response.status_code == 401:
|
|
19
|
+
return APIKeyInvalidError(message=error_message, response_data=response_data)
|
|
20
|
+
|
|
21
|
+
return APIError(status_code=e.response.status_code, message=error_message, response_data=response_data)
|
|
22
|
+
|
|
23
|
+
def handle_response_content(response: httpx.Response) -> Dict[str, Any]:
|
|
24
|
+
"""
|
|
25
|
+
Processes httpx.Response content after raise_for_status.
|
|
26
|
+
Assumes response.raise_for_status() has been called.
|
|
27
|
+
"""
|
|
28
|
+
if response.status_code == 204: # No Content
|
|
29
|
+
return {}
|
|
30
|
+
if not response.content:
|
|
31
|
+
return {}
|
|
32
|
+
return response.json()
|