@hanzo/studio 0.1.8 → 0.1.11
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/app/director.d.ts +137 -0
- package/lib/app/director.js +1263 -0
- package/lib/app/flow.d.ts +58 -0
- package/lib/app/flow.js +948 -0
- package/lib/chat/turn.js +19 -11
- package/lib/home.d.ts +3 -1
- package/lib/home.js +3 -3
- package/lib/index.d.ts +6 -0
- package/lib/index.js +5 -0
- package/lib/kinds/app.d.ts +40 -0
- package/lib/kinds/app.js +907 -0
- package/lib/kinds/document.js +256 -19
- package/lib/kinds/image.d.ts +3 -0
- package/lib/kinds/image.js +82 -10
- package/lib/kinds/index.js +2 -1
- package/lib/kinds/sound.js +109 -10
- package/lib/kinds/video.js +146 -17
- package/lib/live.d.ts +11 -0
- package/lib/live.js +10 -0
- package/lib/made.d.ts +2 -1
- package/lib/made.js +1 -0
- package/lib/pdf.js +1 -1
- package/lib/places.d.ts +0 -3
- package/lib/places.js +1 -11
- package/lib/route.d.ts +12 -0
- package/lib/route.js +17 -0
- package/lib/starters.d.ts +21 -0
- package/lib/starters.js +33 -2
- package/lib/studio.js +1 -1
- package/lib/talk.js +61 -23
- package/lib/wire.d.ts +2 -6
- package/lib/wire.js +16 -3
- package/package.json +1 -1
package/lib/wire.js
CHANGED
|
@@ -216,8 +216,20 @@ export function bytes(url) {
|
|
|
216
216
|
* a chat completion asking for both modalities; the pictures come back on the
|
|
217
217
|
* message (`images`) or among its content parts.
|
|
218
218
|
*/
|
|
219
|
+
const IMAGE_GEN_MODELS = new Set(['iro', 'iro-1', 'zen-image', 'zen3-image', 'enso-image', 'koma']);
|
|
219
220
|
export async function draw(w, model, prompt, o = {}) {
|
|
220
221
|
let held;
|
|
222
|
+
if (!o.from?.length && (IMAGE_GEN_MODELS.has(model) || model.startsWith('black-forest-labs/'))) {
|
|
223
|
+
const gen = await ask(w, 'api', '/v1/images/generations', {
|
|
224
|
+
body: { model, prompt, size: '1024x1024' },
|
|
225
|
+
signal: o.signal,
|
|
226
|
+
heard: (h) => (held = h),
|
|
227
|
+
});
|
|
228
|
+
const b64s = (gen.data ?? []).map((d) => d.b64_json ?? '').filter(Boolean);
|
|
229
|
+
if (!b64s.length)
|
|
230
|
+
throw withheld(model, held);
|
|
231
|
+
return b64s.map((b) => bytes(`data:image/jpeg;base64,${b}`));
|
|
232
|
+
}
|
|
221
233
|
const content = [{ type: 'text', text: prompt }, ...(o.from ?? []).map((url) => ({ type: 'image_url', image_url: { url } }))];
|
|
222
234
|
const out = await ask(w, 'api', '/v1/chat/completions', {
|
|
223
235
|
body: {
|
|
@@ -318,7 +330,8 @@ export function libraryLive(w) {
|
|
|
318
330
|
}
|
|
319
331
|
/** The most a browser may send the Library in one save (its inline limit). */
|
|
320
332
|
const INLINE = 10 * 1024 * 1024;
|
|
321
|
-
|
|
333
|
+
/** What each kind makes, as the Library files it (`POST /v1/library` `kind`). */
|
|
334
|
+
export const LIBRARY = { image: 'image', poster: 'image', ad: 'image', video: 'video', voice: 'audio', music: 'audio', document: 'document', slides: 'slides', type: 'type', mesh: 'model', app: 'app' };
|
|
322
335
|
/** Whether a key and its bytes belong in the Library: a made file the Library can take from a browser. */
|
|
323
336
|
const shelvable = (key, blob) => key.startsWith('files/') && key.split('/').length > 3 && blob.size <= INLINE;
|
|
324
337
|
const base64 = async (b) => {
|
|
@@ -337,9 +350,9 @@ async function shelve(w, key, blob) {
|
|
|
337
350
|
mime: blob.type || 'application/octet-stream',
|
|
338
351
|
data: await base64(blob),
|
|
339
352
|
source: 'studio',
|
|
340
|
-
kind:
|
|
353
|
+
kind: LIBRARY[kind] ?? 'file',
|
|
341
354
|
ref: chat,
|
|
342
|
-
origin: `/
|
|
355
|
+
origin: `/design/c/${chat}`,
|
|
343
356
|
key,
|
|
344
357
|
},
|
|
345
358
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/studio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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.",
|