llamagen-python 0.1.11__tar.gz → 0.1.13__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.11 → llamagen_python-0.1.13}/PKG-INFO +14 -9
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/README.md +13 -8
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/examples/Untitled.ipynb +36 -19
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/examples/quickstart.py +12 -7
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/pyproject.toml +1 -1
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/__init__.py +1 -1
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/_http.py +1 -1
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/tests/test_client.py +1 -1
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/.gitignore +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/LICENSE +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/docs/RELEASE.md +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/_client.py +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/_errors.py +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/_types.py +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/py.typed +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/resources/__init__.py +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/resources/animations.py +0 -0
- {llamagen_python-0.1.11 → llamagen_python-0.1.13}/src/llamagen/resources/comics.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: llamagen-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.13
|
|
4
4
|
Summary: Official Python SDK for LlamaGen Comic API and Animation API
|
|
5
5
|
Project-URL: Homepage, https://llamagen.ai/comic-api
|
|
6
6
|
Project-URL: Documentation, https://llamagen.ai/comic-api/docs
|
|
@@ -71,7 +71,7 @@ client = LlamaGenClient(
|
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
created = client.comic.create({
|
|
74
|
-
"prompt": "
|
|
74
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
75
75
|
"preset": "japanese_manga",
|
|
76
76
|
"fixPanelNum": 4,
|
|
77
77
|
})
|
|
@@ -118,18 +118,23 @@ from llamagen import LlamaGenClient
|
|
|
118
118
|
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
119
119
|
|
|
120
120
|
generation = client.comic.create({
|
|
121
|
-
"prompt": "
|
|
121
|
+
"prompt": "The Little Prince meets the Fox in a luminous desert.",
|
|
122
122
|
"preset": "animeStyle",
|
|
123
123
|
"size": "1024x1024",
|
|
124
124
|
"pagination": {"totalPages": 2, "panelsPerPage": 4},
|
|
125
125
|
"comicRoles": [
|
|
126
126
|
{
|
|
127
127
|
"name": "The Little Prince",
|
|
128
|
-
"image": "https://
|
|
128
|
+
"image": "https://s.llamagen.ai/public/61965b97-23fe-4405-853d-efe17b5d6f08-prince.webp",
|
|
129
129
|
"dress": "green coat and yellow scarf",
|
|
130
130
|
}
|
|
131
131
|
],
|
|
132
|
-
"attachments": [
|
|
132
|
+
"attachments": [
|
|
133
|
+
{
|
|
134
|
+
"type": "image",
|
|
135
|
+
"url": "https://s.llamagen.ai/public/7eeaad2c-fd6b-4679-90ce-884503f011b7-reference.webp",
|
|
136
|
+
}
|
|
137
|
+
],
|
|
133
138
|
"language": "en",
|
|
134
139
|
"upscale": "2K",
|
|
135
140
|
})
|
|
@@ -137,7 +142,7 @@ generation = client.comic.create({
|
|
|
137
142
|
|
|
138
143
|
Comic methods:
|
|
139
144
|
|
|
140
|
-
- `llamagen.comic.create(params)` submits a new comic generation job and returns the created job id, status, and usage metadata. Use `preset` for a known style preset id
|
|
145
|
+
- `llamagen.comic.create(params)` submits a new comic generation job and returns the created job id, status, and usage metadata. Use `preset` for a known style preset id; keep `prompt` focused on story, characters, scene, and action.
|
|
141
146
|
- `llamagen.comic.get(id, page=None, panel=None)` fetches a comic generation's status and result, or a specific page or panel.
|
|
142
147
|
- `llamagen.comic.continue_write(id, params)` extends an existing comic.
|
|
143
148
|
- `llamagen.comic.update_panel(id, params)` regenerates one panel.
|
|
@@ -158,7 +163,7 @@ from llamagen import LlamaGenClient
|
|
|
158
163
|
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
159
164
|
|
|
160
165
|
created = client.comic.create({
|
|
161
|
-
"prompt": "
|
|
166
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
162
167
|
"preset": "comicBookStyle",
|
|
163
168
|
"fixPanelNum": 4,
|
|
164
169
|
})
|
|
@@ -210,8 +215,8 @@ WAIT_TIMEOUT_MS = 30 * 60 * 1000
|
|
|
210
215
|
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
211
216
|
|
|
212
217
|
finished = client.comic.create_and_wait({
|
|
213
|
-
"prompt": "
|
|
214
|
-
"preset": "
|
|
218
|
+
"prompt": "A cozy 3-panel comic about a robot learning to bake bread.",
|
|
219
|
+
"preset": "comicBookStyle",
|
|
215
220
|
"fixPanelNum": 3,
|
|
216
221
|
}, timeout_ms=WAIT_TIMEOUT_MS)
|
|
217
222
|
print("comic.create_and_wait:", finished["id"], finished.get("status"))
|
|
@@ -46,7 +46,7 @@ client = LlamaGenClient(
|
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
created = client.comic.create({
|
|
49
|
-
"prompt": "
|
|
49
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
50
50
|
"preset": "japanese_manga",
|
|
51
51
|
"fixPanelNum": 4,
|
|
52
52
|
})
|
|
@@ -93,18 +93,23 @@ from llamagen import LlamaGenClient
|
|
|
93
93
|
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
94
94
|
|
|
95
95
|
generation = client.comic.create({
|
|
96
|
-
"prompt": "
|
|
96
|
+
"prompt": "The Little Prince meets the Fox in a luminous desert.",
|
|
97
97
|
"preset": "animeStyle",
|
|
98
98
|
"size": "1024x1024",
|
|
99
99
|
"pagination": {"totalPages": 2, "panelsPerPage": 4},
|
|
100
100
|
"comicRoles": [
|
|
101
101
|
{
|
|
102
102
|
"name": "The Little Prince",
|
|
103
|
-
"image": "https://
|
|
103
|
+
"image": "https://s.llamagen.ai/public/61965b97-23fe-4405-853d-efe17b5d6f08-prince.webp",
|
|
104
104
|
"dress": "green coat and yellow scarf",
|
|
105
105
|
}
|
|
106
106
|
],
|
|
107
|
-
"attachments": [
|
|
107
|
+
"attachments": [
|
|
108
|
+
{
|
|
109
|
+
"type": "image",
|
|
110
|
+
"url": "https://s.llamagen.ai/public/7eeaad2c-fd6b-4679-90ce-884503f011b7-reference.webp",
|
|
111
|
+
}
|
|
112
|
+
],
|
|
108
113
|
"language": "en",
|
|
109
114
|
"upscale": "2K",
|
|
110
115
|
})
|
|
@@ -112,7 +117,7 @@ generation = client.comic.create({
|
|
|
112
117
|
|
|
113
118
|
Comic methods:
|
|
114
119
|
|
|
115
|
-
- `llamagen.comic.create(params)` submits a new comic generation job and returns the created job id, status, and usage metadata. Use `preset` for a known style preset id
|
|
120
|
+
- `llamagen.comic.create(params)` submits a new comic generation job and returns the created job id, status, and usage metadata. Use `preset` for a known style preset id; keep `prompt` focused on story, characters, scene, and action.
|
|
116
121
|
- `llamagen.comic.get(id, page=None, panel=None)` fetches a comic generation's status and result, or a specific page or panel.
|
|
117
122
|
- `llamagen.comic.continue_write(id, params)` extends an existing comic.
|
|
118
123
|
- `llamagen.comic.update_panel(id, params)` regenerates one panel.
|
|
@@ -133,7 +138,7 @@ from llamagen import LlamaGenClient
|
|
|
133
138
|
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
134
139
|
|
|
135
140
|
created = client.comic.create({
|
|
136
|
-
"prompt": "
|
|
141
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
137
142
|
"preset": "comicBookStyle",
|
|
138
143
|
"fixPanelNum": 4,
|
|
139
144
|
})
|
|
@@ -185,8 +190,8 @@ WAIT_TIMEOUT_MS = 30 * 60 * 1000
|
|
|
185
190
|
client = LlamaGenClient(api_key=os.environ["LLAMAGEN_API_KEY"])
|
|
186
191
|
|
|
187
192
|
finished = client.comic.create_and_wait({
|
|
188
|
-
"prompt": "
|
|
189
|
-
"preset": "
|
|
193
|
+
"prompt": "A cozy 3-panel comic about a robot learning to bake bread.",
|
|
194
|
+
"preset": "comicBookStyle",
|
|
190
195
|
"fixPanelNum": 3,
|
|
191
196
|
}, timeout_ms=WAIT_TIMEOUT_MS)
|
|
192
197
|
print("comic.create_and_wait:", finished["id"], finished.get("status"))
|
|
@@ -42,34 +42,51 @@
|
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"cell_type": "code",
|
|
45
|
-
"execution_count":
|
|
45
|
+
"execution_count": 2,
|
|
46
46
|
"id": "f0c6df20-22f8-410e-9920-691f2d9b6557",
|
|
47
47
|
"metadata": {},
|
|
48
|
-
"outputs": [
|
|
48
|
+
"outputs": [
|
|
49
|
+
{
|
|
50
|
+
"name": "stdout",
|
|
51
|
+
"output_type": "stream",
|
|
52
|
+
"text": [
|
|
53
|
+
"comic.create: cmrfstpbx0003l604n4njl7e3 LOADING\n",
|
|
54
|
+
"comic.wait_for_completion: cmrfstpbx0003l604n4njl7e3 PROCESSED [{'page': 0, 'prompt': 'A 4-panel comic about Leo finding a glowing key in a quiet library.', 'beginPageIndex': 0, 'totalPages': 1, 'panelsPerPage': 4, 'layout': 'Layout0', 'panels': [{'assetUrl': 'https://s.llamagen.ai/clr907a8t0000jp08cgdqv78h/bfa3c3a1-9ab7-491a-9937-c1682332cea4.png', 'panel': 0, 'caption': \"It's so peaceful here... So many books I've never read.\", 'image': []}, {'assetUrl': 'https://s.llamagen.ai/clr907a8t0000jp08cgdqv78h/9074f3ac-b3b4-4dd5-b908-5a203065e5b4.png', 'panel': 1, 'caption': 'What is that light...?', 'image': []}, {'assetUrl': 'https://s.llamagen.ai/clr907a8t0000jp08cgdqv78h/a5b6902d-bb04-4519-9f95-f99926bcb260.png', 'panel': 2, 'caption': \"Is this someone's lost key? It's so bright...\", 'image': []}, {'assetUrl': 'https://s.llamagen.ai/clr907a8t0000jp08cgdqv78h/30c758d6-209f-46f4-8f0d-84ca156151c3.png', 'panel': 3, 'caption': 'What secrets do you hold?', 'image': []}], 'update': 1783740192609, 'firstUpdate': 1783740192609}]\n"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
49
58
|
"source": [
|
|
50
59
|
"import os\n",
|
|
51
60
|
"\n",
|
|
52
61
|
"from llamagen import LlamaGenClient\n",
|
|
53
62
|
"\n",
|
|
54
|
-
"
|
|
63
|
+
"WAIT_TIMEOUT_MS = 30 * 60 * 1000\n",
|
|
64
|
+
"\n",
|
|
65
|
+
"client = LlamaGenClient(\n",
|
|
66
|
+
" api_key=\"sk-5d609cd64379d048edcb04dcc109a6cfaf7c066f12138c13c8c404766ab9629d\",\n",
|
|
67
|
+
" timeout_ms=30000,\n",
|
|
68
|
+
" max_retries=5,\n",
|
|
69
|
+
" retry_delay_ms=500,\n",
|
|
70
|
+
")\n",
|
|
71
|
+
"\n",
|
|
72
|
+
"created = client.comic.create({\n",
|
|
73
|
+
" \"prompt\": \"A 4-panel comic about Leo finding a glowing key in a quiet library.\",\n",
|
|
74
|
+
" \"preset\": \"japanese_manga\",\n",
|
|
75
|
+
" \"fixPanelNum\": 4,\n",
|
|
76
|
+
"})\n",
|
|
77
|
+
"print(\"comic.create:\", created[\"id\"], created.get(\"status\"))\n",
|
|
55
78
|
"\n",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
" \"style\": \"storybook manga\",\n",
|
|
59
|
-
" \"size\": \"1024x1024\",\n",
|
|
60
|
-
" \"pagination\": {\"totalPages\": 2, \"panelsPerPage\": 4},\n",
|
|
61
|
-
" \"comicRoles\": [\n",
|
|
62
|
-
" {\n",
|
|
63
|
-
" \"name\": \"The Little Prince\",\n",
|
|
64
|
-
" \"image\": \"https://example.com/prince.png\",\n",
|
|
65
|
-
" \"clothing\": \"green coat and yellow scarf\",\n",
|
|
66
|
-
" }\n",
|
|
67
|
-
" ],\n",
|
|
68
|
-
" \"attachments\": [{\"type\": \"image\", \"url\": \"https://example.com/reference.png\"}],\n",
|
|
69
|
-
" \"language\": \"en\",\n",
|
|
70
|
-
" \"upscale\": \"2K\",\n",
|
|
71
|
-
"})"
|
|
79
|
+
"done = client.comic.wait_for_completion(created[\"id\"], timeout_ms=WAIT_TIMEOUT_MS)\n",
|
|
80
|
+
"print(\"comic.wait_for_completion:\", done[\"id\"], done.get(\"status\"), done.get(\"comics\"))"
|
|
72
81
|
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "code",
|
|
85
|
+
"execution_count": null,
|
|
86
|
+
"id": "77cc80bf-967e-4da5-bf9e-d8858914f2a4",
|
|
87
|
+
"metadata": {},
|
|
88
|
+
"outputs": [],
|
|
89
|
+
"source": []
|
|
73
90
|
}
|
|
74
91
|
],
|
|
75
92
|
"metadata": {
|
|
@@ -39,7 +39,7 @@ def make_client() -> LlamaGenClient:
|
|
|
39
39
|
def quick_start(client: LlamaGenClient) -> None:
|
|
40
40
|
created = client.comic.create(
|
|
41
41
|
{
|
|
42
|
-
"prompt": "
|
|
42
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
43
43
|
"preset": "japanese_manga",
|
|
44
44
|
"fixPanelNum": 4,
|
|
45
45
|
}
|
|
@@ -53,7 +53,7 @@ def quick_start(client: LlamaGenClient) -> None:
|
|
|
53
53
|
def create_comic(client: LlamaGenClient) -> None:
|
|
54
54
|
created = client.comic.create(
|
|
55
55
|
{
|
|
56
|
-
"prompt": "
|
|
56
|
+
"prompt": "A 4-panel comic about Leo finding a glowing key in a quiet library.",
|
|
57
57
|
"preset": "comicBookStyle",
|
|
58
58
|
"fixPanelNum": 4,
|
|
59
59
|
}
|
|
@@ -64,18 +64,23 @@ def create_comic(client: LlamaGenClient) -> None:
|
|
|
64
64
|
def create_comic_with_advanced_options(client: LlamaGenClient) -> None:
|
|
65
65
|
generation = client.comic.create(
|
|
66
66
|
{
|
|
67
|
-
"prompt": "
|
|
67
|
+
"prompt": "The Little Prince meets the Fox in a luminous desert.",
|
|
68
68
|
"preset": "animeStyle",
|
|
69
69
|
"size": "1024x1024",
|
|
70
70
|
"pagination": {"totalPages": 2, "panelsPerPage": 4},
|
|
71
71
|
"comicRoles": [
|
|
72
72
|
{
|
|
73
73
|
"name": "The Little Prince",
|
|
74
|
-
"image": "https://
|
|
74
|
+
"image": "https://s.llamagen.ai/public/61965b97-23fe-4405-853d-efe17b5d6f08-prince.webp",
|
|
75
75
|
"dress": "green coat and yellow scarf",
|
|
76
76
|
}
|
|
77
77
|
],
|
|
78
|
-
"attachments": [
|
|
78
|
+
"attachments": [
|
|
79
|
+
{
|
|
80
|
+
"type": "image",
|
|
81
|
+
"url": "https://s.llamagen.ai/public/7eeaad2c-fd6b-4679-90ce-884503f011b7-reference.webp",
|
|
82
|
+
}
|
|
83
|
+
],
|
|
79
84
|
"language": "en",
|
|
80
85
|
"upscale": "2K",
|
|
81
86
|
}
|
|
@@ -99,8 +104,8 @@ def wait_for_comic(client: LlamaGenClient, comic_id: str) -> None:
|
|
|
99
104
|
def create_and_wait_for_comic(client: LlamaGenClient) -> None:
|
|
100
105
|
finished = client.comic.create_and_wait(
|
|
101
106
|
{
|
|
102
|
-
"prompt": "
|
|
103
|
-
"preset": "
|
|
107
|
+
"prompt": "A cozy 3-panel comic about a robot learning to bake bread.",
|
|
108
|
+
"preset": "comicBookStyle",
|
|
104
109
|
"fixPanelNum": 3,
|
|
105
110
|
},
|
|
106
111
|
timeout_ms=WAIT_TIMEOUT_MS,
|
|
@@ -10,7 +10,7 @@ from typing import Any, Dict, Mapping, Optional, Protocol, Tuple
|
|
|
10
10
|
|
|
11
11
|
from ._errors import LlamaGenAPIError, LlamaGenConnectionError, LlamaGenTimeoutError
|
|
12
12
|
|
|
13
|
-
DEFAULT_USER_AGENT = "llamagen-python/0.1.
|
|
13
|
+
DEFAULT_USER_AGENT = "llamagen-python/0.1.13"
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class Transport(Protocol):
|
|
@@ -80,7 +80,7 @@ class ClientTests(unittest.TestCase):
|
|
|
80
80
|
self.assertEqual(call["url"], "https://api.llamagen.ai/v1/comics/generations")
|
|
81
81
|
self.assertEqual(call["headers"]["Authorization"], "Bearer test-key")
|
|
82
82
|
self.assertEqual(call["headers"]["Accept"], "application/json")
|
|
83
|
-
self.assertEqual(call["headers"]["User-Agent"], "llamagen-python/0.1.
|
|
83
|
+
self.assertEqual(call["headers"]["User-Agent"], "llamagen-python/0.1.13")
|
|
84
84
|
body = json.loads(call["body"].decode("utf-8"))
|
|
85
85
|
self.assertEqual(body["preset"], "neutral")
|
|
86
86
|
self.assertEqual(body["size"], "1024x1024")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|