llamagen-python 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.
- llamagen_python-0.1.0/.gitignore +10 -0
- llamagen_python-0.1.0/LICENSE +21 -0
- llamagen_python-0.1.0/PKG-INFO +199 -0
- llamagen_python-0.1.0/README.md +174 -0
- llamagen_python-0.1.0/docs/RELEASE.md +230 -0
- llamagen_python-0.1.0/examples/quickstart.py +17 -0
- llamagen_python-0.1.0/pyproject.toml +47 -0
- llamagen_python-0.1.0/src/llamagen/__init__.py +16 -0
- llamagen_python-0.1.0/src/llamagen/_client.py +44 -0
- llamagen_python-0.1.0/src/llamagen/_errors.py +20 -0
- llamagen_python-0.1.0/src/llamagen/_http.py +137 -0
- llamagen_python-0.1.0/src/llamagen/_types.py +138 -0
- llamagen_python-0.1.0/src/llamagen/_webhooks.py +138 -0
- llamagen_python-0.1.0/src/llamagen/py.typed +1 -0
- llamagen_python-0.1.0/src/llamagen/resources/__init__.py +4 -0
- llamagen_python-0.1.0/src/llamagen/resources/animations.py +70 -0
- llamagen_python-0.1.0/src/llamagen/resources/comics.py +308 -0
- llamagen_python-0.1.0/tests/test_client.py +91 -0
- llamagen_python-0.1.0/tests/test_webhooks.py +49 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 llamagen.ai
|
|
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.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llamagen-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for LlamaGen Comic API and Animation API
|
|
5
|
+
Project-URL: Homepage, https://llamagen.ai/comic-api
|
|
6
|
+
Project-URL: Documentation, https://llamagen.ai/comic-api/docs
|
|
7
|
+
Project-URL: Source, https://github.com/LlamaGenAI/llamagen-python
|
|
8
|
+
Project-URL: Issues, https://github.com/LlamaGenAI/llamagen-python/issues
|
|
9
|
+
Author-email: "llamagen.ai" <support@llamagen.ai>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,ai comic api,animation,comic,image-to-video,llamagen,sdk,text-to-video
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# llamagen-python
|
|
27
|
+
|
|
28
|
+
Official Python SDK for LlamaGen's Comic API and Animation API.
|
|
29
|
+
|
|
30
|
+
Homepage: <https://llamagen.ai/comic-api>
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install llamagen-python
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import os
|
|
42
|
+
from llamagen import LlamaGenClient
|
|
43
|
+
|
|
44
|
+
llamagen = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
45
|
+
|
|
46
|
+
created = llamagen.comic.create({
|
|
47
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
48
|
+
"style": "manga",
|
|
49
|
+
"fixPanelNum": 4,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
done = llamagen.comic.wait_for_completion(created["id"])
|
|
53
|
+
print(done["status"], done.get("comics"))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Client
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
llamagen = LlamaGenClient(
|
|
60
|
+
api_key="YOUR_API_KEY",
|
|
61
|
+
base_url="https://api.llamagen.ai/v1",
|
|
62
|
+
timeout_ms=30000,
|
|
63
|
+
max_retries=2,
|
|
64
|
+
retry_delay_ms=500,
|
|
65
|
+
)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The SDK uses Python's standard library HTTP stack and does not require runtime
|
|
69
|
+
dependencies.
|
|
70
|
+
|
|
71
|
+
## Comic API
|
|
72
|
+
|
|
73
|
+
Use `llamagen.comic` to create comics, manga, webtoons, storyboards,
|
|
74
|
+
consistent-character pages, and panel edits.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
generation = llamagen.comic.create({
|
|
78
|
+
"prompt": "The Little Prince meets the Fox in a luminous desert.",
|
|
79
|
+
"style": "storybook manga",
|
|
80
|
+
"size": "1024x1024",
|
|
81
|
+
"pagination": {"totalPages": 2, "panelsPerPage": 4},
|
|
82
|
+
"comicRoles": [
|
|
83
|
+
{
|
|
84
|
+
"name": "The Little Prince",
|
|
85
|
+
"image": "https://example.com/prince.png",
|
|
86
|
+
"clothing": "green coat and yellow scarf",
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"attachments": [{"type": "image", "url": "https://example.com/reference.png"}],
|
|
90
|
+
"language": "en",
|
|
91
|
+
"upscale": "2K",
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Comic methods:
|
|
96
|
+
|
|
97
|
+
- `llamagen.comic.create(params)` calls `POST /v1/comics/generations`.
|
|
98
|
+
- `llamagen.comic.get(id, page=None, panel=None)` calls `GET /v1/comics/generations/{id}`.
|
|
99
|
+
- `llamagen.comic.continue_write(id, params)` extends an existing comic.
|
|
100
|
+
- `llamagen.comic.update_panel(id, params)` regenerates one panel.
|
|
101
|
+
- `llamagen.comic.usage()` calls `GET /v1/comics/usage`.
|
|
102
|
+
- `llamagen.comic.upload(file, filename=None)` calls `POST /v1/comics/upload`.
|
|
103
|
+
- `llamagen.comic.wait_for_completion(id, **options)` polls until a terminal status.
|
|
104
|
+
- `llamagen.comic.create_and_wait(params, **options)` creates and polls.
|
|
105
|
+
- `llamagen.comic.create_batch(params_list, concurrency=3)` submits many jobs.
|
|
106
|
+
- `llamagen.comic.wait_for_many(ids, concurrency=3)` polls many jobs.
|
|
107
|
+
|
|
108
|
+
JavaScript-style aliases are also available: `createComic`, `getComic`,
|
|
109
|
+
`continueComic`, `regeneratePanel`, `updateComicPanel`, `waitForCompletion`,
|
|
110
|
+
`createAndWait`, and `waitForMany`.
|
|
111
|
+
|
|
112
|
+
## Animation API
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
video = llamagen.animation.create({
|
|
116
|
+
"prompt": "A heroic fox detective walks through neon rain, cinematic camera move.",
|
|
117
|
+
"videoOptions": {
|
|
118
|
+
"duration": 5,
|
|
119
|
+
"resolution": "720p",
|
|
120
|
+
"aspect_ratio": "16:9",
|
|
121
|
+
"image": "https://example.com/first-frame.png",
|
|
122
|
+
"last_frame_image": "https://example.com/last-frame.png",
|
|
123
|
+
"reference_images": ["https://example.com/character.png"],
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
finished = llamagen.animation.wait_for_completion(
|
|
128
|
+
video["id"],
|
|
129
|
+
interval_ms=5000,
|
|
130
|
+
timeout_ms=300000,
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Animation methods:
|
|
135
|
+
|
|
136
|
+
- `llamagen.animation.create(params)` calls `POST /v1/artworks/generations`.
|
|
137
|
+
- `llamagen.animation.get(id)` calls `GET /v1/artworks/generations/{id}`.
|
|
138
|
+
- `llamagen.animation.wait_for_completion(id, **options)` polls video status.
|
|
139
|
+
- `llamagen.animation.create_and_wait(params, **options)` creates and polls.
|
|
140
|
+
|
|
141
|
+
`llamagen.animations` is an alias for `llamagen.animation`.
|
|
142
|
+
|
|
143
|
+
## Webhooks
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from llamagen import construct_webhook_event
|
|
147
|
+
|
|
148
|
+
event = construct_webhook_event(
|
|
149
|
+
payload=raw_body,
|
|
150
|
+
headers=request_headers,
|
|
151
|
+
secret=os.environ["LLAMAGEN_WEBHOOK_SECRET"],
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The helper verifies `X-Llama-Webhook-Timestamp` and
|
|
156
|
+
`X-Llama-Webhook-Signature` with HMAC SHA-256 and a default 5-minute tolerance.
|
|
157
|
+
|
|
158
|
+
## Publishing
|
|
159
|
+
|
|
160
|
+
Detailed release notes are in [`docs/RELEASE.md`](docs/RELEASE.md).
|
|
161
|
+
|
|
162
|
+
1. Update `version` in `pyproject.toml`.
|
|
163
|
+
2. Run tests and packaging checks:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
python -m unittest discover -s tests
|
|
167
|
+
python -m pip install --upgrade build twine
|
|
168
|
+
python -m build
|
|
169
|
+
python -m twine check dist/*
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
3. Publish to TestPyPI first:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
python -m twine upload --repository testpypi dist/*
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
4. Install from TestPyPI in a clean environment and smoke-test:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ llamagen-python
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
5. Publish to PyPI:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
python -m twine upload dist/*
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Use a PyPI API token through `TWINE_USERNAME=__token__` and
|
|
191
|
+
`TWINE_PASSWORD=pypi-...` or configure a trusted publisher in PyPI for GitHub
|
|
192
|
+
Actions.
|
|
193
|
+
|
|
194
|
+
## Local Dev
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
python -m unittest discover -s tests
|
|
198
|
+
python -m compileall src tests
|
|
199
|
+
```
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# llamagen-python
|
|
2
|
+
|
|
3
|
+
Official Python SDK for LlamaGen's Comic API and Animation API.
|
|
4
|
+
|
|
5
|
+
Homepage: <https://llamagen.ai/comic-api>
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install llamagen-python
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import os
|
|
17
|
+
from llamagen import LlamaGenClient
|
|
18
|
+
|
|
19
|
+
llamagen = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
20
|
+
|
|
21
|
+
created = llamagen.comic.create({
|
|
22
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
23
|
+
"style": "manga",
|
|
24
|
+
"fixPanelNum": 4,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
done = llamagen.comic.wait_for_completion(created["id"])
|
|
28
|
+
print(done["status"], done.get("comics"))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Client
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
llamagen = LlamaGenClient(
|
|
35
|
+
api_key="YOUR_API_KEY",
|
|
36
|
+
base_url="https://api.llamagen.ai/v1",
|
|
37
|
+
timeout_ms=30000,
|
|
38
|
+
max_retries=2,
|
|
39
|
+
retry_delay_ms=500,
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The SDK uses Python's standard library HTTP stack and does not require runtime
|
|
44
|
+
dependencies.
|
|
45
|
+
|
|
46
|
+
## Comic API
|
|
47
|
+
|
|
48
|
+
Use `llamagen.comic` to create comics, manga, webtoons, storyboards,
|
|
49
|
+
consistent-character pages, and panel edits.
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
generation = llamagen.comic.create({
|
|
53
|
+
"prompt": "The Little Prince meets the Fox in a luminous desert.",
|
|
54
|
+
"style": "storybook manga",
|
|
55
|
+
"size": "1024x1024",
|
|
56
|
+
"pagination": {"totalPages": 2, "panelsPerPage": 4},
|
|
57
|
+
"comicRoles": [
|
|
58
|
+
{
|
|
59
|
+
"name": "The Little Prince",
|
|
60
|
+
"image": "https://example.com/prince.png",
|
|
61
|
+
"clothing": "green coat and yellow scarf",
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"attachments": [{"type": "image", "url": "https://example.com/reference.png"}],
|
|
65
|
+
"language": "en",
|
|
66
|
+
"upscale": "2K",
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Comic methods:
|
|
71
|
+
|
|
72
|
+
- `llamagen.comic.create(params)` calls `POST /v1/comics/generations`.
|
|
73
|
+
- `llamagen.comic.get(id, page=None, panel=None)` calls `GET /v1/comics/generations/{id}`.
|
|
74
|
+
- `llamagen.comic.continue_write(id, params)` extends an existing comic.
|
|
75
|
+
- `llamagen.comic.update_panel(id, params)` regenerates one panel.
|
|
76
|
+
- `llamagen.comic.usage()` calls `GET /v1/comics/usage`.
|
|
77
|
+
- `llamagen.comic.upload(file, filename=None)` calls `POST /v1/comics/upload`.
|
|
78
|
+
- `llamagen.comic.wait_for_completion(id, **options)` polls until a terminal status.
|
|
79
|
+
- `llamagen.comic.create_and_wait(params, **options)` creates and polls.
|
|
80
|
+
- `llamagen.comic.create_batch(params_list, concurrency=3)` submits many jobs.
|
|
81
|
+
- `llamagen.comic.wait_for_many(ids, concurrency=3)` polls many jobs.
|
|
82
|
+
|
|
83
|
+
JavaScript-style aliases are also available: `createComic`, `getComic`,
|
|
84
|
+
`continueComic`, `regeneratePanel`, `updateComicPanel`, `waitForCompletion`,
|
|
85
|
+
`createAndWait`, and `waitForMany`.
|
|
86
|
+
|
|
87
|
+
## Animation API
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
video = llamagen.animation.create({
|
|
91
|
+
"prompt": "A heroic fox detective walks through neon rain, cinematic camera move.",
|
|
92
|
+
"videoOptions": {
|
|
93
|
+
"duration": 5,
|
|
94
|
+
"resolution": "720p",
|
|
95
|
+
"aspect_ratio": "16:9",
|
|
96
|
+
"image": "https://example.com/first-frame.png",
|
|
97
|
+
"last_frame_image": "https://example.com/last-frame.png",
|
|
98
|
+
"reference_images": ["https://example.com/character.png"],
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
finished = llamagen.animation.wait_for_completion(
|
|
103
|
+
video["id"],
|
|
104
|
+
interval_ms=5000,
|
|
105
|
+
timeout_ms=300000,
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Animation methods:
|
|
110
|
+
|
|
111
|
+
- `llamagen.animation.create(params)` calls `POST /v1/artworks/generations`.
|
|
112
|
+
- `llamagen.animation.get(id)` calls `GET /v1/artworks/generations/{id}`.
|
|
113
|
+
- `llamagen.animation.wait_for_completion(id, **options)` polls video status.
|
|
114
|
+
- `llamagen.animation.create_and_wait(params, **options)` creates and polls.
|
|
115
|
+
|
|
116
|
+
`llamagen.animations` is an alias for `llamagen.animation`.
|
|
117
|
+
|
|
118
|
+
## Webhooks
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from llamagen import construct_webhook_event
|
|
122
|
+
|
|
123
|
+
event = construct_webhook_event(
|
|
124
|
+
payload=raw_body,
|
|
125
|
+
headers=request_headers,
|
|
126
|
+
secret=os.environ["LLAMAGEN_WEBHOOK_SECRET"],
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The helper verifies `X-Llama-Webhook-Timestamp` and
|
|
131
|
+
`X-Llama-Webhook-Signature` with HMAC SHA-256 and a default 5-minute tolerance.
|
|
132
|
+
|
|
133
|
+
## Publishing
|
|
134
|
+
|
|
135
|
+
Detailed release notes are in [`docs/RELEASE.md`](docs/RELEASE.md).
|
|
136
|
+
|
|
137
|
+
1. Update `version` in `pyproject.toml`.
|
|
138
|
+
2. Run tests and packaging checks:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
python -m unittest discover -s tests
|
|
142
|
+
python -m pip install --upgrade build twine
|
|
143
|
+
python -m build
|
|
144
|
+
python -m twine check dist/*
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
3. Publish to TestPyPI first:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
python -m twine upload --repository testpypi dist/*
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
4. Install from TestPyPI in a clean environment and smoke-test:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ llamagen-python
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
5. Publish to PyPI:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
python -m twine upload dist/*
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Use a PyPI API token through `TWINE_USERNAME=__token__` and
|
|
166
|
+
`TWINE_PASSWORD=pypi-...` or configure a trusted publisher in PyPI for GitHub
|
|
167
|
+
Actions.
|
|
168
|
+
|
|
169
|
+
## Local Dev
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
python -m unittest discover -s tests
|
|
173
|
+
python -m compileall src tests
|
|
174
|
+
```
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Release Guide
|
|
2
|
+
|
|
3
|
+
This package publishes as `llamagen-python` and imports as `llamagen`.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- A PyPI account with permission to publish `llamagen-python`.
|
|
8
|
+
- A TestPyPI account for release rehearsals.
|
|
9
|
+
- Either PyPI API tokens or trusted publishing configured in PyPI.
|
|
10
|
+
|
|
11
|
+
Install release tools:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
python -m pip install --upgrade build twine
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Preflight
|
|
18
|
+
|
|
19
|
+
Run from the `llamagen-python` directory:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
python -m unittest discover -s tests
|
|
23
|
+
python -m compileall src tests
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If macOS system Python tries to write bytecode outside the workspace, direct the
|
|
27
|
+
cache into the project:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
PYTHONPYCACHEPREFIX=.pycache python -m compileall src tests
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Version
|
|
34
|
+
|
|
35
|
+
Update both version declarations:
|
|
36
|
+
|
|
37
|
+
- `pyproject.toml` under `[project].version`
|
|
38
|
+
- `src/llamagen/__init__.py` under `__version__`
|
|
39
|
+
|
|
40
|
+
Use semantic versioning:
|
|
41
|
+
|
|
42
|
+
- Patch: compatible bug fixes.
|
|
43
|
+
- Minor: new endpoints or helpers with backward compatibility.
|
|
44
|
+
- Major: breaking API changes.
|
|
45
|
+
|
|
46
|
+
## Build
|
|
47
|
+
|
|
48
|
+
Remove old build artifacts, then build source and wheel distributions:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
rm -rf dist build *.egg-info
|
|
52
|
+
python -m build
|
|
53
|
+
python -m twine check dist/*
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## TestPyPI
|
|
57
|
+
|
|
58
|
+
Publish a rehearsal release:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
TWINE_USERNAME=__token__ TWINE_PASSWORD=testpypi-... \
|
|
62
|
+
python -m twine upload --repository testpypi dist/*
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Install and smoke-test from a clean virtual environment:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python -m venv /tmp/llamagen-python-smoke
|
|
69
|
+
. /tmp/llamagen-python-smoke/bin/activate
|
|
70
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ llamagen-python
|
|
71
|
+
python - <<'PY'
|
|
72
|
+
from llamagen import LlamaGenClient
|
|
73
|
+
|
|
74
|
+
client = LlamaGenClient(api_key="test")
|
|
75
|
+
print(type(client).__name__)
|
|
76
|
+
PY
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## PyPI
|
|
80
|
+
|
|
81
|
+
Publish the production release:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-... \
|
|
85
|
+
python -m twine upload dist/*
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
After publishing, verify metadata and installability:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
python -m venv /tmp/llamagen-python-pypi-smoke
|
|
92
|
+
. /tmp/llamagen-python-pypi-smoke/bin/activate
|
|
93
|
+
python -m pip install llamagen-python
|
|
94
|
+
python -c "import llamagen; print(llamagen.__version__)"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Recommended GitHub Actions Publishing
|
|
98
|
+
|
|
99
|
+
For long-term maintenance, configure PyPI trusted publishing instead of storing
|
|
100
|
+
API tokens in repository secrets. Create a GitHub release workflow that:
|
|
101
|
+
|
|
102
|
+
1. Checks out the repository.
|
|
103
|
+
2. Sets up Python.
|
|
104
|
+
3. Runs unittest and compileall.
|
|
105
|
+
4. Builds with `python -m build`.
|
|
106
|
+
5. Publishes with `pypa/gh-action-pypi-publish`.
|
|
107
|
+
|
|
108
|
+
# 中文发布说明
|
|
109
|
+
|
|
110
|
+
这个项目发布到 PyPI 时的包名是 `llamagen-python`,用户安装后在代码里通过
|
|
111
|
+
`import llamagen` 或 `from llamagen import LlamaGenClient` 使用。
|
|
112
|
+
|
|
113
|
+
## 准备工作
|
|
114
|
+
|
|
115
|
+
发布前需要确认这些条件已经满足:
|
|
116
|
+
|
|
117
|
+
- 拥有 `llamagen-python` 这个 PyPI 项目的发布权限。
|
|
118
|
+
- 拥有 TestPyPI 账号,用来先做一次预发布演练。
|
|
119
|
+
- 已准备 PyPI API Token,或者已经在 PyPI 上配置 Trusted Publisher。
|
|
120
|
+
|
|
121
|
+
安装本地发布工具:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
python -m pip install --upgrade build twine
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 发布前检查
|
|
128
|
+
|
|
129
|
+
进入项目目录:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
cd /Users/zuoxd/work/all/llamagen-python
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
运行测试和语法编译检查:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python -m unittest discover -s tests
|
|
139
|
+
python -m compileall src tests examples
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
如果 macOS 系统 Python 尝试把缓存写到用户 Library 目录并被权限拦截,可以把
|
|
143
|
+
pycache 指向项目内:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
PYTHONPYCACHEPREFIX=.pycache python -m compileall src tests examples
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 更新版本号
|
|
150
|
+
|
|
151
|
+
每次发布前同时更新两个位置:
|
|
152
|
+
|
|
153
|
+
- `pyproject.toml` 里的 `[project].version`
|
|
154
|
+
- `src/llamagen/__init__.py` 里的 `__version__`
|
|
155
|
+
|
|
156
|
+
版本号建议遵循语义化版本:
|
|
157
|
+
|
|
158
|
+
- Patch:兼容的 bug 修复,例如 `0.1.1`。
|
|
159
|
+
- Minor:新增兼容能力,例如新 endpoint 或新 helper,例如 `0.2.0`。
|
|
160
|
+
- Major:破坏性变更,例如 `1.0.0` 到 `2.0.0`。
|
|
161
|
+
|
|
162
|
+
## 构建发布产物
|
|
163
|
+
|
|
164
|
+
先清理旧产物,再构建源码包和 wheel:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
rm -rf dist build *.egg-info
|
|
168
|
+
python -m build
|
|
169
|
+
python -m twine check dist/*
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`twine check` 必须通过。它会检查 README、metadata 和分发包格式是否能被 PyPI
|
|
173
|
+
正常解析。
|
|
174
|
+
|
|
175
|
+
## 先发布到 TestPyPI
|
|
176
|
+
|
|
177
|
+
推荐每次正式发布前先发布到 TestPyPI:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
TWINE_USERNAME=__token__ TWINE_PASSWORD=testpypi-... \
|
|
181
|
+
python -m twine upload --repository testpypi dist/*
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
然后新建一个干净环境,从 TestPyPI 安装并做 smoke test:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
python -m venv /tmp/llamagen-python-smoke
|
|
188
|
+
. /tmp/llamagen-python-smoke/bin/activate
|
|
189
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ llamagen-python
|
|
190
|
+
python - <<'PY'
|
|
191
|
+
from llamagen import LlamaGenClient
|
|
192
|
+
|
|
193
|
+
client = LlamaGenClient(api_key="test")
|
|
194
|
+
print(type(client).__name__)
|
|
195
|
+
PY
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
能正常输出 `LlamaGenClient`,说明包名、导入名和 wheel 内容基本正确。
|
|
199
|
+
|
|
200
|
+
## 正式发布到 PyPI
|
|
201
|
+
|
|
202
|
+
确认 TestPyPI 没问题后,再上传正式 PyPI:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-... \
|
|
206
|
+
python -m twine upload dist/*
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
发布后建议再用一个干净环境从正式 PyPI 安装验证:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
python -m venv /tmp/llamagen-python-pypi-smoke
|
|
213
|
+
. /tmp/llamagen-python-pypi-smoke/bin/activate
|
|
214
|
+
python -m pip install llamagen-python
|
|
215
|
+
python -c "import llamagen; print(llamagen.__version__)"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 推荐的长期发布方式
|
|
219
|
+
|
|
220
|
+
长期维护时,推荐使用 PyPI Trusted Publisher 配合 GitHub Actions,而不是把
|
|
221
|
+
PyPI Token 存进仓库 Secrets。标准流程是:
|
|
222
|
+
|
|
223
|
+
1. 在 PyPI 项目设置中配置 GitHub Trusted Publisher。
|
|
224
|
+
2. GitHub Actions checkout 代码。
|
|
225
|
+
3. 设置 Python 环境。
|
|
226
|
+
4. 运行 `python -m unittest discover -s tests`。
|
|
227
|
+
5. 运行 `python -m build`。
|
|
228
|
+
6. 使用 `pypa/gh-action-pypi-publish` 发布。
|
|
229
|
+
|
|
230
|
+
这样可以减少 token 泄露风险,也更适合团队协作和自动化 release。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from llamagen import LlamaGenClient
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
7
|
+
|
|
8
|
+
created = client.comic.create(
|
|
9
|
+
{
|
|
10
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
11
|
+
"style": "manga",
|
|
12
|
+
"fixPanelNum": 4,
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
done = client.comic.wait_for_completion(created["id"])
|
|
17
|
+
print(done["status"])
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "llamagen-python"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for LlamaGen Comic API and Animation API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "llamagen.ai", email = "support@llamagen.ai" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"llamagen",
|
|
15
|
+
"comic",
|
|
16
|
+
"animation",
|
|
17
|
+
"ai comic api",
|
|
18
|
+
"text-to-video",
|
|
19
|
+
"image-to-video",
|
|
20
|
+
"sdk",
|
|
21
|
+
"ai"
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
34
|
+
]
|
|
35
|
+
dependencies = []
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://llamagen.ai/comic-api"
|
|
39
|
+
Documentation = "https://llamagen.ai/comic-api/docs"
|
|
40
|
+
Source = "https://github.com/LlamaGenAI/llamagen-python"
|
|
41
|
+
Issues = "https://github.com/LlamaGenAI/llamagen-python/issues"
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["src/llamagen"]
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["tests"]
|