swarmauri_tool_generateimage 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.
- swarmauri_tool_generateimage-0.1.0/LICENSE +201 -0
- swarmauri_tool_generateimage-0.1.0/NOTICE +4 -0
- swarmauri_tool_generateimage-0.1.0/PKG-INFO +362 -0
- swarmauri_tool_generateimage-0.1.0/README.md +337 -0
- swarmauri_tool_generateimage-0.1.0/pyproject.toml +95 -0
- swarmauri_tool_generateimage-0.1.0/swarmauri_tool_generateimage/GenerateImageTool.py +203 -0
- swarmauri_tool_generateimage-0.1.0/swarmauri_tool_generateimage/__init__.py +5 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2025] [Jacob Stewart @ Swarmauri]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_tool_generateimage
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate and store images from an injected SDK image model.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: swarmauri,tools,injected image model,bounded image decoding,scoped artifact storage
|
|
9
|
+
Author: Jacob Stewart
|
|
10
|
+
Author-email: jacob@swarmauri.com
|
|
11
|
+
Requires-Python: >=3.10,<3.15
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Requires-Dist: httpx (>=0.27,<0.29)
|
|
19
|
+
Requires-Dist: pillow (>=11)
|
|
20
|
+
Requires-Dist: swarmauri_base (>=0.11.0,<0.12)
|
|
21
|
+
Requires-Dist: swarmauri_core (>=0.11.1,<0.12)
|
|
22
|
+
Project-URL: Repository, https://github.com/swarmauri/swarmauri-sdk
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# swarmauri_tool_generateimage
|
|
26
|
+
|
|
27
|
+
<!-- readme-standards:begin branding -->
|
|
28
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
29
|
+
<p align="center"><strong>swarmauri_tool_generateimage</strong></p>
|
|
30
|
+
<p align="center">Generate and store images from an injected SDK image model.</p>
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://pypi.org/project/swarmauri_tool_generateimage/"><img alt="pypi: swarmauri_tool_generateimage unpublished" src="https://img.shields.io/static/v1?label=pypi&message=swarmauri_tool_generateimage%20unpublished&labelColor=292421&color=805500"></a>
|
|
33
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/pyproject.toml"><img alt="Source version: 0.1.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.1.0&labelColor=292421&color=994525"></a>
|
|
34
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=292421&color=994525"></a>
|
|
35
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=292421&color=994525"></a>
|
|
36
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=292421&color=24654A"></a>
|
|
37
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=292421&color=994525"></a>
|
|
38
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=292421&color=994525"></a>
|
|
39
|
+
</p>
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="https://pypi.org/project/swarmauri_tool_generateimage/"><img alt="pypi downloads: swarmauri_tool_generateimage: unpublished" src="https://img.shields.io/static/v1?label=pypi%20downloads&message=swarmauri_tool_generateimage%3A%20unpublished&labelColor=292421&color=805500"></a>
|
|
42
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md"><img alt="README hits: swarmauri_tool_generateimage" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_tool_generateimage/README.md.svg?label=README%20hits&labelColor=292421&color=08704E"></a>
|
|
43
|
+
</p>
|
|
44
|
+
<p align="center">
|
|
45
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=292421&color=67437E"></a>
|
|
46
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=292421&color=67437E"></a>
|
|
47
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=292421&color=805500"></a>
|
|
48
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=292421&color=67437E"></a>
|
|
49
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=292421&color=67437E"></a>
|
|
50
|
+
</p>
|
|
51
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
52
|
+
<!-- readme-standards:end branding -->
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Overview
|
|
57
|
+
|
|
58
|
+
### Summary
|
|
59
|
+
|
|
60
|
+
Generate and store images from an injected SDK image model.
|
|
61
|
+
|
|
62
|
+
### Why This Package
|
|
63
|
+
|
|
64
|
+
This package provides injected image model, bounded image decoding, scoped artifact storage for applications using the Swarmauri SDK.
|
|
65
|
+
|
|
66
|
+
### When to Use
|
|
67
|
+
|
|
68
|
+
Use this component when an application needs the image workflow described in the usage examples.
|
|
69
|
+
|
|
70
|
+
### Features
|
|
71
|
+
|
|
72
|
+
- Injected image model.
|
|
73
|
+
- Bounded image decoding.
|
|
74
|
+
- Scoped artifact storage.
|
|
75
|
+
|
|
76
|
+
### Non-Goals
|
|
77
|
+
|
|
78
|
+
Provider accounts, storage credentials, and signing identities are configured by the application.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Getting Started
|
|
83
|
+
|
|
84
|
+
### Prerequisites
|
|
85
|
+
|
|
86
|
+
The package supports Python 3.10 through 3.14. Install any application-specific provider or adapter used in your workflow.
|
|
87
|
+
|
|
88
|
+
### Installation
|
|
89
|
+
|
|
90
|
+
#### Install with uv
|
|
91
|
+
|
|
92
|
+
<!-- readme-standards:begin installation.uv -->
|
|
93
|
+
`swarmauri_tool_generateimage` is not declared published. From the source checkout:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uv pip install .
|
|
97
|
+
```
|
|
98
|
+
<!-- readme-standards:end installation.uv -->
|
|
99
|
+
|
|
100
|
+
From a Swarmauri SDK checkout, run `uv sync --directory pkgs --package swarmauri_tool_generateimage`.
|
|
101
|
+
|
|
102
|
+
#### Install with pip
|
|
103
|
+
|
|
104
|
+
<!-- readme-standards:begin installation.pip -->
|
|
105
|
+
`swarmauri_tool_generateimage` is not declared published. From the source checkout:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python -m pip install .
|
|
109
|
+
```
|
|
110
|
+
<!-- readme-standards:end installation.pip -->
|
|
111
|
+
|
|
112
|
+
From the wheelhouse containing the SDK dependency builds, run `python -m pip install --find-links dist swarmauri_tool_generateimage`.
|
|
113
|
+
|
|
114
|
+
#### Install with Poetry
|
|
115
|
+
|
|
116
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
117
|
+
`swarmauri_tool_generateimage` is not declared published. From a separate Poetry project, replace the path with your checkout:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
poetry add /path/to/swarmauri_tool_generateimage
|
|
121
|
+
```
|
|
122
|
+
<!-- readme-standards:end installation.poetry -->
|
|
123
|
+
|
|
124
|
+
### Quick Start
|
|
125
|
+
|
|
126
|
+
#### Example
|
|
127
|
+
|
|
128
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
129
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/docs/readme/quick_start.py).
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import os
|
|
133
|
+
|
|
134
|
+
from swarmauri_standard.image_gens.DeepInfraImgGenModel import (
|
|
135
|
+
DeepInfraImgGenModel,
|
|
136
|
+
)
|
|
137
|
+
from swarmauri_storage_file import FileStorageAdapter
|
|
138
|
+
from swarmauri_tool_generateimage import GenerateImageTool
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def main():
|
|
142
|
+
model = DeepInfraImgGenModel(api_key=os.environ["DEEPINFRA_API_KEY"])
|
|
143
|
+
tool = GenerateImageTool(
|
|
144
|
+
model=model,
|
|
145
|
+
storage=FileStorageAdapter("images"),
|
|
146
|
+
scope="local-demo-session",
|
|
147
|
+
output="base64",
|
|
148
|
+
)
|
|
149
|
+
print(tool("A blue ceramic mug on a white table"))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == "__main__":
|
|
153
|
+
main()
|
|
154
|
+
```
|
|
155
|
+
<!-- readme-standards:end example.quick-start -->
|
|
156
|
+
|
|
157
|
+
#### Expected Result
|
|
158
|
+
|
|
159
|
+
The example shows the package’s configuration and workflow entry point.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Usage
|
|
164
|
+
|
|
165
|
+
### Common Workflows
|
|
166
|
+
|
|
167
|
+
s’s OpenAIImgGenModel integration. Install the file storage and standard kernel packages for that example, and set OPENAI_API_KEY, OPENAI_IMAGE_MODEL, and IMAGE_OUTPUT_HOST to trusted values for your account. The example is intended for a Python version supported by the standard kernel. Use an injected IGenImage adapter for another provider.
|
|
168
|
+
|
|
169
|
+
<!-- readme-standards:begin example.usage -->
|
|
170
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/docs/readme/usage.py).
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from pathlib import Path
|
|
174
|
+
|
|
175
|
+
from swarmauri_core.image_gens.types import image_artifact_key
|
|
176
|
+
from swarmauri_tool_generateimage import GenerateImageTool
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def export_pngs(
|
|
180
|
+
tool: GenerateImageTool, prompt: str, destination: Path
|
|
181
|
+
) -> list[Path]:
|
|
182
|
+
destination.mkdir(parents=True, exist_ok=True)
|
|
183
|
+
paths = []
|
|
184
|
+
for artifact in tool(prompt)["artifacts"]:
|
|
185
|
+
if artifact["media_type"] != "image/png":
|
|
186
|
+
continue
|
|
187
|
+
artifact_id = artifact["artifact_id"]
|
|
188
|
+
key = image_artifact_key(tool.scope, artifact_id)
|
|
189
|
+
path = destination / f"{artifact_id}.png"
|
|
190
|
+
path.write_bytes(tool.storage.get_blob(f"{key}/image"))
|
|
191
|
+
paths.append(path)
|
|
192
|
+
return paths
|
|
193
|
+
```
|
|
194
|
+
<!-- readme-standards:end example.usage -->
|
|
195
|
+
|
|
196
|
+
**Expected output.** Given one generated PNG and `Path("exports")`, `export_pngs` returns a list containing the path below and writes the original PNG bytes there. The filename uses the generated artifact ID.
|
|
197
|
+
|
|
198
|
+
```text
|
|
199
|
+
exports/1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d.5e6f70815e6f70815e6f70815e6f7081.png
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Configuration
|
|
203
|
+
|
|
204
|
+
Use the public constructor or loader shown above. The caller supplies application-specific collaborators when constructing a component.
|
|
205
|
+
|
|
206
|
+
### Error Handling
|
|
207
|
+
|
|
208
|
+
Check the structured tool or agent outcome before using image references or reporting that signing succeeded.
|
|
209
|
+
|
|
210
|
+
### Best Practices
|
|
211
|
+
|
|
212
|
+
Use a distinct storage scope per authorized session and retrieve images through the toolkit after publication.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Package Boundary
|
|
217
|
+
|
|
218
|
+
### What It Owns
|
|
219
|
+
|
|
220
|
+
Generate and store images from an injected SDK image model.
|
|
221
|
+
|
|
222
|
+
### Public API and Import Surfaces
|
|
223
|
+
|
|
224
|
+
Import `GenerateImageTool` from `swarmauri_tool_generateimage`.
|
|
225
|
+
|
|
226
|
+
### Entry Points
|
|
227
|
+
|
|
228
|
+
<!-- readme-standards:begin entry-points -->
|
|
229
|
+
- `swarmauri.tools` → `GenerateImageTool` → `swarmauri_tool_generateimage:GenerateImageTool`
|
|
230
|
+
<!-- readme-standards:end entry-points -->
|
|
231
|
+
|
|
232
|
+
### Injected Dependencies
|
|
233
|
+
|
|
234
|
+
Inject the collaborators required by your application through the public constructor.
|
|
235
|
+
|
|
236
|
+
### Protocol Consumers
|
|
237
|
+
|
|
238
|
+
Swarmauri applications can use this component through the corresponding SDK resource family.
|
|
239
|
+
|
|
240
|
+
### Extensions
|
|
241
|
+
|
|
242
|
+
Supply compatible SDK components through the inputs shown in the examples.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Operations and Readiness
|
|
247
|
+
|
|
248
|
+
### Operational Requirements
|
|
249
|
+
|
|
250
|
+
Set up the application collaborators listed above before running the workflow. Use a test provider and isolated scope for local verification.
|
|
251
|
+
|
|
252
|
+
### Health and Observability
|
|
253
|
+
|
|
254
|
+
Check tool outcomes, provider health, and storage availability in the application.
|
|
255
|
+
|
|
256
|
+
### Security and Resource Limits
|
|
257
|
+
|
|
258
|
+
Set provider and storage limits at the application boundary. Keep signing keys in the configured key provider.
|
|
259
|
+
|
|
260
|
+
### Compatibility
|
|
261
|
+
|
|
262
|
+
Python 3.10 through 3.14. Check the Python support of any provider adapter installed alongside this package.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Verification
|
|
267
|
+
|
|
268
|
+
### Tests
|
|
269
|
+
|
|
270
|
+
Run the package’s pytest suite from the SDK workspace.
|
|
271
|
+
|
|
272
|
+
### Certification Status
|
|
273
|
+
|
|
274
|
+
The package is in planning status. Its tests are available in the repository.
|
|
275
|
+
|
|
276
|
+
### Evidence
|
|
277
|
+
|
|
278
|
+
The package tests and maintained example sources are available alongside its manifest.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## FAQ
|
|
283
|
+
|
|
284
|
+
### Why
|
|
285
|
+
|
|
286
|
+
Generate and store images from an injected SDK image model.
|
|
287
|
+
|
|
288
|
+
### How
|
|
289
|
+
|
|
290
|
+
Use the installation instructions and the workflow examples in this guide.
|
|
291
|
+
|
|
292
|
+
### When
|
|
293
|
+
|
|
294
|
+
Use it when your image workflow needs injected image model, bounded image decoding, scoped artifact storage.
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Documentation and Related Packages
|
|
299
|
+
|
|
300
|
+
### More Documentation
|
|
301
|
+
|
|
302
|
+
See the maintained example sources under `docs/readme`.
|
|
303
|
+
|
|
304
|
+
### Related Packages
|
|
305
|
+
|
|
306
|
+
See the SDK package index for the image tools, toolkit, agents, and packaged skills.
|
|
307
|
+
|
|
308
|
+
### Project Links
|
|
309
|
+
|
|
310
|
+
<!-- readme-standards:begin project-links -->
|
|
311
|
+
- [Repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
312
|
+
- [pypi: swarmauri_tool_generateimage](https://pypi.org/project/swarmauri_tool_generateimage/)
|
|
313
|
+
<!-- readme-standards:end project-links -->
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Contributing
|
|
318
|
+
|
|
319
|
+
### How to Contribute
|
|
320
|
+
|
|
321
|
+
Follow the SDK contribution guide and keep workflow examples in sync with the public API.
|
|
322
|
+
|
|
323
|
+
### Development Setup
|
|
324
|
+
|
|
325
|
+
Use the SDK uv workspace and run the package’s lint and test commands.
|
|
326
|
+
|
|
327
|
+
### Notes for Maintainers
|
|
328
|
+
|
|
329
|
+
Keep the package import path and registered component name aligned with the manifest.
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## Governance
|
|
334
|
+
|
|
335
|
+
### Ownership and Decision Making
|
|
336
|
+
|
|
337
|
+
The Swarmauri SDK maintainers review changes to this package.
|
|
338
|
+
|
|
339
|
+
### Standards and Policies
|
|
340
|
+
|
|
341
|
+
Follow the SDK contribution and package README policies.
|
|
342
|
+
|
|
343
|
+
### Lifecycle and Migration
|
|
344
|
+
|
|
345
|
+
This is a new package in planning status.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## License and Attribution
|
|
350
|
+
|
|
351
|
+
### License
|
|
352
|
+
|
|
353
|
+
<!-- readme-standards:begin license -->
|
|
354
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/LICENSE).
|
|
355
|
+
<!-- readme-standards:end license -->
|
|
356
|
+
|
|
357
|
+
### Notices
|
|
358
|
+
|
|
359
|
+
<!-- readme-standards:begin notices -->
|
|
360
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/NOTICE) for attribution.
|
|
361
|
+
<!-- readme-standards:end notices -->
|
|
362
|
+
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# swarmauri_tool_generateimage
|
|
2
|
+
|
|
3
|
+
<!-- readme-standards:begin branding -->
|
|
4
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
5
|
+
<p align="center"><strong>swarmauri_tool_generateimage</strong></p>
|
|
6
|
+
<p align="center">Generate and store images from an injected SDK image model.</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_tool_generateimage/"><img alt="pypi: swarmauri_tool_generateimage unpublished" src="https://img.shields.io/static/v1?label=pypi&message=swarmauri_tool_generateimage%20unpublished&labelColor=292421&color=805500"></a>
|
|
9
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/pyproject.toml"><img alt="Source version: 0.1.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.1.0&labelColor=292421&color=994525"></a>
|
|
10
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=292421&color=994525"></a>
|
|
11
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=292421&color=994525"></a>
|
|
12
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=292421&color=24654A"></a>
|
|
13
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=292421&color=994525"></a>
|
|
14
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=292421&color=994525"></a>
|
|
15
|
+
</p>
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://pypi.org/project/swarmauri_tool_generateimage/"><img alt="pypi downloads: swarmauri_tool_generateimage: unpublished" src="https://img.shields.io/static/v1?label=pypi%20downloads&message=swarmauri_tool_generateimage%3A%20unpublished&labelColor=292421&color=805500"></a>
|
|
18
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md"><img alt="README hits: swarmauri_tool_generateimage" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_tool_generateimage/README.md.svg?label=README%20hits&labelColor=292421&color=08704E"></a>
|
|
19
|
+
</p>
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=292421&color=67437E"></a>
|
|
22
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=292421&color=67437E"></a>
|
|
23
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=292421&color=805500"></a>
|
|
24
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=292421&color=67437E"></a>
|
|
25
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=292421&color=67437E"></a>
|
|
26
|
+
</p>
|
|
27
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
28
|
+
<!-- readme-standards:end branding -->
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
### Summary
|
|
35
|
+
|
|
36
|
+
Generate and store images from an injected SDK image model.
|
|
37
|
+
|
|
38
|
+
### Why This Package
|
|
39
|
+
|
|
40
|
+
This package provides injected image model, bounded image decoding, scoped artifact storage for applications using the Swarmauri SDK.
|
|
41
|
+
|
|
42
|
+
### When to Use
|
|
43
|
+
|
|
44
|
+
Use this component when an application needs the image workflow described in the usage examples.
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
- Injected image model.
|
|
49
|
+
- Bounded image decoding.
|
|
50
|
+
- Scoped artifact storage.
|
|
51
|
+
|
|
52
|
+
### Non-Goals
|
|
53
|
+
|
|
54
|
+
Provider accounts, storage credentials, and signing identities are configured by the application.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Getting Started
|
|
59
|
+
|
|
60
|
+
### Prerequisites
|
|
61
|
+
|
|
62
|
+
The package supports Python 3.10 through 3.14. Install any application-specific provider or adapter used in your workflow.
|
|
63
|
+
|
|
64
|
+
### Installation
|
|
65
|
+
|
|
66
|
+
#### Install with uv
|
|
67
|
+
|
|
68
|
+
<!-- readme-standards:begin installation.uv -->
|
|
69
|
+
`swarmauri_tool_generateimage` is not declared published. From the source checkout:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
uv pip install .
|
|
73
|
+
```
|
|
74
|
+
<!-- readme-standards:end installation.uv -->
|
|
75
|
+
|
|
76
|
+
From a Swarmauri SDK checkout, run `uv sync --directory pkgs --package swarmauri_tool_generateimage`.
|
|
77
|
+
|
|
78
|
+
#### Install with pip
|
|
79
|
+
|
|
80
|
+
<!-- readme-standards:begin installation.pip -->
|
|
81
|
+
`swarmauri_tool_generateimage` is not declared published. From the source checkout:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
python -m pip install .
|
|
85
|
+
```
|
|
86
|
+
<!-- readme-standards:end installation.pip -->
|
|
87
|
+
|
|
88
|
+
From the wheelhouse containing the SDK dependency builds, run `python -m pip install --find-links dist swarmauri_tool_generateimage`.
|
|
89
|
+
|
|
90
|
+
#### Install with Poetry
|
|
91
|
+
|
|
92
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
93
|
+
`swarmauri_tool_generateimage` is not declared published. From a separate Poetry project, replace the path with your checkout:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
poetry add /path/to/swarmauri_tool_generateimage
|
|
97
|
+
```
|
|
98
|
+
<!-- readme-standards:end installation.poetry -->
|
|
99
|
+
|
|
100
|
+
### Quick Start
|
|
101
|
+
|
|
102
|
+
#### Example
|
|
103
|
+
|
|
104
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
105
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/docs/readme/quick_start.py).
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import os
|
|
109
|
+
|
|
110
|
+
from swarmauri_standard.image_gens.DeepInfraImgGenModel import (
|
|
111
|
+
DeepInfraImgGenModel,
|
|
112
|
+
)
|
|
113
|
+
from swarmauri_storage_file import FileStorageAdapter
|
|
114
|
+
from swarmauri_tool_generateimage import GenerateImageTool
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def main():
|
|
118
|
+
model = DeepInfraImgGenModel(api_key=os.environ["DEEPINFRA_API_KEY"])
|
|
119
|
+
tool = GenerateImageTool(
|
|
120
|
+
model=model,
|
|
121
|
+
storage=FileStorageAdapter("images"),
|
|
122
|
+
scope="local-demo-session",
|
|
123
|
+
output="base64",
|
|
124
|
+
)
|
|
125
|
+
print(tool("A blue ceramic mug on a white table"))
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
main()
|
|
130
|
+
```
|
|
131
|
+
<!-- readme-standards:end example.quick-start -->
|
|
132
|
+
|
|
133
|
+
#### Expected Result
|
|
134
|
+
|
|
135
|
+
The example shows the package’s configuration and workflow entry point.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Usage
|
|
140
|
+
|
|
141
|
+
### Common Workflows
|
|
142
|
+
|
|
143
|
+
s’s OpenAIImgGenModel integration. Install the file storage and standard kernel packages for that example, and set OPENAI_API_KEY, OPENAI_IMAGE_MODEL, and IMAGE_OUTPUT_HOST to trusted values for your account. The example is intended for a Python version supported by the standard kernel. Use an injected IGenImage adapter for another provider.
|
|
144
|
+
|
|
145
|
+
<!-- readme-standards:begin example.usage -->
|
|
146
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/docs/readme/usage.py).
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from pathlib import Path
|
|
150
|
+
|
|
151
|
+
from swarmauri_core.image_gens.types import image_artifact_key
|
|
152
|
+
from swarmauri_tool_generateimage import GenerateImageTool
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def export_pngs(
|
|
156
|
+
tool: GenerateImageTool, prompt: str, destination: Path
|
|
157
|
+
) -> list[Path]:
|
|
158
|
+
destination.mkdir(parents=True, exist_ok=True)
|
|
159
|
+
paths = []
|
|
160
|
+
for artifact in tool(prompt)["artifacts"]:
|
|
161
|
+
if artifact["media_type"] != "image/png":
|
|
162
|
+
continue
|
|
163
|
+
artifact_id = artifact["artifact_id"]
|
|
164
|
+
key = image_artifact_key(tool.scope, artifact_id)
|
|
165
|
+
path = destination / f"{artifact_id}.png"
|
|
166
|
+
path.write_bytes(tool.storage.get_blob(f"{key}/image"))
|
|
167
|
+
paths.append(path)
|
|
168
|
+
return paths
|
|
169
|
+
```
|
|
170
|
+
<!-- readme-standards:end example.usage -->
|
|
171
|
+
|
|
172
|
+
**Expected output.** Given one generated PNG and `Path("exports")`, `export_pngs` returns a list containing the path below and writes the original PNG bytes there. The filename uses the generated artifact ID.
|
|
173
|
+
|
|
174
|
+
```text
|
|
175
|
+
exports/1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d.5e6f70815e6f70815e6f70815e6f7081.png
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Configuration
|
|
179
|
+
|
|
180
|
+
Use the public constructor or loader shown above. The caller supplies application-specific collaborators when constructing a component.
|
|
181
|
+
|
|
182
|
+
### Error Handling
|
|
183
|
+
|
|
184
|
+
Check the structured tool or agent outcome before using image references or reporting that signing succeeded.
|
|
185
|
+
|
|
186
|
+
### Best Practices
|
|
187
|
+
|
|
188
|
+
Use a distinct storage scope per authorized session and retrieve images through the toolkit after publication.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Package Boundary
|
|
193
|
+
|
|
194
|
+
### What It Owns
|
|
195
|
+
|
|
196
|
+
Generate and store images from an injected SDK image model.
|
|
197
|
+
|
|
198
|
+
### Public API and Import Surfaces
|
|
199
|
+
|
|
200
|
+
Import `GenerateImageTool` from `swarmauri_tool_generateimage`.
|
|
201
|
+
|
|
202
|
+
### Entry Points
|
|
203
|
+
|
|
204
|
+
<!-- readme-standards:begin entry-points -->
|
|
205
|
+
- `swarmauri.tools` → `GenerateImageTool` → `swarmauri_tool_generateimage:GenerateImageTool`
|
|
206
|
+
<!-- readme-standards:end entry-points -->
|
|
207
|
+
|
|
208
|
+
### Injected Dependencies
|
|
209
|
+
|
|
210
|
+
Inject the collaborators required by your application through the public constructor.
|
|
211
|
+
|
|
212
|
+
### Protocol Consumers
|
|
213
|
+
|
|
214
|
+
Swarmauri applications can use this component through the corresponding SDK resource family.
|
|
215
|
+
|
|
216
|
+
### Extensions
|
|
217
|
+
|
|
218
|
+
Supply compatible SDK components through the inputs shown in the examples.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Operations and Readiness
|
|
223
|
+
|
|
224
|
+
### Operational Requirements
|
|
225
|
+
|
|
226
|
+
Set up the application collaborators listed above before running the workflow. Use a test provider and isolated scope for local verification.
|
|
227
|
+
|
|
228
|
+
### Health and Observability
|
|
229
|
+
|
|
230
|
+
Check tool outcomes, provider health, and storage availability in the application.
|
|
231
|
+
|
|
232
|
+
### Security and Resource Limits
|
|
233
|
+
|
|
234
|
+
Set provider and storage limits at the application boundary. Keep signing keys in the configured key provider.
|
|
235
|
+
|
|
236
|
+
### Compatibility
|
|
237
|
+
|
|
238
|
+
Python 3.10 through 3.14. Check the Python support of any provider adapter installed alongside this package.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Verification
|
|
243
|
+
|
|
244
|
+
### Tests
|
|
245
|
+
|
|
246
|
+
Run the package’s pytest suite from the SDK workspace.
|
|
247
|
+
|
|
248
|
+
### Certification Status
|
|
249
|
+
|
|
250
|
+
The package is in planning status. Its tests are available in the repository.
|
|
251
|
+
|
|
252
|
+
### Evidence
|
|
253
|
+
|
|
254
|
+
The package tests and maintained example sources are available alongside its manifest.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## FAQ
|
|
259
|
+
|
|
260
|
+
### Why
|
|
261
|
+
|
|
262
|
+
Generate and store images from an injected SDK image model.
|
|
263
|
+
|
|
264
|
+
### How
|
|
265
|
+
|
|
266
|
+
Use the installation instructions and the workflow examples in this guide.
|
|
267
|
+
|
|
268
|
+
### When
|
|
269
|
+
|
|
270
|
+
Use it when your image workflow needs injected image model, bounded image decoding, scoped artifact storage.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Documentation and Related Packages
|
|
275
|
+
|
|
276
|
+
### More Documentation
|
|
277
|
+
|
|
278
|
+
See the maintained example sources under `docs/readme`.
|
|
279
|
+
|
|
280
|
+
### Related Packages
|
|
281
|
+
|
|
282
|
+
See the SDK package index for the image tools, toolkit, agents, and packaged skills.
|
|
283
|
+
|
|
284
|
+
### Project Links
|
|
285
|
+
|
|
286
|
+
<!-- readme-standards:begin project-links -->
|
|
287
|
+
- [Repository](https://github.com/swarmauri/swarmauri-sdk)
|
|
288
|
+
- [pypi: swarmauri_tool_generateimage](https://pypi.org/project/swarmauri_tool_generateimage/)
|
|
289
|
+
<!-- readme-standards:end project-links -->
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Contributing
|
|
294
|
+
|
|
295
|
+
### How to Contribute
|
|
296
|
+
|
|
297
|
+
Follow the SDK contribution guide and keep workflow examples in sync with the public API.
|
|
298
|
+
|
|
299
|
+
### Development Setup
|
|
300
|
+
|
|
301
|
+
Use the SDK uv workspace and run the package’s lint and test commands.
|
|
302
|
+
|
|
303
|
+
### Notes for Maintainers
|
|
304
|
+
|
|
305
|
+
Keep the package import path and registered component name aligned with the manifest.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Governance
|
|
310
|
+
|
|
311
|
+
### Ownership and Decision Making
|
|
312
|
+
|
|
313
|
+
The Swarmauri SDK maintainers review changes to this package.
|
|
314
|
+
|
|
315
|
+
### Standards and Policies
|
|
316
|
+
|
|
317
|
+
Follow the SDK contribution and package README policies.
|
|
318
|
+
|
|
319
|
+
### Lifecycle and Migration
|
|
320
|
+
|
|
321
|
+
This is a new package in planning status.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## License and Attribution
|
|
326
|
+
|
|
327
|
+
### License
|
|
328
|
+
|
|
329
|
+
<!-- readme-standards:begin license -->
|
|
330
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/LICENSE).
|
|
331
|
+
<!-- readme-standards:end license -->
|
|
332
|
+
|
|
333
|
+
### Notices
|
|
334
|
+
|
|
335
|
+
<!-- readme-standards:begin notices -->
|
|
336
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/NOTICE) for attribution.
|
|
337
|
+
<!-- readme-standards:end notices -->
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "swarmauri_tool_generateimage"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Generate and store images from an injected SDK image model."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
8
|
+
requires-python = ">=3.10,<3.15"
|
|
9
|
+
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
10
|
+
keywords = ["swarmauri","tools","injected image model","bounded image decoding","scoped artifact storage"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 1 - Planning",
|
|
13
|
+
"Programming Language :: Python :: 3.10",
|
|
14
|
+
"Programming Language :: Python :: 3.11",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Programming Language :: Python :: 3.13",
|
|
17
|
+
"Programming Language :: Python :: 3.14",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"swarmauri_base>=0.11.0,<0.12",
|
|
21
|
+
"swarmauri_core>=0.11.1,<0.12",
|
|
22
|
+
"httpx>=0.27,<0.29",
|
|
23
|
+
"pillow>=11",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Repository = "https://github.com/swarmauri/swarmauri-sdk"
|
|
28
|
+
|
|
29
|
+
[project.entry-points."swarmauri.tools"]
|
|
30
|
+
GenerateImageTool = "swarmauri_tool_generateimage:GenerateImageTool"
|
|
31
|
+
|
|
32
|
+
[tool.uv.sources]
|
|
33
|
+
swarmauri_base = { workspace = true }
|
|
34
|
+
swarmauri_core = { workspace = true }
|
|
35
|
+
swarmauri_storage_memory = { workspace = true }
|
|
36
|
+
swarmauri_standard = { workspace = true }
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
markers = ["unit: Unit tests", "i9n: Integration tests"]
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["poetry-core>=2.2"]
|
|
43
|
+
build-backend = "poetry.core.masonry.api"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = ["pytest>=8", "ruff>=0.9.9", "readme-standards==0.1.6; python_version >= '3.11'", "swarmauri_storage_memory", "swarmauri_standard; python_version >= '3.11'"]
|
|
47
|
+
|
|
48
|
+
[tool.readme_standards]
|
|
49
|
+
policy = "package-guide-v1"
|
|
50
|
+
readme = "README.md"
|
|
51
|
+
brand = "swarmauri"
|
|
52
|
+
brand_catalog = "../../../tools/readme/brands.toml"
|
|
53
|
+
repository = "https://github.com/swarmauri/swarmauri-sdk"
|
|
54
|
+
ref = "master"
|
|
55
|
+
package_path = "pkgs/40-standards/swarmauri_tool_generateimage"
|
|
56
|
+
layer = "standards"
|
|
57
|
+
lifecycle = "active"
|
|
58
|
+
license_file = "LICENSE"
|
|
59
|
+
notice_file = "NOTICE"
|
|
60
|
+
|
|
61
|
+
[tool.readme_standards.distributions.pypi]
|
|
62
|
+
name = "swarmauri_tool_generateimage"
|
|
63
|
+
published = false
|
|
64
|
+
|
|
65
|
+
[tool.readme_standards.examples.quick_start]
|
|
66
|
+
source = "docs/readme/quick_start.py"
|
|
67
|
+
test = "tests/unit/test_readme_sources.py"
|
|
68
|
+
language = "python"
|
|
69
|
+
expected_exit_code = 0
|
|
70
|
+
|
|
71
|
+
[tool.readme_standards.examples.usage]
|
|
72
|
+
source = "docs/readme/usage.py"
|
|
73
|
+
test = "tests/unit/test_readme_sources.py"
|
|
74
|
+
language = "python"
|
|
75
|
+
expected_exit_code = 0
|
|
76
|
+
|
|
77
|
+
[tool.readme_standards.statuses.readme]
|
|
78
|
+
label = "CI gate"
|
|
79
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
80
|
+
|
|
81
|
+
[tool.readme_standards.statuses.tests]
|
|
82
|
+
label = "example source"
|
|
83
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/tests/unit/test_readme_sources.py"
|
|
84
|
+
|
|
85
|
+
[tool.readme_standards.statuses.certification]
|
|
86
|
+
label = "not certified"
|
|
87
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_tool_generateimage/README.md#certification-status"
|
|
88
|
+
|
|
89
|
+
[tool.readme_standards.statuses.governance]
|
|
90
|
+
label = "repository policy"
|
|
91
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"
|
|
92
|
+
|
|
93
|
+
[tool.readme_standards.statuses.evidence]
|
|
94
|
+
label = "source and CI"
|
|
95
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"""Generate and store images through an injected SDK image model."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import json
|
|
5
|
+
from collections.abc import Callable, Sequence
|
|
6
|
+
from dataclasses import asdict
|
|
7
|
+
from io import BytesIO
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
from urllib.parse import urlsplit
|
|
10
|
+
from uuid import uuid4
|
|
11
|
+
|
|
12
|
+
import httpx
|
|
13
|
+
from PIL import Image
|
|
14
|
+
from pydantic import Field
|
|
15
|
+
from swarmauri_base.ComponentBase import ComponentBase
|
|
16
|
+
from swarmauri_base.tools.ParameterBase import ParameterBase
|
|
17
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
18
|
+
from swarmauri_core.image_gens.IGenImage import IGenImage
|
|
19
|
+
from swarmauri_core.image_gens.types import (
|
|
20
|
+
ImageArtifact,
|
|
21
|
+
image_artifact_key,
|
|
22
|
+
image_batch_key,
|
|
23
|
+
)
|
|
24
|
+
from swarmauri_core.storage.IStorageAdapter import IStorageAdapter
|
|
25
|
+
|
|
26
|
+
_MEDIA_TYPES = {"PNG": "image/png", "JPEG": "image/jpeg", "WEBP": "image/webp"}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@ComponentBase.register_type(ToolBase, "GenerateImageTool")
|
|
30
|
+
class GenerateImageTool(ToolBase):
|
|
31
|
+
"""Generate images in a storage scope selected by the application."""
|
|
32
|
+
|
|
33
|
+
type: Literal["GenerateImageTool"] = "GenerateImageTool"
|
|
34
|
+
name: Literal["GenerateImageTool"] = "GenerateImageTool"
|
|
35
|
+
description: str = (
|
|
36
|
+
"Generate images from a text prompt and return artifact IDs."
|
|
37
|
+
)
|
|
38
|
+
model: IGenImage = Field(exclude=True)
|
|
39
|
+
storage: IStorageAdapter = Field(exclude=True)
|
|
40
|
+
scope: str = Field(min_length=1, exclude=True)
|
|
41
|
+
on_staged: Callable[[str, list[ImageArtifact]], dict[str, Any]] | None = (
|
|
42
|
+
Field(default=None, exclude=True)
|
|
43
|
+
)
|
|
44
|
+
output: Literal["bytes", "base64", "url"] = "bytes"
|
|
45
|
+
model_options: dict[str, Any] = Field(default_factory=dict)
|
|
46
|
+
allowed_hosts: frozenset[str] = frozenset()
|
|
47
|
+
max_bytes: int = Field(default=16 * 1024 * 1024, gt=0)
|
|
48
|
+
max_pixels: int = Field(default=25_000_000, gt=0)
|
|
49
|
+
max_images: int = Field(default=8, gt=0)
|
|
50
|
+
timeout: float = Field(default=30, gt=0)
|
|
51
|
+
parameters: list[ParameterBase] = Field(
|
|
52
|
+
default_factory=lambda: [
|
|
53
|
+
ParameterBase(
|
|
54
|
+
name="prompt",
|
|
55
|
+
description="Describe the image to generate.",
|
|
56
|
+
input_type="string",
|
|
57
|
+
required=True,
|
|
58
|
+
)
|
|
59
|
+
]
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def __call__(self, prompt: str) -> dict[str, Any]:
|
|
63
|
+
"""Generate images and make the batch visible."""
|
|
64
|
+
batch_id, artifacts = self.stage(prompt)
|
|
65
|
+
if self.on_staged is not None:
|
|
66
|
+
return self.on_staged(batch_id, artifacts)
|
|
67
|
+
self.publish(batch_id)
|
|
68
|
+
return self.result(artifacts)
|
|
69
|
+
|
|
70
|
+
def stage(self, prompt: str) -> tuple[str, list[ImageArtifact]]:
|
|
71
|
+
"""Store a complete image batch privately and return its references."""
|
|
72
|
+
if not isinstance(prompt, str) or not prompt.strip():
|
|
73
|
+
raise ValueError("An image prompt is required")
|
|
74
|
+
if not self.model_options.keys().isdisjoint({"prompt"}):
|
|
75
|
+
raise ValueError("Configure the prompt through the tool call")
|
|
76
|
+
generated = self.model.generate_image(prompt, **self.model_options)
|
|
77
|
+
outputs = (
|
|
78
|
+
generated
|
|
79
|
+
if isinstance(generated, Sequence)
|
|
80
|
+
and not isinstance(generated, (str, bytes))
|
|
81
|
+
else [generated]
|
|
82
|
+
)
|
|
83
|
+
if not outputs or len(outputs) > self.max_images:
|
|
84
|
+
raise ValueError("Unexpected number of generated images")
|
|
85
|
+
|
|
86
|
+
batch_id = uuid4().hex
|
|
87
|
+
artifacts = []
|
|
88
|
+
written_keys = []
|
|
89
|
+
try:
|
|
90
|
+
for item in outputs:
|
|
91
|
+
payload = self._image_bytes(item)
|
|
92
|
+
with Image.open(
|
|
93
|
+
BytesIO(payload), formats=list(_MEDIA_TYPES)
|
|
94
|
+
) as image:
|
|
95
|
+
if image.width * image.height > self.max_pixels:
|
|
96
|
+
raise ValueError(
|
|
97
|
+
"Generated image exceeds the pixel limit"
|
|
98
|
+
)
|
|
99
|
+
media_type = _MEDIA_TYPES[image.format]
|
|
100
|
+
image.verify()
|
|
101
|
+
artifact = ImageArtifact(
|
|
102
|
+
artifact_id=f"{batch_id}.{uuid4().hex}",
|
|
103
|
+
media_type=media_type,
|
|
104
|
+
byte_count=len(payload),
|
|
105
|
+
provider=type(self.model).__name__,
|
|
106
|
+
model=getattr(self.model, "name", None),
|
|
107
|
+
)
|
|
108
|
+
key = image_artifact_key(self.scope, artifact.artifact_id)
|
|
109
|
+
for suffix, data in (
|
|
110
|
+
("image", payload),
|
|
111
|
+
("artifact.json", json.dumps(asdict(artifact)).encode()),
|
|
112
|
+
):
|
|
113
|
+
object_key = f"{key}/{suffix}"
|
|
114
|
+
self.storage.put_blob(object_key, data)
|
|
115
|
+
written_keys.append(object_key)
|
|
116
|
+
artifacts.append(artifact)
|
|
117
|
+
batch_key = image_batch_key(self.scope, batch_id)
|
|
118
|
+
self.storage.put_blob(
|
|
119
|
+
f"{batch_key}/batch.json",
|
|
120
|
+
json.dumps(
|
|
121
|
+
[asdict(artifact) for artifact in artifacts]
|
|
122
|
+
).encode(),
|
|
123
|
+
)
|
|
124
|
+
except Exception:
|
|
125
|
+
# A batch without a publication marker stays private.
|
|
126
|
+
self._discard(written_keys)
|
|
127
|
+
raise
|
|
128
|
+
return batch_id, artifacts
|
|
129
|
+
|
|
130
|
+
def _discard(self, keys: list[str]) -> None:
|
|
131
|
+
"""Remove partial staging data where the storage backend permits it."""
|
|
132
|
+
import asyncio
|
|
133
|
+
|
|
134
|
+
async def discard() -> None:
|
|
135
|
+
for key in keys:
|
|
136
|
+
try:
|
|
137
|
+
await self.storage.remove_object(key)
|
|
138
|
+
except Exception:
|
|
139
|
+
continue
|
|
140
|
+
|
|
141
|
+
asyncio.run(discard())
|
|
142
|
+
|
|
143
|
+
def staged_artifacts(self, batch_id: str) -> list[ImageArtifact]:
|
|
144
|
+
"""Load staged references for an application-controlled retry."""
|
|
145
|
+
key = image_batch_key(self.scope, batch_id)
|
|
146
|
+
return [
|
|
147
|
+
ImageArtifact(**entry)
|
|
148
|
+
for entry in json.loads(self.storage.get_blob(f"{key}/batch.json"))
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
def publish(self, batch_id: str) -> None:
|
|
152
|
+
"""Make a fully staged batch visible with a single storage write."""
|
|
153
|
+
key = image_batch_key(self.scope, batch_id)
|
|
154
|
+
self.storage.put_blob(f"{key}/published", b"1")
|
|
155
|
+
|
|
156
|
+
@staticmethod
|
|
157
|
+
def result(artifacts: list[ImageArtifact]) -> dict[str, Any]:
|
|
158
|
+
"""Build the model-facing result without including image bytes."""
|
|
159
|
+
return {
|
|
160
|
+
"status": "generated",
|
|
161
|
+
"artifacts": [asdict(item) for item in artifacts],
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
def _image_bytes(self, item: Any) -> bytes:
|
|
165
|
+
if self.output == "url" and isinstance(item, str):
|
|
166
|
+
return self._fetch(item)
|
|
167
|
+
if self.output == "base64" and isinstance(item, str):
|
|
168
|
+
item = item.partition(",")[2] if item.startswith("data:") else item
|
|
169
|
+
if len(item) > ((self.max_bytes + 2) // 3) * 4:
|
|
170
|
+
raise ValueError("Generated image exceeds the byte limit")
|
|
171
|
+
item = base64.b64decode(item, validate=True)
|
|
172
|
+
if (
|
|
173
|
+
not isinstance(item, bytes)
|
|
174
|
+
or not item
|
|
175
|
+
or len(item) > self.max_bytes
|
|
176
|
+
):
|
|
177
|
+
raise ValueError("Invalid generated image payload or size")
|
|
178
|
+
return item
|
|
179
|
+
|
|
180
|
+
def _fetch(self, url: str) -> bytes:
|
|
181
|
+
# Refuse redirects so the allowlist applies to every request.
|
|
182
|
+
parsed = urlsplit(url)
|
|
183
|
+
if (
|
|
184
|
+
parsed.scheme != "https"
|
|
185
|
+
or parsed.hostname not in self.allowed_hosts
|
|
186
|
+
or parsed.port not in (None, 443)
|
|
187
|
+
or parsed.username is not None
|
|
188
|
+
or parsed.password is not None
|
|
189
|
+
):
|
|
190
|
+
raise ValueError(
|
|
191
|
+
"The generated image URL is outside the configured HTTPS hosts"
|
|
192
|
+
)
|
|
193
|
+
with httpx.stream(
|
|
194
|
+
"GET", url, timeout=self.timeout, follow_redirects=False
|
|
195
|
+
) as response:
|
|
196
|
+
if response.status_code != 200:
|
|
197
|
+
raise ValueError("The provider did not return an image")
|
|
198
|
+
result = bytearray()
|
|
199
|
+
for chunk in response.iter_bytes(chunk_size=65536):
|
|
200
|
+
result.extend(chunk)
|
|
201
|
+
if len(result) > self.max_bytes:
|
|
202
|
+
raise ValueError("Generated image exceeds the byte limit")
|
|
203
|
+
return bytes(result)
|