@hanzo/studio 0.1.2 → 0.1.4
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/lib/kinds/image.d.ts +2 -0
- package/lib/kinds/image.js +25 -5
- package/package.json +3 -3
package/lib/kinds/image.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare const ZEN = "zen-image";
|
|
|
22
22
|
export declare const ASPECTS: readonly ['1:1', '4:5', '3:4', '2:3', '9:16', '16:9', '3:2', '4:3', '21:9'];
|
|
23
23
|
/** Which lane a request takes: the one asked for, else Zen Image on a GPU that can run it, else the gateway. */
|
|
24
24
|
export declare function lane(model: string, fleet: Fleet | null): string;
|
|
25
|
+
/** Which lane an edit takes: the one asked for, else Qwen Edit on a GPU that can run it, else the gateway. */
|
|
26
|
+
export declare function editing(model: string, fleet: Fleet | null): string;
|
|
25
27
|
/** Why the gateway's image models are not answering now, or null. */
|
|
26
28
|
export declare function useImageLane(): {
|
|
27
29
|
model: string;
|
package/lib/kinds/image.js
CHANGED
|
@@ -5,7 +5,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
* Two lanes, chosen per request: the gateway's image models (api.hanzo.ai,
|
|
6
6
|
* billed to the org) and Zen Image on the org's own GPU (Z-Image-Turbo through
|
|
7
7
|
* the engine), which is offered only while a GPU advertises `image.zen`. Auto
|
|
8
|
-
* takes the GPU when one can run it, else the gateway.
|
|
8
|
+
* takes the GPU when one can run it, else the gateway. An edit is the same
|
|
9
|
+
* choice: Qwen Edit on a GPU that advertises `edit.qwen` (the engine's fix
|
|
10
|
+
* lane, from the picture staged on the engine), else a gateway model.
|
|
9
11
|
*/
|
|
10
12
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
11
13
|
import { Image as Picture } from '@hanzogui/lucide-icons-2';
|
|
@@ -13,7 +15,7 @@ import { useState, useSyncExternalStore } from 'react';
|
|
|
13
15
|
import { render } from '../gpu.js';
|
|
14
16
|
import { current, filename } from '../made.js';
|
|
15
17
|
import { useUrl } from '../use.js';
|
|
16
|
-
import { draw, read, Refusal } from '../wire.js';
|
|
18
|
+
import { draw, read, Refusal, stage } from '../wire.js';
|
|
17
19
|
import { lit, num, str } from './kind.js';
|
|
18
20
|
/** The gateway's image models, best first. */
|
|
19
21
|
export const MODELS = [
|
|
@@ -44,6 +46,16 @@ export function lane(model, fleet) {
|
|
|
44
46
|
return model;
|
|
45
47
|
return lit(fleet, 'image.zen') ? ZEN : MODELS[0].id;
|
|
46
48
|
}
|
|
49
|
+
/** Which lane an edit takes: the one asked for, else Qwen Edit on a GPU that can run it, else the gateway. */
|
|
50
|
+
export function editing(model, fleet) {
|
|
51
|
+
if (MODELS.some((m) => m.id === model))
|
|
52
|
+
return model;
|
|
53
|
+
if (lit(fleet, 'edit.qwen'))
|
|
54
|
+
return ZEN;
|
|
55
|
+
if (model === ZEN)
|
|
56
|
+
throw new Error('Editing on your GPU needs one that runs Qwen Edit; connect it with hanzo link, or edit with a gateway model.');
|
|
57
|
+
return MODELS[0].id;
|
|
58
|
+
}
|
|
47
59
|
async function size(blob) {
|
|
48
60
|
try {
|
|
49
61
|
const bmp = await createImageBitmap(blob);
|
|
@@ -74,11 +86,19 @@ export function useImageLane() {
|
|
|
74
86
|
}
|
|
75
87
|
/** Make pictures from words (and, for an edit, the pictures they start from), and keep them. */
|
|
76
88
|
export async function picture(w, o) {
|
|
77
|
-
const use = lane(o.model, w.fleet);
|
|
89
|
+
const use = o.from?.length ? editing(o.model, w.fleet) : lane(o.model, w.fleet);
|
|
78
90
|
const files = [];
|
|
91
|
+
if (use === ZEN && o.from?.length) {
|
|
92
|
+
for (const f of o.from) {
|
|
93
|
+
w.doing('Sending the picture to your GPU');
|
|
94
|
+
const upload = await stage(w.wire, await read(w.wire, f.key), f.name);
|
|
95
|
+
const got = await render(w.wire, 'fix', { upload, instruction: o.prompt.slice(0, 500) }, w.doing, w.signal);
|
|
96
|
+
for (const g of got)
|
|
97
|
+
files.push(await w.keep(`edit-${files.length + 1}.png`, g.blob, await size(g.blob)));
|
|
98
|
+
}
|
|
99
|
+
return { files, by: 'Qwen Edit (your GPU)' };
|
|
100
|
+
}
|
|
79
101
|
if (use === ZEN) {
|
|
80
|
-
if (o.from?.length)
|
|
81
|
-
throw new Error('Zen Image draws from words only; edit with a gateway model.');
|
|
82
102
|
const [width, height] = PIXELS[o.aspect] ?? PIXELS['1:1'];
|
|
83
103
|
for (let i = 0; i < (o.count ?? 1); i++) {
|
|
84
104
|
const got = await render(w.wire, 'image', { prompt: o.prompt, width, height }, w.doing, w.signal);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"description": "Hanzo Studio: a chat that makes images, posters, documents, slides, type systems, 3D, video and sound, with every result open in a tab beside it. Mounted by the Hanzo app at hanzo.ai/studio and served whole at studio.hanzo.ai.",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@axe-core/playwright": "4.14.0",
|
|
16
|
-
"@hanzo/build": "0.2.
|
|
16
|
+
"@hanzo/build": "0.2.60",
|
|
17
17
|
"@hanzo/composer": "0.2.0",
|
|
18
18
|
"@hanzo/font": "1.9.3",
|
|
19
19
|
"@hanzo/gui": "8.3.5",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"url": "git+https://github.com/hanzoai/studio.git"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@hanzo/build": ">=0.2.
|
|
61
|
+
"@hanzo/build": ">=0.2.60",
|
|
62
62
|
"@hanzo/composer": ">=0.2.0",
|
|
63
63
|
"@hanzo/gui": ">=8.3.5",
|
|
64
64
|
"@hanzo/ui": ">=8.27.77",
|