adaptsapi 0.1.9__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {adaptsapi-0.1.9/src/adaptsapi.egg-info → adaptsapi-0.2.0}/PKG-INFO +257 -231
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/README.md +252 -227
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/pyproject.toml +5 -4
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/setup.cfg +5 -4
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/setup.py +6 -5
- adaptsapi-0.2.0/src/adaptsapi/__init__.py +21 -0
- adaptsapi-0.2.0/src/adaptsapi/chat.py +178 -0
- adaptsapi-0.2.0/src/adaptsapi/cli.py +163 -0
- adaptsapi-0.2.0/src/adaptsapi/client.py +278 -0
- adaptsapi-0.2.0/src/adaptsapi/config.py +330 -0
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/src/adaptsapi/generate_docs.py +60 -33
- adaptsapi-0.2.0/src/adaptsapi/get_list_of_all_wikis.py +63 -0
- adaptsapi-0.2.0/src/adaptsapi/models/__init__.py +16 -0
- adaptsapi-0.2.0/src/adaptsapi/models/chat_request.py +43 -0
- adaptsapi-0.2.0/src/adaptsapi/models/metadata.py +12 -0
- adaptsapi-0.2.0/src/adaptsapi/models/prompt_request.py +23 -0
- adaptsapi-0.2.0/src/adaptsapi/models/repo_object.py +30 -0
- adaptsapi-0.2.0/src/adaptsapi/models/wiki_object.py +13 -0
- adaptsapi-0.2.0/src/adaptsapi/prompt.py +146 -0
- adaptsapi-0.2.0/src/adaptsapi/release_notes.py +42 -0
- {adaptsapi-0.1.9 → adaptsapi-0.2.0/src/adaptsapi.egg-info}/PKG-INFO +257 -231
- adaptsapi-0.2.0/src/adaptsapi.egg-info/SOURCES.txt +33 -0
- adaptsapi-0.2.0/src/adaptsapi.egg-info/requires.txt +2 -0
- adaptsapi-0.2.0/tests/test_chat.py +226 -0
- adaptsapi-0.2.0/tests/test_cli.py +520 -0
- adaptsapi-0.2.0/tests/test_client.py +150 -0
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/tests/test_config.py +251 -4
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/tests/test_generate_docs.py +28 -13
- adaptsapi-0.2.0/tests/test_get_list_of_all_wikis.py +75 -0
- adaptsapi-0.2.0/tests/test_release_notes.py +89 -0
- adaptsapi-0.1.9/src/adaptsapi/__init__.py +0 -0
- adaptsapi-0.1.9/src/adaptsapi/cli.py +0 -45
- adaptsapi-0.1.9/src/adaptsapi/config.py +0 -63
- adaptsapi-0.1.9/src/adaptsapi.egg-info/SOURCES.txt +0 -18
- adaptsapi-0.1.9/src/adaptsapi.egg-info/requires.txt +0 -1
- adaptsapi-0.1.9/tests/test_cli.py +0 -246
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/LICENSE +0 -0
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/src/adaptsapi.egg-info/dependency_links.txt +0 -0
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/src/adaptsapi.egg-info/entry_points.txt +0 -0
- {adaptsapi-0.1.9 → adaptsapi-0.2.0}/src/adaptsapi.egg-info/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: adaptsapi
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
5
|
-
Home-page: https://github.com/
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python client library and CLI for the Adapts API — chat with your codebase wikis, generate docs, and more.
|
|
5
|
+
Home-page: https://github.com/AdaptsAI/adapts_api_client
|
|
6
6
|
Author: adapts
|
|
7
7
|
Author-email: "VerifyAI Inc." <dev@adapts.ai>
|
|
8
8
|
License-Expression: LicenseRef-Proprietary
|
|
@@ -11,10 +11,11 @@ Project-URL: Source, https://github.com/AdaptsAI/adapts_api_client
|
|
|
11
11
|
Keywords: adapts,api,cli,sns
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: pydantic[email]>=2.4
|
|
18
19
|
Dynamic: author
|
|
19
20
|
Dynamic: home-page
|
|
20
21
|
Dynamic: license-file
|
|
@@ -22,23 +23,22 @@ Dynamic: requires-python
|
|
|
22
23
|
|
|
23
24
|
# AdaptsAPI Client
|
|
24
25
|
|
|
25
|
-
A Python client library and CLI for the Adapts API
|
|
26
|
+
A Python client library and CLI for the Adapts API: **chat with your codebase wikis**, **generate wiki docs**, and **generate release notes**.
|
|
26
27
|
|
|
27
28
|
[](https://badge.fury.io/py/adaptsapi)
|
|
28
|
-
[](https://www.python.org/downloads/)
|
|
29
30
|
[](LICENSE)
|
|
30
|
-
[](https://github.com/
|
|
31
|
+
[](https://github.com/AdaptsAI/adapts_api_client)
|
|
31
32
|
|
|
32
33
|
## Features
|
|
33
34
|
|
|
34
|
-
- 🚀
|
|
35
|
-
-
|
|
36
|
-
- 📄 **
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- 📦 **CLI tool** for command-line usage
|
|
35
|
+
- 🚀 **`AdaptsClient`** — high-level client with `chat()`, `list_chat_enabled_wikis()`, `list_all_wikis()`, `generate_docs()`
|
|
36
|
+
- 💬 **Chat with wikis** — async start, poll for status, multi-wiki, same-thread follow-ups
|
|
37
|
+
- 📄 **Generate docs & release notes** — submit repos for wiki generation
|
|
38
|
+
- 🔑 **Token loading** via `ADAPTS_API_TOKEN`, `ADAPTS_API_KEY`, `config.json`, or interactive prompt
|
|
39
|
+
- 📦 **CLI**: `adaptsapi (--chat | --chat-status | --chat-enabled-wikis | --list-wikis | --generatedoc | --releasenotes) …`
|
|
40
|
+
- ✅ **Validation**: Pydantic models for chat and generate-docs payloads
|
|
41
|
+
- 🧪 **Test suite** with high coverage; integration demos under `tests/integ/`
|
|
42
42
|
|
|
43
43
|
## Installation
|
|
44
44
|
|
|
@@ -51,8 +51,8 @@ pip install adaptsapi
|
|
|
51
51
|
### From Source
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
git clone https://github.com/
|
|
55
|
-
cd
|
|
54
|
+
git clone https://github.com/AdaptsAI/adapts_api_client.git
|
|
55
|
+
cd adapts_api_client
|
|
56
56
|
pip install -e .
|
|
57
57
|
```
|
|
58
58
|
|
|
@@ -60,123 +60,143 @@ pip install -e .
|
|
|
60
60
|
|
|
61
61
|
### 1. Set up your API token
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
`load_token()` resolves credentials in this order:
|
|
64
64
|
|
|
65
|
-
1.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```
|
|
65
|
+
1. **`ADAPTS_API_TOKEN`** or **`ADAPTS_API_KEY`** (recommended for CI/CD)
|
|
66
|
+
2. **`token`** in `./config.json`
|
|
67
|
+
3. **Interactive prompt** (CLI saves `token` to `config.json`)
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"endpoint": "https://your-api-endpoint.com/prod/generate_wiki_docs"
|
|
75
|
-
}
|
|
76
|
-
```
|
|
69
|
+
```bash
|
|
70
|
+
export ADAPTS_API_TOKEN="your-api-token-here"
|
|
71
|
+
# or: export ADAPTS_API_KEY="your-api-token-here"
|
|
72
|
+
```
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
Optional **`config.json`** (same directory you run the CLI from) for base URL and per-operation paths:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"token": "your-api-token-here",
|
|
79
|
+
"base_url": "https://prod.api.adapts.ai",
|
|
80
|
+
"generate_wiki_docs_metadata": {
|
|
81
|
+
"path": "/generate_wiki_docs"
|
|
82
|
+
},
|
|
83
|
+
"generate_release_notes_metadata": {
|
|
84
|
+
"path": "/generate_release_notes"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
You can set a full URL per operation with `"url"` instead of `"path"`. Legacy **`endpoint`** (full generate-docs URL, or host-only base) is still supported—see [Configuration](#configuration).
|
|
83
90
|
|
|
84
|
-
|
|
91
|
+
First-time CLI without env or `token` in config:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
adaptsapi --generatedoc --data '{"test": "payload"}'
|
|
95
|
+
# Prompts for token and merges into config.json
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 2. Using the Python client
|
|
85
99
|
|
|
86
100
|
```python
|
|
87
|
-
from adaptsapi
|
|
88
|
-
|
|
89
|
-
# Create your payload
|
|
90
|
-
payload = {
|
|
91
|
-
"email_address": "user@example.com",
|
|
92
|
-
"user_name": "john_doe",
|
|
93
|
-
"repo_object": {
|
|
94
|
-
"repository_name": "my-repo",
|
|
95
|
-
"source": "github",
|
|
96
|
-
"repository_url": "https://github.com/user/my-repo",
|
|
97
|
-
"branch": "main",
|
|
98
|
-
"size": "12345",
|
|
99
|
-
"language": "python",
|
|
100
|
-
"is_private": False,
|
|
101
|
-
"git_provider_type": "github",
|
|
102
|
-
"refresh_token": "github_token_here"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
101
|
+
from adaptsapi import AdaptsClient
|
|
105
102
|
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
103
|
+
client = AdaptsClient() # uses ADAPTS_API_KEY env var
|
|
104
|
+
|
|
105
|
+
# List wikis available for chat
|
|
106
|
+
wikis = client.list_chat_enabled_wikis()
|
|
107
|
+
|
|
108
|
+
# Chat (blocks until response is ready)
|
|
109
|
+
response = client.chat("What does this repo do?", wiki_name="my-repo_main")
|
|
110
|
+
print(response["response"])
|
|
111
|
+
|
|
112
|
+
# Chat across multiple wikis
|
|
113
|
+
response = client.chat("Compare these repos.", wiki_names=["wiki_a", "wiki_b"])
|
|
114
|
+
|
|
115
|
+
# Async chat (returns immediately, poll manually)
|
|
116
|
+
started = client.chat_async("Explain the auth flow.", wiki_name="my-repo_main")
|
|
117
|
+
status = client.poll_chat_status(started["thread_id"], started["created_on"])
|
|
118
|
+
|
|
119
|
+
# List all wiki generation requests
|
|
120
|
+
all_wikis = client.list_all_wikis()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
# Generate wiki documentation
|
|
125
|
+
client.generate_docs(
|
|
126
|
+
email="you@example.com",
|
|
127
|
+
user_name="your_username",
|
|
128
|
+
repo_name="my-repo",
|
|
129
|
+
repo_url="https://github.com/user/my-repo",
|
|
130
|
+
branch="main",
|
|
131
|
+
)
|
|
120
132
|
```
|
|
121
133
|
|
|
122
134
|
### 3. Using the CLI
|
|
123
135
|
|
|
124
|
-
|
|
136
|
+
Omit **`--endpoint`** when `config.json` supplies defaults (see above).
|
|
137
|
+
|
|
138
|
+
**Generate docs (inline JSON):**
|
|
125
139
|
```bash
|
|
126
|
-
adaptsapi \
|
|
127
|
-
--endpoint "https://api.adapts.ai/
|
|
140
|
+
adaptsapi --generatedoc \
|
|
141
|
+
--endpoint "https://prod.api.adapts.ai/generate_wiki_docs" \
|
|
128
142
|
--data '{"email_address": "user@example.com", "user_name": "john_doe", "repo_object": {...}}'
|
|
129
143
|
```
|
|
130
144
|
|
|
131
|
-
**
|
|
145
|
+
**Generate docs (payload file):**
|
|
132
146
|
```bash
|
|
133
|
-
adaptsapi \
|
|
134
|
-
--endpoint "https://api.adapts.ai/
|
|
147
|
+
adaptsapi --generatedoc \
|
|
148
|
+
--endpoint "https://prod.api.adapts.ai/generate_wiki_docs" \
|
|
135
149
|
--payload-file payload.json
|
|
136
150
|
```
|
|
137
151
|
|
|
152
|
+
**Chat:**
|
|
153
|
+
```bash
|
|
154
|
+
adaptsapi --chat --data '{"user_prompt":"What does this do?","wiki_name":"my-repo_main"}'
|
|
155
|
+
adaptsapi --chat-status --data '{"thread_id":"...","created_on":"..."}'
|
|
156
|
+
adaptsapi --chat-enabled-wikis
|
|
157
|
+
adaptsapi --list-wikis
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Release notes** (same payload as wiki docs; uses config default or **`--endpoint`**):
|
|
161
|
+
```bash
|
|
162
|
+
adaptsapi --releasenotes --payload-file payload.json
|
|
163
|
+
```
|
|
164
|
+
|
|
138
165
|
## Testing
|
|
139
166
|
|
|
140
|
-
The
|
|
167
|
+
The suite includes unit tests, CLI/config tests, and optional integration demos.
|
|
141
168
|
|
|
142
|
-
### Running
|
|
169
|
+
### Running tests
|
|
143
170
|
|
|
144
|
-
#### Quick Test Run
|
|
145
171
|
```bash
|
|
146
|
-
#
|
|
147
|
-
python
|
|
172
|
+
# Full check (pytest + lint + mypy) — same as `make test`
|
|
173
|
+
python run_tests.py --type all
|
|
148
174
|
|
|
149
|
-
#
|
|
150
|
-
|
|
175
|
+
# Makefile (uses `.venv/bin/python` when present)
|
|
176
|
+
make test
|
|
177
|
+
```
|
|
151
178
|
|
|
152
|
-
|
|
179
|
+
**Pytest only:**
|
|
180
|
+
```bash
|
|
181
|
+
python -m pytest
|
|
182
|
+
python -m pytest -v
|
|
153
183
|
python -m pytest tests/test_generate_docs.py
|
|
154
|
-
|
|
155
|
-
# Run with coverage report
|
|
156
184
|
python -m pytest --cov=src/adaptsapi --cov-report=html
|
|
157
185
|
```
|
|
158
186
|
|
|
159
|
-
|
|
187
|
+
**Test runner:**
|
|
160
188
|
```bash
|
|
161
|
-
# Run unit tests only (fast, no external dependencies)
|
|
162
189
|
python run_tests.py --type unit
|
|
163
|
-
|
|
164
|
-
# Run integration tests (requires API key)
|
|
165
|
-
python run_tests.py --type integration
|
|
166
|
-
|
|
167
|
-
# Run all tests with coverage
|
|
190
|
+
python run_tests.py --type integration # needs ADAPTS_API_TOKEN / ADAPTS_API_KEY for live calls
|
|
168
191
|
python run_tests.py --type coverage
|
|
169
|
-
|
|
170
|
-
# Run with custom API key
|
|
171
192
|
python run_tests.py --type integration --api-key "your-api-key"
|
|
172
193
|
```
|
|
173
194
|
|
|
174
|
-
|
|
195
|
+
**Categories**
|
|
175
196
|
|
|
176
|
-
- **Unit
|
|
177
|
-
- **Integration
|
|
178
|
-
-
|
|
179
|
-
- **Config Tests**: Tests for configuration management
|
|
197
|
+
- **Unit**: mocked HTTP and fast paths
|
|
198
|
+
- **Integration / API**: real calls when marked `@pytest.mark.integration` or `@pytest.mark.api` and credentials are set
|
|
199
|
+
- **`tests/integ/`**: runnable demos (`test_chat_demo.py`, `test_get_list_of_all_wikis_demo.py`, `test_generate_docs_demo.py`, `test_workflow.py`)
|
|
180
200
|
|
|
181
201
|
### Test Coverage
|
|
182
202
|
|
|
@@ -188,32 +208,35 @@ The test suite covers:
|
|
|
188
208
|
- ✅ **CLI Functionality**: Command-line argument parsing and file handling
|
|
189
209
|
- ✅ **Configuration**: Token loading and config file management
|
|
190
210
|
|
|
191
|
-
###
|
|
211
|
+
### Integration demos
|
|
192
212
|
|
|
193
|
-
|
|
213
|
+
Runnable modules under `tests/integ/` (pytest or `python tests/integ/...`):
|
|
194
214
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
215
|
+
- `test_chat_demo.py` — chat validation, mocked POST, optional live call
|
|
216
|
+
- `test_get_list_of_all_wikis_demo.py` — list wikis, mocked POST, optional live call
|
|
217
|
+
- `test_generate_docs_demo.py` — validation, metadata, optional live generate-docs call
|
|
218
|
+
- `test_workflow.py` — end-to-end style walkthrough
|
|
198
219
|
|
|
199
|
-
|
|
200
|
-
- Payload validation examples
|
|
201
|
-
- Metadata population demonstration
|
|
202
|
-
- API call structure
|
|
203
|
-
- Real API testing (if API key is available)
|
|
220
|
+
Set **`ADAPTS_API_TOKEN`** or **`ADAPTS_API_KEY`** for live requests.
|
|
204
221
|
|
|
205
222
|
## Usage
|
|
206
223
|
|
|
207
224
|
### Command Line Options
|
|
208
225
|
|
|
209
226
|
```bash
|
|
210
|
-
adaptsapi [OPTIONS]
|
|
227
|
+
adaptsapi (--chat | --chat-status | --chat-enabled-wikis | --list-wikis | --generatedoc | --releasenotes) [OPTIONS]
|
|
211
228
|
```
|
|
212
229
|
|
|
213
230
|
| Option | Description | Required |
|
|
214
231
|
|--------|-------------|----------|
|
|
215
|
-
| `--
|
|
216
|
-
| `--
|
|
232
|
+
| `--chat` | POST a chat request (`user_prompt`, `wiki_name`/`wiki_names`) | One mode required |
|
|
233
|
+
| `--chat-status` | Poll chat status (`thread_id`, `created_on`) | One mode required |
|
|
234
|
+
| `--chat-enabled-wikis` | List wikis available for chat (no payload) | One mode required |
|
|
235
|
+
| `--list-wikis` | List all wiki generation requests (no payload) | One mode required |
|
|
236
|
+
| `--generatedoc` | POST a generate-docs / wiki payload | One mode required |
|
|
237
|
+
| `--releasenotes` | POST a release-notes payload | One mode required |
|
|
238
|
+
| `--endpoint URL` | Full API URL | No (defaults from `config.json`) |
|
|
239
|
+
| `--data JSON` | Inline JSON payload string | Yes (or --payload-file; not needed for --chat-enabled-wikis / --list-wikis) |
|
|
217
240
|
| `--payload-file FILE` | Path to JSON payload file | Yes (or --data) |
|
|
218
241
|
| `--timeout SECONDS` | Request timeout in seconds (default: 30) | No |
|
|
219
242
|
|
|
@@ -260,6 +283,8 @@ For documentation generation, your payload should follow this structure:
|
|
|
260
283
|
- `repo_object.commit_message`: Commit message
|
|
261
284
|
- `repo_object.commit_author`: Commit author
|
|
262
285
|
- `repo_object.directory_name`: Specific directory to process
|
|
286
|
+
- `repo_object.previous_commit_hash`: Previous commit hash (common for release notes)
|
|
287
|
+
- `repo_object.pr_number`, `pr_title`, `pr_body`, `pr_url`: Pull request context (strings)
|
|
263
288
|
|
|
264
289
|
## GitHub Actions Integration
|
|
265
290
|
|
|
@@ -284,14 +309,14 @@ jobs:
|
|
|
284
309
|
- name: Set up Python
|
|
285
310
|
uses: actions/setup-python@v5
|
|
286
311
|
with:
|
|
287
|
-
python-version: "3.
|
|
312
|
+
python-version: "3.12"
|
|
288
313
|
|
|
289
314
|
- name: Install adaptsapi
|
|
290
315
|
run: pip install adaptsapi
|
|
291
316
|
|
|
292
317
|
- name: Generate documentation
|
|
293
318
|
env:
|
|
294
|
-
|
|
319
|
+
ADAPTS_API_TOKEN: ${{ secrets.ADAPTS_API_TOKEN }}
|
|
295
320
|
run: |
|
|
296
321
|
python -c "
|
|
297
322
|
import os
|
|
@@ -314,12 +339,12 @@ jobs:
|
|
|
314
339
|
}
|
|
315
340
|
|
|
316
341
|
resp = post(
|
|
317
|
-
'https://
|
|
318
|
-
os.environ['
|
|
342
|
+
'https://prod.api.adapts.ai/generate_wiki_docs',
|
|
343
|
+
os.environ['ADAPTS_API_TOKEN'],
|
|
319
344
|
payload
|
|
320
345
|
)
|
|
321
346
|
resp.raise_for_status()
|
|
322
|
-
print('
|
|
347
|
+
print('Documentation generated successfully')
|
|
323
348
|
"
|
|
324
349
|
```
|
|
325
350
|
|
|
@@ -328,25 +353,51 @@ jobs:
|
|
|
328
353
|
1. Go to your repository on GitHub
|
|
329
354
|
2. Click **Settings** → **Secrets and variables** → **Actions**
|
|
330
355
|
3. Click **New repository secret**
|
|
331
|
-
4. Add
|
|
356
|
+
4. Add **`ADAPTS_API_TOKEN`** (recommended) or **`ADAPTS_API_KEY`** with your API token value
|
|
357
|
+
|
|
358
|
+
If the repository already stores the token under `ADAPTS_API_KEY`, map it in the workflow: `ADAPTS_API_TOKEN: ${{ secrets.ADAPTS_API_KEY }}`.
|
|
332
359
|
|
|
333
360
|
## Configuration
|
|
334
361
|
|
|
335
|
-
###
|
|
362
|
+
### `config.json`
|
|
363
|
+
|
|
364
|
+
Placed in the **current working directory**. Common keys:
|
|
365
|
+
|
|
366
|
+
| Key | Purpose |
|
|
367
|
+
|-----|---------|
|
|
368
|
+
| `token` | API key (if not using env) |
|
|
369
|
+
| `base_url` / `api_base_url` | API host; paths below are appended |
|
|
370
|
+
| `generate_wiki_docs_metadata` | `{ "url": "..." }` or `{ "path": "/generate_wiki_docs" }` |
|
|
371
|
+
| `generate_release_notes_metadata` | `{ "url": "..." }` or `{ "path": "/generate_release_notes" }` |
|
|
372
|
+
| `endpoint` | Legacy full generate-docs URL, or host-only base |
|
|
373
|
+
|
|
374
|
+
Override the host with **`ADAPTS_API_BASE_URL`**.
|
|
375
|
+
|
|
376
|
+
**Example (paths + base):**
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"token": "your-api-token-here",
|
|
381
|
+
"base_url": "https://prod.api.adapts.ai",
|
|
382
|
+
"generate_wiki_docs_metadata": { "path": "/generate_wiki_docs" }
|
|
383
|
+
}
|
|
384
|
+
```
|
|
336
385
|
|
|
337
|
-
|
|
386
|
+
**Example (legacy single endpoint):**
|
|
338
387
|
|
|
339
388
|
```json
|
|
340
389
|
{
|
|
341
390
|
"token": "your-api-token-here",
|
|
342
|
-
"endpoint": "https://
|
|
391
|
+
"endpoint": "https://prod.api.adapts.ai/generate_wiki_docs"
|
|
343
392
|
}
|
|
344
393
|
```
|
|
345
394
|
|
|
346
|
-
### Environment
|
|
395
|
+
### Environment variables
|
|
347
396
|
|
|
348
|
-
|
|
349
|
-
|
|
397
|
+
| Variable | Purpose |
|
|
398
|
+
|----------|---------|
|
|
399
|
+
| `ADAPTS_API_TOKEN` / `ADAPTS_API_KEY` | API key (`load_token()` checks both) |
|
|
400
|
+
| `ADAPTS_API_BASE_URL` | Base URL when not set in `config.json` |
|
|
350
401
|
|
|
351
402
|
## Error Handling
|
|
352
403
|
|
|
@@ -368,14 +419,14 @@ The library provides comprehensive error handling:
|
|
|
368
419
|
|
|
369
420
|
### Prerequisites
|
|
370
421
|
|
|
371
|
-
- Python 3.
|
|
422
|
+
- Python 3.12+
|
|
372
423
|
- pip
|
|
373
424
|
|
|
374
425
|
### Setup Development Environment
|
|
375
426
|
|
|
376
427
|
```bash
|
|
377
|
-
git clone https://github.com/
|
|
378
|
-
cd
|
|
428
|
+
git clone https://github.com/AdaptsAI/adapts_api_client.git
|
|
429
|
+
cd adapts_api_client
|
|
379
430
|
python -m venv .venv
|
|
380
431
|
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
381
432
|
pip install -r requirements-dev.txt
|
|
@@ -399,21 +450,16 @@ This includes:
|
|
|
399
450
|
- `black` - Code formatting
|
|
400
451
|
- `isort` - Import sorting
|
|
401
452
|
|
|
402
|
-
### Running
|
|
453
|
+
### Running tests
|
|
403
454
|
|
|
404
455
|
```bash
|
|
405
|
-
# Run all tests
|
|
406
456
|
python -m pytest
|
|
407
|
-
|
|
408
|
-
# Run with coverage
|
|
409
457
|
python -m pytest --cov=src/adaptsapi --cov-report=html
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
python -m pytest -m "not integration" # Unit tests only
|
|
413
|
-
python -m pytest -m "integration" # Integration tests only
|
|
414
|
-
|
|
415
|
-
# Run the test runner
|
|
458
|
+
python -m pytest -m "not integration"
|
|
459
|
+
python -m pytest -m "integration"
|
|
416
460
|
python run_tests.py --type all
|
|
461
|
+
make test # same as run_tests.py --type all
|
|
462
|
+
make build # test then python -m build
|
|
417
463
|
```
|
|
418
464
|
|
|
419
465
|
### Code Quality
|
|
@@ -452,15 +498,16 @@ The project uses `pyproject.toml` for build configuration. Key settings:
|
|
|
452
498
|
```toml
|
|
453
499
|
[project]
|
|
454
500
|
name = "adaptsapi"
|
|
455
|
-
version = "0.
|
|
456
|
-
description = "
|
|
501
|
+
version = "0.2.0"
|
|
502
|
+
description = "Python client library and CLI for the Adapts API"
|
|
457
503
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
458
|
-
requires-python = ">=3.
|
|
504
|
+
requires-python = ">=3.12"
|
|
459
505
|
authors = [
|
|
460
506
|
{ name = "VerifyAI Inc.", email = "dev@adapts.ai" }
|
|
461
507
|
]
|
|
462
508
|
dependencies = [
|
|
463
509
|
"requests",
|
|
510
|
+
"pydantic[email]>=2.4",
|
|
464
511
|
]
|
|
465
512
|
```
|
|
466
513
|
|
|
@@ -491,7 +538,7 @@ python -m build
|
|
|
491
538
|
|
|
492
539
|
# Verify the built packages
|
|
493
540
|
ls -la dist/
|
|
494
|
-
# Should show: adaptsapi-0.
|
|
541
|
+
# Should show: adaptsapi-0.2.0.tar.gz and adaptsapi-0.2.0-py3-none-any.whl
|
|
495
542
|
```
|
|
496
543
|
|
|
497
544
|
#### 3. Test on TestPyPI (Recommended)
|
|
@@ -540,7 +587,7 @@ jobs:
|
|
|
540
587
|
- name: Set up Python
|
|
541
588
|
uses: actions/setup-python@v5
|
|
542
589
|
with:
|
|
543
|
-
python-version: "3.
|
|
590
|
+
python-version: "3.12"
|
|
544
591
|
|
|
545
592
|
- name: Install dependencies
|
|
546
593
|
run: |
|
|
@@ -582,7 +629,7 @@ Set these secrets in your GitHub repository:
|
|
|
582
629
|
|
|
583
630
|
Follow [semantic versioning](https://semver.org/):
|
|
584
631
|
|
|
585
|
-
- **MAJOR.MINOR.PATCH** (e.g., 0.
|
|
632
|
+
- **MAJOR.MINOR.PATCH** (e.g., 0.2.0)
|
|
586
633
|
- **MAJOR**: Breaking changes
|
|
587
634
|
- **MINOR**: New features, backward compatible
|
|
588
635
|
- **PATCH**: Bug fixes, backward compatible
|
|
@@ -594,14 +641,14 @@ Update version in these files:
|
|
|
594
641
|
1. **pyproject.toml**:
|
|
595
642
|
```toml
|
|
596
643
|
[project]
|
|
597
|
-
version = "0.1
|
|
644
|
+
version = "0.2.1" # Update this
|
|
598
645
|
```
|
|
599
646
|
|
|
600
647
|
2. **setup.py**:
|
|
601
648
|
```python
|
|
602
649
|
setup(
|
|
603
650
|
name="adaptsapi",
|
|
604
|
-
version="0.1
|
|
651
|
+
version="0.2.1", # Update this
|
|
605
652
|
# ...
|
|
606
653
|
)
|
|
607
654
|
```
|
|
@@ -614,7 +661,7 @@ Before publishing, ensure:
|
|
|
614
661
|
- [ ] Code is linted: `flake8 src/adaptsapi tests/`
|
|
615
662
|
- [ ] Type checking passes: `mypy src/adaptsapi/`
|
|
616
663
|
- [ ] Documentation is updated
|
|
617
|
-
- [ ] Version numbers are updated in
|
|
664
|
+
- [ ] Version numbers are updated in `pyproject.toml`, `setup.py`, `setup.cfg`, and `src/adaptsapi/__init__.py`
|
|
618
665
|
- [ ] CHANGELOG is updated
|
|
619
666
|
- [ ] Package builds successfully: `python -m build`
|
|
620
667
|
- [ ] Package installs correctly: `pip install dist/*.whl`
|
|
@@ -659,7 +706,7 @@ If you need to rollback a release:
|
|
|
659
706
|
|
|
660
707
|
2. **Yank the release** (recommended):
|
|
661
708
|
```bash
|
|
662
|
-
python -m twine delete --username __token__ --password $PYPI_API_TOKEN adaptsapi 0.
|
|
709
|
+
python -m twine delete --username __token__ --password $PYPI_API_TOKEN adaptsapi 0.2.0
|
|
663
710
|
```
|
|
664
711
|
|
|
665
712
|
3. **Publish a new patch version** with fixes
|
|
@@ -677,107 +724,81 @@ If you need to rollback a release:
|
|
|
677
724
|
After publishing, verify the package:
|
|
678
725
|
|
|
679
726
|
```bash
|
|
680
|
-
# Install from PyPI
|
|
681
727
|
pip install adaptsapi
|
|
682
728
|
|
|
683
|
-
# Test imports
|
|
684
729
|
python -c "
|
|
685
|
-
from adaptsapi
|
|
686
|
-
from adaptsapi.
|
|
687
|
-
from adaptsapi.
|
|
688
|
-
print('
|
|
730
|
+
from adaptsapi import AdaptsClient, __version__
|
|
731
|
+
from adaptsapi.chat import post_chat
|
|
732
|
+
from adaptsapi.generate_docs import post
|
|
733
|
+
print(f'adaptsapi {__version__} — all imports OK')
|
|
689
734
|
"
|
|
690
735
|
|
|
691
|
-
# Test CLI
|
|
692
736
|
adaptsapi --help
|
|
693
|
-
|
|
694
|
-
# Run tests
|
|
695
|
-
python -m pytest tests/test_generate_docs.py -v
|
|
696
737
|
```
|
|
697
738
|
|
|
698
|
-
## API
|
|
699
|
-
|
|
700
|
-
### Core Functions
|
|
701
|
-
|
|
702
|
-
#### `post(endpoint, auth_token, payload, timeout=30)`
|
|
703
|
-
|
|
704
|
-
Make a POST request to the Adapts API with automatic payload validation and metadata population.
|
|
705
|
-
|
|
706
|
-
**Parameters:**
|
|
707
|
-
- `endpoint` (str): The API endpoint URL
|
|
708
|
-
- `auth_token` (str): Authentication token
|
|
709
|
-
- `payload` (dict): JSON payload to send
|
|
710
|
-
- `timeout` (int): Request timeout in seconds (default: 30)
|
|
711
|
-
|
|
712
|
-
**Returns:**
|
|
713
|
-
- `requests.Response`: The HTTP response object
|
|
739
|
+
## API reference
|
|
714
740
|
|
|
715
|
-
|
|
716
|
-
- `PayloadValidationError`: If payload validation fails
|
|
717
|
-
- `requests.RequestException`: If the HTTP request fails
|
|
741
|
+
### `adaptsapi.generate_docs`
|
|
718
742
|
|
|
719
|
-
|
|
743
|
+
- **`post(endpoint, token, payload, timeout=30)`** — Wiki docs only (`action`: `code_to_wiki`); validate, populate metadata, POST with `x-api-key`.
|
|
744
|
+
- **`default_generate_docs_url()`** — Generate-docs URL from config (`load_default_endpoint()`), or `None`.
|
|
720
745
|
|
|
721
|
-
|
|
746
|
+
Private helpers **`_validate_payload`** and **`_populate_metadata`** are shared with release notes (schema + metadata).
|
|
722
747
|
|
|
723
|
-
|
|
724
|
-
- `payload` (dict): The payload to validate
|
|
748
|
+
### `adaptsapi.release_notes`
|
|
725
749
|
|
|
726
|
-
|
|
727
|
-
- `
|
|
750
|
+
- **`post(endpoint, token, payload, timeout=30)`** — Release notes (`action`: `generate_release_notes`); same transport as generate-docs.
|
|
751
|
+
- **`default_release_notes_url()`** — Release-notes URL from config (`load_release_notes_endpoint()`), or `None`.
|
|
728
752
|
|
|
729
|
-
|
|
753
|
+
### `adaptsapi.chat`
|
|
730
754
|
|
|
731
|
-
|
|
755
|
+
- **`post_chat(endpoint, token, payload)`** — Start a chat (returns `thread_id` + `created_on`).
|
|
756
|
+
- **`post_chat_status(endpoint, token, payload)`** — Poll for chat response.
|
|
757
|
+
- **`post_chat_enabled_wikis(endpoint, token)`** — List wikis available for chat.
|
|
732
758
|
|
|
733
|
-
|
|
734
|
-
- `payload` (dict): The payload to populate with metadata
|
|
759
|
+
### `adaptsapi.get_list_of_all_wikis`
|
|
735
760
|
|
|
736
|
-
|
|
761
|
+
- **`post(endpoint, token)`** — List all wiki generation requests.
|
|
737
762
|
|
|
738
|
-
|
|
763
|
+
### `adaptsapi.config`
|
|
739
764
|
|
|
740
|
-
|
|
765
|
+
- **`load_token()`** — `ADAPTS_API_TOKEN` / `ADAPTS_API_KEY`, then `config.json` `token`, then prompt.
|
|
766
|
+
- **`load_api_base_url()`** — `ADAPTS_API_BASE_URL`, then config, then default prod base.
|
|
767
|
+
- **`load_chat_url()`**, **`load_chat_status_url()`**, **`load_chat_enabled_wikis_url()`**, **`load_get_list_of_all_wikis_url()`** — Endpoint URLs from config or defaults.
|
|
741
768
|
|
|
742
|
-
###
|
|
769
|
+
### CLI
|
|
743
770
|
|
|
744
|
-
|
|
771
|
+
- **`adaptsapi.cli.main()`** — Entry point; requires one of **`--chat`**, **`--chat-status`**, **`--chat-enabled-wikis`**, **`--list-wikis`**, **`--generatedoc`**, or **`--releasenotes`**.
|
|
745
772
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
**Returns:**
|
|
749
|
-
- `str`: The authentication token
|
|
750
|
-
|
|
751
|
-
**Raises:**
|
|
752
|
-
- `ConfigError`: If no token can be found
|
|
753
|
-
|
|
754
|
-
#### `load_default_endpoint()`
|
|
755
|
-
|
|
756
|
-
Load default endpoint from config file.
|
|
757
|
-
|
|
758
|
-
**Returns:**
|
|
759
|
-
- `str | None`: The default endpoint URL or None
|
|
760
|
-
|
|
761
|
-
## Project Structure
|
|
773
|
+
## Project structure
|
|
762
774
|
|
|
763
775
|
```
|
|
764
|
-
|
|
776
|
+
adapts_api_client/
|
|
765
777
|
├── src/adaptsapi/
|
|
766
|
-
│ ├── __init__.py
|
|
767
|
-
│ ├──
|
|
768
|
-
│ ├──
|
|
769
|
-
│
|
|
778
|
+
│ ├── __init__.py # AdaptsClient, AdaptsAPIError, __version__
|
|
779
|
+
│ ├── client.py # High-level AdaptsClient
|
|
780
|
+
│ ├── chat.py # Chat API (post_chat, post_chat_status, post_chat_enabled_wikis)
|
|
781
|
+
│ ├── get_list_of_all_wikis.py
|
|
782
|
+
│ ├── generate_docs.py # Wiki-docs client
|
|
783
|
+
│ ├── release_notes.py # Release-notes client
|
|
784
|
+
│ ├── cli.py
|
|
785
|
+
│ ├── config.py
|
|
786
|
+
│ └── models/ # Pydantic models (ChatRequest, ChatStatusRequest, …)
|
|
770
787
|
├── tests/
|
|
771
|
-
│ ├── conftest.py
|
|
772
|
-
│ ├──
|
|
773
|
-
│ ├──
|
|
774
|
-
│
|
|
775
|
-
├──
|
|
776
|
-
├──
|
|
777
|
-
├──
|
|
778
|
-
├──
|
|
779
|
-
|
|
780
|
-
|
|
788
|
+
│ ├── conftest.py
|
|
789
|
+
│ ├── integ/ # Demos: chat, list_wikis, generate_docs, workflow
|
|
790
|
+
│ ├── test_chat.py
|
|
791
|
+
│ ├── test_client.py
|
|
792
|
+
│ ├── test_get_list_of_all_wikis.py
|
|
793
|
+
│ ├── test_generate_docs.py
|
|
794
|
+
│ ├── test_release_notes.py
|
|
795
|
+
│ ├── test_cli.py
|
|
796
|
+
│ └── test_config.py
|
|
797
|
+
├── Makefile
|
|
798
|
+
├── run_tests.py
|
|
799
|
+
├── requirements-dev.txt
|
|
800
|
+
├── pytest.ini
|
|
801
|
+
└── TESTING.md
|
|
781
802
|
```
|
|
782
803
|
|
|
783
804
|
## License
|
|
@@ -793,23 +814,28 @@ This software is licensed under the Adapts API Use-Only License v1.0. See [LICEN
|
|
|
793
814
|
## Support
|
|
794
815
|
|
|
795
816
|
- 📧 Email: dev@adapts.ai
|
|
796
|
-
- 🐛 Issues: [GitHub Issues](https://github.com/
|
|
817
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/AdaptsAI/adapts_api_client/issues)
|
|
797
818
|
- 📖 Documentation: This README and [TESTING.md](TESTING.md)
|
|
798
819
|
|
|
799
820
|
## Changelog
|
|
800
821
|
|
|
801
|
-
### v0.
|
|
802
|
-
|
|
803
|
-
-
|
|
804
|
-
-
|
|
805
|
-
-
|
|
806
|
-
-
|
|
822
|
+
### v0.2.0 (latest)
|
|
823
|
+
|
|
824
|
+
- **`AdaptsClient`** — high-level client (`chat`, `chat_async`, `poll_chat_status`, `list_chat_enabled_wikis`, `list_all_wikis`, `generate_docs`)
|
|
825
|
+
- **Chat API**: `post_chat`, `post_chat_status`, `post_chat_enabled_wikis` in `adaptsapi.chat`
|
|
826
|
+
- **`get_list_of_all_wikis`** module
|
|
827
|
+
- **CLI**: `--chat`, `--chat-status`, `--chat-enabled-wikis`, `--list-wikis`
|
|
828
|
+
- Pydantic models: `ChatRequest`, `ChatStatusRequest`
|
|
829
|
+
|
|
830
|
+
### v0.1.9
|
|
831
|
+
|
|
832
|
+
- Prompt API client, Pydantic models, `config.json` metadata blocks
|
|
833
|
+
- Release notes module, CLI `--releasenotes`
|
|
834
|
+
- `load_token()` accepts `ADAPTS_API_TOKEN` or `ADAPTS_API_KEY`
|
|
807
835
|
|
|
808
|
-
### v0.1.
|
|
809
|
-
- Patch updates
|
|
836
|
+
### v0.1.4 and earlier
|
|
810
837
|
|
|
811
|
-
|
|
812
|
-
- Initial stable release
|
|
838
|
+
- Generate-docs client, CLI, tests, and legacy `endpoint`-only configuration
|
|
813
839
|
|
|
814
840
|
---
|
|
815
841
|
|