vardast 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vardast-0.1.0/.gitignore +41 -0
- vardast-0.1.0/LICENSE +21 -0
- vardast-0.1.0/PKG-INFO +183 -0
- vardast-0.1.0/README.md +151 -0
- vardast-0.1.0/examples/list_assistants.py +32 -0
- vardast-0.1.0/examples/quickstart.py +58 -0
- vardast-0.1.0/pyproject.toml +67 -0
- vardast-0.1.0/src/vardast/__init__.py +62 -0
- vardast-0.1.0/src/vardast/client.py +690 -0
- vardast-0.1.0/src/vardast/exceptions.py +52 -0
- vardast-0.1.0/src/vardast/models.py +210 -0
- vardast-0.1.0/src/vardast/py.typed +1 -0
- vardast-0.1.0/tests/conftest.py +24 -0
- vardast-0.1.0/tests/test_client.py +395 -0
vardast-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Byte-compiled / cache
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.eggs/
|
|
11
|
+
*.egg
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
ENV/
|
|
17
|
+
env/
|
|
18
|
+
|
|
19
|
+
# Test / coverage
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
.coverage
|
|
22
|
+
.coverage.*
|
|
23
|
+
htmlcov/
|
|
24
|
+
.tox/
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
|
|
28
|
+
# IDE / OS
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
*.swp
|
|
32
|
+
.DS_Store
|
|
33
|
+
|
|
34
|
+
# Secrets / local
|
|
35
|
+
.env
|
|
36
|
+
.env.*
|
|
37
|
+
!.env.example
|
|
38
|
+
*.pem
|
|
39
|
+
|
|
40
|
+
# Packaging
|
|
41
|
+
pip-wheel-metadata/
|
vardast-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vardast
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
vardast-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: vardast
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Vardast Public API
|
|
5
|
+
Project-URL: Homepage, https://github.com/technicalvardast/vardast-python
|
|
6
|
+
Project-URL: Documentation, https://vardast.chat/docs/public-api
|
|
7
|
+
Project-URL: Repository, https://github.com/technicalvardast/vardast-python
|
|
8
|
+
Project-URL: Issues, https://github.com/technicalvardast/vardast-python/issues
|
|
9
|
+
Author-email: Vardast <hello@vardast.chat>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,api,chat,messenger,sdk,vardast
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Requires-Dist: httpx<1,>=0.27
|
|
26
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Vardast Python SDK
|
|
34
|
+
|
|
35
|
+
Official Python client for the [Vardast Public API](https://vardast.chat/docs/public-api).
|
|
36
|
+
|
|
37
|
+
Package name on PyPI: **`vardast`**
|
|
38
|
+
GitHub: [technicalvardast/vardast-python](https://github.com/technicalvardast/vardast-python)
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install vardast
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Requires Python 3.9+.
|
|
47
|
+
|
|
48
|
+
## Setup
|
|
49
|
+
|
|
50
|
+
1. Create or copy a Public API key from the Vardast panel (channel settings / Public API).
|
|
51
|
+
2. Pass it to the client as `api_key`. The SDK sends it on every request as the `X-API-Key` header.
|
|
52
|
+
3. Default base URL (override only for a private gateway):
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
https://apigw.vardast.chat/uaa/public
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from vardast import Vardast
|
|
60
|
+
|
|
61
|
+
client = Vardast(
|
|
62
|
+
api_key="your-api-key",
|
|
63
|
+
# base_url="https://apigw.vardast.chat/uaa/public", # default
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Prefer a context manager so the HTTP client closes cleanly:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
with Vardast(api_key="your-api-key") as client:
|
|
71
|
+
channels = client.list_channels()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Async support is available via `AsyncVardast`.
|
|
75
|
+
|
|
76
|
+
## Quickstart
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from vardast import Vardast
|
|
80
|
+
|
|
81
|
+
with Vardast(api_key="your-api-key") as client:
|
|
82
|
+
channels = client.list_channels()
|
|
83
|
+
channel = channels[0]
|
|
84
|
+
|
|
85
|
+
result = client.process_message(
|
|
86
|
+
message="Hello",
|
|
87
|
+
channel_id=channel.id,
|
|
88
|
+
contact_id="contact-uuid",
|
|
89
|
+
)
|
|
90
|
+
print(result.response)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
See `examples/quickstart.py` and `examples/list_assistants.py`.
|
|
94
|
+
|
|
95
|
+
## Method reference
|
|
96
|
+
|
|
97
|
+
Methods map 1:1 to the documented Public API surface.
|
|
98
|
+
|
|
99
|
+
| Method | HTTP | Path |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| `process_message(...)` | `POST` | `/messenger/api/chat/public/process` |
|
|
102
|
+
| `list_messages(channel_id, contact_id, page=1, size=20)` | `GET` | `/messenger/api/chat/{channel_id}/{contact_id}/` |
|
|
103
|
+
| `list_contacts(page=1, size=20, channel_ids=None, platform=None)` | `GET` | `/messenger/api/chat/contacts/` |
|
|
104
|
+
| `list_channels()` | `GET` | `/messenger/api/channel/` |
|
|
105
|
+
| `list_assistants()` | `GET` | `/messenger/api/assistants/` |
|
|
106
|
+
| `create_assistant(...)` | `POST` | `/messenger/api/assistants/` |
|
|
107
|
+
| `create_prompt(...)` | `POST` | `/messenger/api/prompts/` |
|
|
108
|
+
| `get_prompt(prompt_id)` | `GET` | `/messenger/api/prompts/{prompt_id}` |
|
|
109
|
+
| `list_channel_contacts(channel_id, id=None, page=1, page_size=20)` | `GET` | `/report/channel/{channel_id}/contacts` |
|
|
110
|
+
| `list_channel_orders(channel_id, order_id=None, page=1, page_size=20)` | `GET` | `/report/channel/{channel_id}/orders` |
|
|
111
|
+
| `get_usage_info()` | `GET` | `/payment/get-usage-info/` |
|
|
112
|
+
| `get_usage_activity(feature=..., ...)` | `GET` | `/payment/get-usage-activity/` |
|
|
113
|
+
|
|
114
|
+
`channel_ids` may be a comma-separated string or a sequence of IDs.
|
|
115
|
+
`get_usage_activity` requires `feature` in `{id, date, mode, period}` plus the matching query fields from the docs.
|
|
116
|
+
|
|
117
|
+
Responses are typed Pydantic models (`Message`, `Channel`, `Assistant`, `Paginated[...]`, and so on). Extra JSON fields from the API are preserved.
|
|
118
|
+
|
|
119
|
+
### Errors
|
|
120
|
+
|
|
121
|
+
| Exception | When |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| `AuthenticationError` | HTTP 401 |
|
|
124
|
+
| `NotFoundError` | HTTP 404 |
|
|
125
|
+
| `ValidationError` | HTTP 400 / 422 |
|
|
126
|
+
| `RateLimitError` | HTTP 429 |
|
|
127
|
+
| `ServerError` | HTTP 5xx |
|
|
128
|
+
| `VardastAPIError` | Other API failures |
|
|
129
|
+
| `VardastError` | Client configuration errors |
|
|
130
|
+
|
|
131
|
+
API error bodies of the form `{"detail": "..."}` are surfaced on `exc.message` / `exc.detail`.
|
|
132
|
+
|
|
133
|
+
## Development
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cd vardast-python
|
|
137
|
+
python -m venv .venv
|
|
138
|
+
source .venv/bin/activate
|
|
139
|
+
pip install -e ".[dev]"
|
|
140
|
+
pytest
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Publish to PyPI
|
|
144
|
+
|
|
145
|
+
### One-time Trusted Publisher setup (recommended)
|
|
146
|
+
|
|
147
|
+
1. Use the GitHub repository `technicalvardast/vardast-python`.
|
|
148
|
+
2. On [PyPI](https://pypi.org/manage/account/publishing/), add a Trusted Publisher:
|
|
149
|
+
- Owner: `technicalvardast`
|
|
150
|
+
- Repository: `vardast-python`
|
|
151
|
+
- Workflow: `publish.yml`
|
|
152
|
+
- Environment: `pypi` (optional but recommended)
|
|
153
|
+
3. Create a GitHub Environment named `pypi` if you scoped the publisher that way.
|
|
154
|
+
|
|
155
|
+
### Release with a version tag
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# bump version in pyproject.toml and src/vardast/__init__.py
|
|
159
|
+
git commit -am "Release v0.1.0"
|
|
160
|
+
git tag v0.1.0
|
|
161
|
+
git push origin main --tags
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Pushing a tag matching `v*` runs `.github/workflows/publish.yml`, which builds the sdist/wheel and uploads to PyPI via OIDC (Trusted Publisher). No long-lived PyPI token is required.
|
|
165
|
+
|
|
166
|
+
### Manual / token publish (fallback)
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pip install build twine
|
|
170
|
+
python -m build
|
|
171
|
+
TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-... twine upload dist/*
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Store the token as the `PYPI_API_TOKEN` repository secret if you switch the publish workflow to token auth.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT — see [LICENSE](LICENSE).
|
|
179
|
+
|
|
180
|
+
## Docs
|
|
181
|
+
|
|
182
|
+
- Public API: https://vardast.chat/docs/public-api
|
|
183
|
+
- Product (merchant catalog) API is separate and **not** covered by this SDK.
|
vardast-0.1.0/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Vardast Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python client for the [Vardast Public API](https://vardast.chat/docs/public-api).
|
|
4
|
+
|
|
5
|
+
Package name on PyPI: **`vardast`**
|
|
6
|
+
GitHub: [technicalvardast/vardast-python](https://github.com/technicalvardast/vardast-python)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install vardast
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Requires Python 3.9+.
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
|
|
18
|
+
1. Create or copy a Public API key from the Vardast panel (channel settings / Public API).
|
|
19
|
+
2. Pass it to the client as `api_key`. The SDK sends it on every request as the `X-API-Key` header.
|
|
20
|
+
3. Default base URL (override only for a private gateway):
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
https://apigw.vardast.chat/uaa/public
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from vardast import Vardast
|
|
28
|
+
|
|
29
|
+
client = Vardast(
|
|
30
|
+
api_key="your-api-key",
|
|
31
|
+
# base_url="https://apigw.vardast.chat/uaa/public", # default
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Prefer a context manager so the HTTP client closes cleanly:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
with Vardast(api_key="your-api-key") as client:
|
|
39
|
+
channels = client.list_channels()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Async support is available via `AsyncVardast`.
|
|
43
|
+
|
|
44
|
+
## Quickstart
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from vardast import Vardast
|
|
48
|
+
|
|
49
|
+
with Vardast(api_key="your-api-key") as client:
|
|
50
|
+
channels = client.list_channels()
|
|
51
|
+
channel = channels[0]
|
|
52
|
+
|
|
53
|
+
result = client.process_message(
|
|
54
|
+
message="Hello",
|
|
55
|
+
channel_id=channel.id,
|
|
56
|
+
contact_id="contact-uuid",
|
|
57
|
+
)
|
|
58
|
+
print(result.response)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
See `examples/quickstart.py` and `examples/list_assistants.py`.
|
|
62
|
+
|
|
63
|
+
## Method reference
|
|
64
|
+
|
|
65
|
+
Methods map 1:1 to the documented Public API surface.
|
|
66
|
+
|
|
67
|
+
| Method | HTTP | Path |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `process_message(...)` | `POST` | `/messenger/api/chat/public/process` |
|
|
70
|
+
| `list_messages(channel_id, contact_id, page=1, size=20)` | `GET` | `/messenger/api/chat/{channel_id}/{contact_id}/` |
|
|
71
|
+
| `list_contacts(page=1, size=20, channel_ids=None, platform=None)` | `GET` | `/messenger/api/chat/contacts/` |
|
|
72
|
+
| `list_channels()` | `GET` | `/messenger/api/channel/` |
|
|
73
|
+
| `list_assistants()` | `GET` | `/messenger/api/assistants/` |
|
|
74
|
+
| `create_assistant(...)` | `POST` | `/messenger/api/assistants/` |
|
|
75
|
+
| `create_prompt(...)` | `POST` | `/messenger/api/prompts/` |
|
|
76
|
+
| `get_prompt(prompt_id)` | `GET` | `/messenger/api/prompts/{prompt_id}` |
|
|
77
|
+
| `list_channel_contacts(channel_id, id=None, page=1, page_size=20)` | `GET` | `/report/channel/{channel_id}/contacts` |
|
|
78
|
+
| `list_channel_orders(channel_id, order_id=None, page=1, page_size=20)` | `GET` | `/report/channel/{channel_id}/orders` |
|
|
79
|
+
| `get_usage_info()` | `GET` | `/payment/get-usage-info/` |
|
|
80
|
+
| `get_usage_activity(feature=..., ...)` | `GET` | `/payment/get-usage-activity/` |
|
|
81
|
+
|
|
82
|
+
`channel_ids` may be a comma-separated string or a sequence of IDs.
|
|
83
|
+
`get_usage_activity` requires `feature` in `{id, date, mode, period}` plus the matching query fields from the docs.
|
|
84
|
+
|
|
85
|
+
Responses are typed Pydantic models (`Message`, `Channel`, `Assistant`, `Paginated[...]`, and so on). Extra JSON fields from the API are preserved.
|
|
86
|
+
|
|
87
|
+
### Errors
|
|
88
|
+
|
|
89
|
+
| Exception | When |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `AuthenticationError` | HTTP 401 |
|
|
92
|
+
| `NotFoundError` | HTTP 404 |
|
|
93
|
+
| `ValidationError` | HTTP 400 / 422 |
|
|
94
|
+
| `RateLimitError` | HTTP 429 |
|
|
95
|
+
| `ServerError` | HTTP 5xx |
|
|
96
|
+
| `VardastAPIError` | Other API failures |
|
|
97
|
+
| `VardastError` | Client configuration errors |
|
|
98
|
+
|
|
99
|
+
API error bodies of the form `{"detail": "..."}` are surfaced on `exc.message` / `exc.detail`.
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
cd vardast-python
|
|
105
|
+
python -m venv .venv
|
|
106
|
+
source .venv/bin/activate
|
|
107
|
+
pip install -e ".[dev]"
|
|
108
|
+
pytest
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Publish to PyPI
|
|
112
|
+
|
|
113
|
+
### One-time Trusted Publisher setup (recommended)
|
|
114
|
+
|
|
115
|
+
1. Use the GitHub repository `technicalvardast/vardast-python`.
|
|
116
|
+
2. On [PyPI](https://pypi.org/manage/account/publishing/), add a Trusted Publisher:
|
|
117
|
+
- Owner: `technicalvardast`
|
|
118
|
+
- Repository: `vardast-python`
|
|
119
|
+
- Workflow: `publish.yml`
|
|
120
|
+
- Environment: `pypi` (optional but recommended)
|
|
121
|
+
3. Create a GitHub Environment named `pypi` if you scoped the publisher that way.
|
|
122
|
+
|
|
123
|
+
### Release with a version tag
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# bump version in pyproject.toml and src/vardast/__init__.py
|
|
127
|
+
git commit -am "Release v0.1.0"
|
|
128
|
+
git tag v0.1.0
|
|
129
|
+
git push origin main --tags
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Pushing a tag matching `v*` runs `.github/workflows/publish.yml`, which builds the sdist/wheel and uploads to PyPI via OIDC (Trusted Publisher). No long-lived PyPI token is required.
|
|
133
|
+
|
|
134
|
+
### Manual / token publish (fallback)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pip install build twine
|
|
138
|
+
python -m build
|
|
139
|
+
TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-... twine upload dist/*
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Store the token as the `PYPI_API_TOKEN` repository secret if you switch the publish workflow to token auth.
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
MIT — see [LICENSE](LICENSE).
|
|
147
|
+
|
|
148
|
+
## Docs
|
|
149
|
+
|
|
150
|
+
- Public API: https://vardast.chat/docs/public-api
|
|
151
|
+
- Product (merchant catalog) API is separate and **not** covered by this SDK.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""List assistants and usage for the authenticated account."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from vardast import Vardast
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main() -> int:
|
|
12
|
+
api_key = os.environ.get("VARDAST_API_KEY")
|
|
13
|
+
if not api_key:
|
|
14
|
+
print("Set VARDAST_API_KEY to your Public API key.", file=sys.stderr)
|
|
15
|
+
return 1
|
|
16
|
+
|
|
17
|
+
with Vardast(api_key=api_key) as client:
|
|
18
|
+
for assistant in client.list_assistants():
|
|
19
|
+
print(f"- {assistant.assistant_name} ({assistant.id}) model={assistant.model}")
|
|
20
|
+
|
|
21
|
+
usage = client.get_usage_info()
|
|
22
|
+
if usage.response:
|
|
23
|
+
print(
|
|
24
|
+
f"credits: chat={usage.response.chat_credit} "
|
|
25
|
+
f"contacts={usage.response.contact_credit} "
|
|
26
|
+
f"allowed={usage.response.is_allowed}"
|
|
27
|
+
)
|
|
28
|
+
return 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Quickstart: list channels and process a chat message.
|
|
2
|
+
|
|
3
|
+
Set ``VARDAST_API_KEY`` in your environment before running::
|
|
4
|
+
|
|
5
|
+
export VARDAST_API_KEY=your-key
|
|
6
|
+
python examples/quickstart.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from vardast import AuthenticationError, Vardast
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> int:
|
|
18
|
+
api_key = os.environ.get("VARDAST_API_KEY")
|
|
19
|
+
if not api_key:
|
|
20
|
+
print("Set VARDAST_API_KEY to your Public API key.", file=sys.stderr)
|
|
21
|
+
return 1
|
|
22
|
+
|
|
23
|
+
with Vardast(api_key=api_key) as client:
|
|
24
|
+
try:
|
|
25
|
+
channels = client.list_channels()
|
|
26
|
+
except AuthenticationError as exc:
|
|
27
|
+
print(f"Authentication failed: {exc}", file=sys.stderr)
|
|
28
|
+
return 1
|
|
29
|
+
|
|
30
|
+
if not channels:
|
|
31
|
+
print("No channels found for this account.")
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
channel = channels[0]
|
|
35
|
+
print(f"Using channel {channel.name!r} ({channel.id}) on {channel.platform}")
|
|
36
|
+
|
|
37
|
+
# Replace contact_id with a real contact from your account before sending.
|
|
38
|
+
contact_id = os.environ.get("VARDAST_CONTACT_ID")
|
|
39
|
+
if not contact_id:
|
|
40
|
+
print("Set VARDAST_CONTACT_ID to process a message against a contact.")
|
|
41
|
+
return 0
|
|
42
|
+
|
|
43
|
+
result = client.process_message(
|
|
44
|
+
message="Hello from the Vardast Python SDK",
|
|
45
|
+
channel_id=channel.id,
|
|
46
|
+
contact_id=contact_id,
|
|
47
|
+
)
|
|
48
|
+
print(f"status={result.status}")
|
|
49
|
+
if result.response:
|
|
50
|
+
print(result.response)
|
|
51
|
+
if result.error:
|
|
52
|
+
print(f"error={result.error}", file=sys.stderr)
|
|
53
|
+
return 1
|
|
54
|
+
return 0
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vardast"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the Vardast Public API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Vardast", email = "hello@vardast.chat" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["vardast", "api", "sdk", "chat", "messenger", "ai"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Typing :: Typed",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"httpx>=0.27,<1",
|
|
31
|
+
"pydantic>=2.6,<3",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/technicalvardast/vardast-python"
|
|
36
|
+
Documentation = "https://vardast.chat/docs/public-api"
|
|
37
|
+
Repository = "https://github.com/technicalvardast/vardast-python"
|
|
38
|
+
Issues = "https://github.com/technicalvardast/vardast-python/issues"
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
dev = [
|
|
42
|
+
"pytest>=8.0",
|
|
43
|
+
"pytest-asyncio>=0.23",
|
|
44
|
+
"respx>=0.21",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.wheel]
|
|
48
|
+
packages = ["src/vardast"]
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.sdist]
|
|
51
|
+
include = [
|
|
52
|
+
"/src",
|
|
53
|
+
"/tests",
|
|
54
|
+
"/examples",
|
|
55
|
+
"/README.md",
|
|
56
|
+
"/LICENSE",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
pythonpath = ["src"]
|
|
62
|
+
asyncio_mode = "auto"
|
|
63
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
64
|
+
|
|
65
|
+
[tool.ruff]
|
|
66
|
+
line-length = 100
|
|
67
|
+
target-version = "py39"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Official Python SDK for the Vardast Public API."""
|
|
2
|
+
|
|
3
|
+
from vardast.client import AsyncVardast, Vardast
|
|
4
|
+
from vardast.exceptions import (
|
|
5
|
+
AuthenticationError,
|
|
6
|
+
NotFoundError,
|
|
7
|
+
RateLimitError,
|
|
8
|
+
ServerError,
|
|
9
|
+
VardastAPIError,
|
|
10
|
+
VardastError,
|
|
11
|
+
ValidationError,
|
|
12
|
+
)
|
|
13
|
+
from vardast.models import (
|
|
14
|
+
Assistant,
|
|
15
|
+
AssistantCreate,
|
|
16
|
+
Channel,
|
|
17
|
+
ChannelContact,
|
|
18
|
+
ChannelOrder,
|
|
19
|
+
Contact,
|
|
20
|
+
Message,
|
|
21
|
+
OrderItem,
|
|
22
|
+
Paginated,
|
|
23
|
+
ProcessChatResponse,
|
|
24
|
+
Prompt,
|
|
25
|
+
PromptCreate,
|
|
26
|
+
PromptCreateResponse,
|
|
27
|
+
UsageActivity,
|
|
28
|
+
UsageActivityPeriodItem,
|
|
29
|
+
UsageInfo,
|
|
30
|
+
UsageInfoData,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
"Assistant",
|
|
35
|
+
"AssistantCreate",
|
|
36
|
+
"AsyncVardast",
|
|
37
|
+
"AuthenticationError",
|
|
38
|
+
"Channel",
|
|
39
|
+
"ChannelContact",
|
|
40
|
+
"ChannelOrder",
|
|
41
|
+
"Contact",
|
|
42
|
+
"Message",
|
|
43
|
+
"NotFoundError",
|
|
44
|
+
"OrderItem",
|
|
45
|
+
"Paginated",
|
|
46
|
+
"ProcessChatResponse",
|
|
47
|
+
"Prompt",
|
|
48
|
+
"PromptCreate",
|
|
49
|
+
"PromptCreateResponse",
|
|
50
|
+
"RateLimitError",
|
|
51
|
+
"ServerError",
|
|
52
|
+
"UsageActivity",
|
|
53
|
+
"UsageActivityPeriodItem",
|
|
54
|
+
"UsageInfo",
|
|
55
|
+
"UsageInfoData",
|
|
56
|
+
"ValidationError",
|
|
57
|
+
"Vardast",
|
|
58
|
+
"VardastAPIError",
|
|
59
|
+
"VardastError",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
__version__ = "0.1.0"
|