@vibes.diy/prompts 14.1.0 → 14.1.2
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/llms/callai.md +47 -0
- package/llms/three-js.md +12 -3
- package/package.json +4 -4
- package/system-prompt-initial-oneshot.md +1 -1
- package/system-prompt-initial.md +1 -1
- package/system-prompt.md +1 -1
package/llms/callai.md
CHANGED
|
@@ -56,6 +56,51 @@ console.log(demoData.items); // Array of item objects
|
|
|
56
56
|
- Use simple property names like `name`, `type`, `items`, `price`.
|
|
57
57
|
- Keep array items simple (strings or flat objects).
|
|
58
58
|
|
|
59
|
+
## Reading an Image
|
|
60
|
+
|
|
61
|
+
Send an image by passing the prompt as an array of content parts: an `image_url` part carrying the picture beside a `text` part asking the question.
|
|
62
|
+
|
|
63
|
+
The prompt is the content of one user message, so a plain string means exactly one text part and the array is that same message's parts. Read the picture the user picked with a `FileReader` and hand over the data URL it produces:
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
import { callAI } from "call-ai";
|
|
67
|
+
|
|
68
|
+
function readAsDataUrl(file) {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const reader = new FileReader();
|
|
71
|
+
reader.onload = () => resolve(reader.result);
|
|
72
|
+
reader.onerror = () => reject(reader.error);
|
|
73
|
+
reader.readAsDataURL(file);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function readFlyer(file) {
|
|
78
|
+
const dataUrl = await readAsDataUrl(file);
|
|
79
|
+
const response = await callAI(
|
|
80
|
+
[
|
|
81
|
+
{ type: "text", text: "Read this event flyer and pull out the event details." },
|
|
82
|
+
{ type: "image_url", image_url: { url: dataUrl } },
|
|
83
|
+
],
|
|
84
|
+
{
|
|
85
|
+
schema: {
|
|
86
|
+
properties: {
|
|
87
|
+
title: { type: "string", description: "Name of the event" },
|
|
88
|
+
date: { type: "string", description: "Date as printed on the flyer" },
|
|
89
|
+
time: { type: "string" },
|
|
90
|
+
venue: { type: "string" },
|
|
91
|
+
description: { type: "string" },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
return JSON.parse(response);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
A string prompt stays the common path for text-only work and behaves exactly as it always has. A model that reads text alone answers an image request with an error naming that model, so an app that asks about a picture hears when the picture went unread — surface that message the way you surface any other `callAI` error.
|
|
101
|
+
|
|
102
|
+
Inside `backend.js`, `ctx.callAI` takes a string prompt.
|
|
103
|
+
|
|
59
104
|
## Error Handling
|
|
60
105
|
|
|
61
106
|
```javascript
|
|
@@ -74,3 +119,5 @@ try {
|
|
|
74
119
|
console.error("API error:", error.message);
|
|
75
120
|
}
|
|
76
121
|
```
|
|
122
|
+
|
|
123
|
+
Let the request finish. Reading an image takes several seconds, so a slow answer is still an answer: show a waiting state ("reading your photo…") and keep awaiting the call. The `catch` above is what tells the app a request actually failed.
|
package/llms/three-js.md
CHANGED
|
@@ -361,12 +361,21 @@ function onPointerDown(event) {
|
|
|
361
361
|
## Importing three
|
|
362
362
|
|
|
363
363
|
A bare package name at the top of the file resolves through the platform's esm.sh
|
|
364
|
-
map, and a full esm.sh URL loads too
|
|
365
|
-
|
|
366
|
-
which moves as esm.sh publishes; a version-pinned URL such as
|
|
364
|
+
map, and a full esm.sh URL loads too. The bare form follows whatever version the
|
|
365
|
+
platform serves, which moves as esm.sh publishes; a version-pinned URL such as
|
|
367
366
|
`https://esm.sh/three@0.160.0` is the lever for holding a scene on one release of
|
|
368
367
|
the library.
|
|
369
368
|
|
|
369
|
+
`await import()` defers a library until it is needed. Give it a full esm.sh URL,
|
|
370
|
+
which the browser resolves on its own — for a third-party library like three,
|
|
371
|
+
that is the form that both resolves and defers.
|
|
372
|
+
|
|
373
|
+
A bare specifier resolves through the page's import map, which carries the
|
|
374
|
+
packages the platform serves plus the ones your files import at the top. So a
|
|
375
|
+
bare name loads on demand for a platform package; for three, a name your file
|
|
376
|
+
also imports at the top is already loaded by the time the call runs, and a name
|
|
377
|
+
that appears only inside `await import()` has nothing to resolve through.
|
|
378
|
+
|
|
370
379
|
## Animation System
|
|
371
380
|
|
|
372
381
|
### Animation Mixer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/prompts",
|
|
3
|
-
"version": "14.1.
|
|
3
|
+
"version": "14.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"exports": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@adviser/cement": "~0.5.34",
|
|
37
|
-
"@vibes.diy/call-ai-v2": "14.1.
|
|
38
|
-
"@vibes.diy/identity": "14.1.
|
|
39
|
-
"@vibes.diy/use-vibes-types": "14.1.
|
|
37
|
+
"@vibes.diy/call-ai-v2": "14.1.2",
|
|
38
|
+
"@vibes.diy/identity": "14.1.2",
|
|
39
|
+
"@vibes.diy/use-vibes-types": "14.1.2",
|
|
40
40
|
"arktype": "~2.2.3",
|
|
41
41
|
"json-schema-faker": "~0.6.3"
|
|
42
42
|
},
|
|
@@ -25,7 +25,7 @@ You are an AI assistant tasked with creating React components. You should create
|
|
|
25
25
|
- For dynamic components, like autocomplete, don't use external libraries, implement your own
|
|
26
26
|
- Avoid using external libraries unless they are essential for the component to function
|
|
27
27
|
- Always use ES module imports at the top of the file (e.g. `import React, { useState } from "react"`). Never reference React or other libraries as globals.
|
|
28
|
-
- A bare package name at the top of the file resolves through the platform's esm.sh map, and a full esm.sh URL such as `https://esm.sh/three@0.160.0` loads too.
|
|
28
|
+
- A bare package name at the top of the file resolves through the platform's esm.sh map, and a full esm.sh URL such as `https://esm.sh/three@0.160.0` loads too. To defer a library until it is needed, `await import()` the full URL.
|
|
29
29
|
- Your file MUST use `export default function App()` — the runtime loads it as an ES module and imports the default export.
|
|
30
30
|
- Structure your component code in this order: (1) hooks and document shapes, (2) event handlers, (3) classNames object, (4) JSX return. ClassNames go right before JSX so they are close to where they are used.
|
|
31
31
|
- Use Fireproof for data persistence
|
package/system-prompt-initial.md
CHANGED
|
@@ -25,7 +25,7 @@ You are an AI assistant tasked with creating React components. You should create
|
|
|
25
25
|
- For dynamic components, like autocomplete, don't use external libraries, implement your own
|
|
26
26
|
- Avoid using external libraries unless they are essential for the component to function
|
|
27
27
|
- Always use ES module imports at the top of the file (e.g. `import React, { useState } from "react"`). Never reference React or other libraries as globals.
|
|
28
|
-
- A bare package name at the top of the file resolves through the platform's esm.sh map, and a full esm.sh URL such as `https://esm.sh/three@0.160.0` loads too.
|
|
28
|
+
- A bare package name at the top of the file resolves through the platform's esm.sh map, and a full esm.sh URL such as `https://esm.sh/three@0.160.0` loads too. To defer a library until it is needed, `await import()` the full URL.
|
|
29
29
|
- Your file MUST use `export default function App()` — the runtime loads it as an ES module and imports the default export.
|
|
30
30
|
- Structure your component code in this order: (1) hooks and document shapes, (2) event handlers, (3) classNames object, (4) JSX return. ClassNames go right before JSX so they are close to where they are used.
|
|
31
31
|
- Use Fireproof for data persistence
|
package/system-prompt.md
CHANGED
|
@@ -25,7 +25,7 @@ You are an AI assistant tasked with creating React components. You should create
|
|
|
25
25
|
- For dynamic components, like autocomplete, don't use external libraries, implement your own
|
|
26
26
|
- Avoid using external libraries unless they are essential for the component to function
|
|
27
27
|
- Always use ES module imports at the top of the file (e.g. `import React, { useState } from "react"`). Never reference React or other libraries as globals.
|
|
28
|
-
- A bare package name at the top of the file resolves through the platform's esm.sh map, and a full esm.sh URL such as `https://esm.sh/three@0.160.0` loads too.
|
|
28
|
+
- A bare package name at the top of the file resolves through the platform's esm.sh map, and a full esm.sh URL such as `https://esm.sh/three@0.160.0` loads too. To defer a library until it is needed, `await import()` the full URL.
|
|
29
29
|
- Your file MUST use `export default function App()` — the runtime loads it as an ES module and imports the default export.
|
|
30
30
|
- Structure your component code in this order: (1) hooks and document shapes, (2) event handlers, (3) classNames object, (4) JSX return. ClassNames go right before JSX so they are close to where they are used. Never define components (functions that return JSX) inside `App` or any other component — always define them at module scope and pass data as props. Components defined inside other components are recreated on every render, causing React to unmount and remount them, which breaks form focus and input state.
|
|
31
31
|
- Use Fireproof for data persistence
|