utilitas 1999.1.53 → 1999.1.54
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.
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/image.mjs +6 -7
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/image.mjs
CHANGED
|
@@ -43,12 +43,12 @@ const generate = async (prompt, options) => {
|
|
|
43
43
|
prompt = ensureString(prompt);
|
|
44
44
|
assert(prompt.length <= 4000,
|
|
45
45
|
'Prompt must be less than 4000 characters.', 400);
|
|
46
|
+
options = {
|
|
47
|
+
...options || {},
|
|
48
|
+
expected: ensureString(options?.expected || BUFFER, { case: 'LOW' }),
|
|
49
|
+
};
|
|
46
50
|
switch (provider) {
|
|
47
51
|
case OPENAI:
|
|
48
|
-
options = {
|
|
49
|
-
...options || {},
|
|
50
|
-
expected: ensureString(options?.expected || BUFFER, { case: 'LOW' }),
|
|
51
|
-
};
|
|
52
52
|
try { // https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1
|
|
53
53
|
var resp = await client.generate({
|
|
54
54
|
prompt, model: OPENAI_MODEL, n, quality: 'high',
|
|
@@ -60,14 +60,13 @@ const generate = async (prompt, options) => {
|
|
|
60
60
|
} catch (err) { throwError(err?.message || ERROR_GENERATING); }
|
|
61
61
|
if (!options?.raw) {
|
|
62
62
|
resp.data = await Promise.all(resp.data.map(async x => ({
|
|
63
|
-
caption: `🎨 by ${OPENAI_MODEL}`,
|
|
63
|
+
caption: `🎨 by [${OPENAI_MODEL}](https://deepmind.google/technologies/imagen-3/)`,
|
|
64
64
|
data: await extractImage(x.b64_json, options),
|
|
65
65
|
mimeType: MIME_PNG,
|
|
66
66
|
})));
|
|
67
67
|
}
|
|
68
68
|
return resp?.data;
|
|
69
69
|
case GEMINI:
|
|
70
|
-
options.expected === 'URL' && (options.expected = 'FILE');
|
|
71
70
|
var resp = await (await fetch(
|
|
72
71
|
'https://generativelanguage.googleapis.com/v1beta/models/'
|
|
73
72
|
+ `${IMAGEN_MODEL}:predict?key=${client.apiKey}`, {
|
|
@@ -83,7 +82,7 @@ const generate = async (prompt, options) => {
|
|
|
83
82
|
if (!options?.raw) {
|
|
84
83
|
resp = await Promise.all((resp?.predictions || []).map(
|
|
85
84
|
async x => ({
|
|
86
|
-
caption: `🎨 by ${IMAGEN_MODEL}`,
|
|
85
|
+
caption: `🎨 by [${IMAGEN_MODEL}](https://openai.com/index/image-generation-api/)`,
|
|
87
86
|
data: await extractImage(x.bytesBase64Encoded, options),
|
|
88
87
|
mimeType: x.mimeType,
|
|
89
88
|
})
|
package/lib/manifest.mjs
CHANGED