@vibes.diy/prompts 2.0.0-dev-cli-d → 2.0.0-dev-cli-f
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/build-schema-prompt.js +5 -3
- package/build-schema-prompt.js.map +1 -1
- package/llms/callai.txt +24 -303
- package/llms/d3.md +11 -0
- package/llms/fireproof.txt +64 -20
- package/llms/three-js.md +10 -0
- package/package.json +9 -9
- package/prompts.d.ts +4 -6
- package/prompts.js +24 -28
- package/prompts.js.map +1 -1
- package/settings.d.ts +0 -7
package/build-schema-prompt.js
CHANGED
|
@@ -8,9 +8,11 @@ async function buildExample(schema) {
|
|
|
8
8
|
}
|
|
9
9
|
export async function buildSchemaSystemMessage(schema) {
|
|
10
10
|
const example = await buildExample(schema);
|
|
11
|
-
return `Return a JSON object
|
|
11
|
+
return `Return ONLY a JSON object inside a \`\`\`json code fence. Conform to this schema: ${JSON.stringify(schema)}
|
|
12
12
|
|
|
13
|
-
Example of expected output
|
|
14
|
-
|
|
13
|
+
Example of expected output:
|
|
14
|
+
\`\`\`json
|
|
15
|
+
${JSON.stringify(example, null, 2)}
|
|
16
|
+
\`\`\``;
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=build-schema-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-schema-prompt.js","sourceRoot":"","sources":["../jsr/build-schema-prompt.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAmB,MAAM,mBAAmB,CAAC;AAE9D,KAAK,UAAU,YAAY,CAAC,MAAkB;IAC5C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC;IACnE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,MAAc;IAC3D,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,MAAoB,CAAC,CAAC;IACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"build-schema-prompt.js","sourceRoot":"","sources":["../jsr/build-schema-prompt.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAmB,MAAM,mBAAmB,CAAC;AAE9D,KAAK,UAAU,YAAY,CAAC,MAAkB;IAC5C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC;IACnE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,MAAc;IAC3D,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,MAAoB,CAAC,CAAC;IACzD,OAAO,qFAAqF,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;;;;EAIlH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;OAC3B,CAAC;AACR,CAAC"}
|
package/llms/callai.txt
CHANGED
|
@@ -1,241 +1,31 @@
|
|
|
1
1
|
# CallAI Helper Function
|
|
2
2
|
|
|
3
|
-
The `callAI`
|
|
3
|
+
The `callAI` function returns structured JSON from an AI model. It always requires a schema and returns a string that you `JSON.parse()`.
|
|
4
4
|
|
|
5
5
|
## Basic Usage
|
|
6
6
|
|
|
7
|
-
By default the function returns a Promise that resolves to the complete response:
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
import { callAI } from 'call-ai';
|
|
11
|
-
|
|
12
|
-
// Default behavior - returns a Promise<string>
|
|
13
|
-
const response = await callAI("Write a haiku");
|
|
14
|
-
|
|
15
|
-
// Use the complete response directly
|
|
16
|
-
console.log(response); // Complete response text
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Streaming Mode
|
|
20
|
-
|
|
21
|
-
If you prefer to receive the response incrementally as it's generated, set `stream: true`. This returns an AsyncGenerator which must be awaited:
|
|
22
|
-
|
|
23
7
|
```javascript
|
|
24
8
|
import { callAI } from 'call-ai';
|
|
25
9
|
|
|
26
|
-
|
|
27
|
-
const generator = await callAI("Write an epic poem", { stream: true });
|
|
28
|
-
// Process the streaming response
|
|
29
|
-
for await (const partialResponse of generator) {
|
|
30
|
-
console.log(partialResponse); // Updates incrementally
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## JSON Schema Responses
|
|
35
|
-
|
|
36
|
-
To get structured JSON responses, provide a schema in the options:
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
import { callAI } from 'call-ai';
|
|
40
|
-
|
|
41
|
-
const todoResponse = await callAI("Give me a todo list for learning React", {
|
|
10
|
+
const response = await callAI("Give me a todo list for learning React", {
|
|
42
11
|
schema: {
|
|
43
|
-
name: "todo", // Optional - defaults to "result" if not provided
|
|
44
12
|
properties: {
|
|
45
13
|
todos: {
|
|
46
14
|
type: "array",
|
|
15
|
+
description: "List of actionable todo items",
|
|
47
16
|
items: { type: "string" }
|
|
48
17
|
}
|
|
49
18
|
}
|
|
50
19
|
}
|
|
51
20
|
});
|
|
52
|
-
const todoData = JSON.parse(
|
|
53
|
-
console.log(todoData.todos);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## JSON with Streaming
|
|
57
|
-
|
|
58
|
-
In this example, we're using the `callAI` helper function to get weather data in a structured format with streaming preview:
|
|
59
|
-
|
|
60
|
-
```javascript
|
|
61
|
-
import { callAI } from 'call-ai';
|
|
62
|
-
|
|
63
|
-
// Get weather data with streaming updates
|
|
64
|
-
const generator = await callAI("What's the weather like in Paris today?", {
|
|
65
|
-
stream: true,
|
|
66
|
-
schema: {
|
|
67
|
-
properties: {
|
|
68
|
-
location: {
|
|
69
|
-
type: "string",
|
|
70
|
-
description: "City or location name"
|
|
71
|
-
},
|
|
72
|
-
temperature: {
|
|
73
|
-
type: "number",
|
|
74
|
-
description: "Temperature in Celsius"
|
|
75
|
-
},
|
|
76
|
-
conditions: {
|
|
77
|
-
type: "string",
|
|
78
|
-
description: "Weather conditions description"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Preview streaming updates as they arrive, don't parse until the end
|
|
85
|
-
const resultElement = document.getElementById('result');
|
|
86
|
-
let finalResponse;
|
|
87
|
-
|
|
88
|
-
for await (const partialResponse of generator) {
|
|
89
|
-
resultElement.textContent = partialResponse;
|
|
90
|
-
finalResponse = partialResponse;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Parse final result
|
|
94
|
-
try {
|
|
95
|
-
const weatherData = JSON.parse(finalResponse);
|
|
96
|
-
|
|
97
|
-
// Access individual fields
|
|
98
|
-
const { location, temperature, conditions } = weatherData;
|
|
99
|
-
|
|
100
|
-
// Update UI with formatted data
|
|
101
|
-
document.getElementById('location').textContent = location;
|
|
102
|
-
document.getElementById('temperature').textContent = `${temperature}°C`;
|
|
103
|
-
document.getElementById('conditions').textContent = conditions;
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.error("Failed to parse response:", error);
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Schema Structure Recommendations
|
|
110
|
-
|
|
111
|
-
1. **Flat schemas perform better across all models**. If you need maximum compatibility, avoid deeply nested structures.
|
|
112
|
-
|
|
113
|
-
2. **Field names matter**. Some models have preferences for certain property naming patterns:
|
|
114
|
-
- Use simple, common naming patterns like `name`, `type`, `items`, `price`
|
|
115
|
-
- Avoid deeply nested object hierarchies (more than 2 levels deep)
|
|
116
|
-
- Keep array items simple (strings or flat objects)
|
|
117
|
-
|
|
118
|
-
## Specifying a Model
|
|
119
|
-
|
|
120
|
-
By default, the function uses `openrouter/auto` (automatic model selection). You can specify a different model:
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
import { callAI } from 'call-ai';
|
|
124
|
-
|
|
125
|
-
// Use a specific model via options
|
|
126
|
-
const response = await callAI(
|
|
127
|
-
"Explain quantum computing in simple terms",
|
|
128
|
-
{ model: "openai/gpt-4o" }
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
console.log(response);
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Additional Options
|
|
135
|
-
|
|
136
|
-
You can pass extra parameters to customize the request:
|
|
137
|
-
|
|
138
|
-
```javascript
|
|
139
|
-
import { callAI } from 'call-ai';
|
|
140
|
-
|
|
141
|
-
const response = await callAI(
|
|
142
|
-
"Write a creative story",
|
|
143
|
-
{
|
|
144
|
-
model: "anthropic/claude-3-opus",
|
|
145
|
-
temperature: 0.8, // Higher for more creativity (0-1)
|
|
146
|
-
max_tokens: 1000, // Limit response length
|
|
147
|
-
top_p: 0.95 // Control randomness
|
|
148
|
-
}
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
console.log(response);
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Message History
|
|
155
|
-
|
|
156
|
-
For multi-turn conversations, you can pass an array of messages:
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
import { callAI } from 'call-ai';
|
|
160
|
-
|
|
161
|
-
// Create a conversation
|
|
162
|
-
const messages = [
|
|
163
|
-
{ role: "system", content: "You are a helpful coding assistant." },
|
|
164
|
-
{ role: "user", content: "How do I use React hooks?" },
|
|
165
|
-
{ role: "assistant", content: "React hooks are functions that let you use state and other React features in functional components..." },
|
|
166
|
-
{ role: "user", content: "Can you show me an example of useState?" }
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
// Pass the entire conversation history
|
|
170
|
-
const response = await callAI(messages);
|
|
171
|
-
console.log(response);
|
|
172
|
-
|
|
173
|
-
// To continue the conversation, add the new response and send again
|
|
174
|
-
messages.push({ role: "assistant", content: response });
|
|
175
|
-
messages.push({ role: "user", content: "What about useEffect?" });
|
|
176
|
-
|
|
177
|
-
// Call again with updated history
|
|
178
|
-
const nextResponse = await callAI(messages);
|
|
179
|
-
console.log(nextResponse);
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## Recommended Models
|
|
183
|
-
|
|
184
|
-
| Model | Best For | Speed vs Quality |
|
|
185
|
-
|-------|----------|------------------|
|
|
186
|
-
| `openrouter/auto` | Default, automatically selects | Adaptive |
|
|
187
|
-
| `openai/gpt-4o-mini` | data generation | Fast, good quality |
|
|
188
|
-
| `anthropic/claude-3-haiku` | Cost-effective | Fast, good quality |
|
|
189
|
-
| `openai/gpt-4o` | Best overall quality | Medium speed, highest quality |
|
|
190
|
-
| `anthropic/claude-3-opus` | Complex reasoning | Slower, highest quality |
|
|
191
|
-
| `mistralai/mistral-large` | Open weights alternative | Good balance |
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
## Items with lists
|
|
195
|
-
|
|
196
|
-
```javascript
|
|
197
|
-
import { callAI } from 'call-ai';
|
|
198
|
-
|
|
199
|
-
const generator = await callAI([
|
|
200
|
-
{
|
|
201
|
-
role: "user",
|
|
202
|
-
content: "Generate 3 JSON records with name, description, tags, and priority (0 is highest, 5 is lowest)."
|
|
203
|
-
}
|
|
204
|
-
], {
|
|
205
|
-
stream: true,
|
|
206
|
-
schema: {
|
|
207
|
-
properties: {
|
|
208
|
-
records: {
|
|
209
|
-
type: "array",
|
|
210
|
-
items: {
|
|
211
|
-
type: "object",
|
|
212
|
-
properties: {
|
|
213
|
-
name: { type: "string" },
|
|
214
|
-
description: { type: "string" },
|
|
215
|
-
tags: {
|
|
216
|
-
type: "array",
|
|
217
|
-
items: { type: "string" }
|
|
218
|
-
},
|
|
219
|
-
priority: { type: "integer" }
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
for await (const partialResponse of generator) {
|
|
228
|
-
console.log(partialResponse);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const recordData = JSON.parse(/* final response */);
|
|
232
|
-
console.log(recordData.records); // Array of records
|
|
21
|
+
const todoData = JSON.parse(response);
|
|
22
|
+
console.log(todoData.todos);
|
|
233
23
|
```
|
|
234
24
|
|
|
235
25
|
## Items with properties
|
|
236
26
|
|
|
237
27
|
```javascript
|
|
238
|
-
const
|
|
28
|
+
const response = await callAI("Generate 4 items with label, status, priority (low, medium, high, critical), and notes. Return as structured JSON with these fields.", {
|
|
239
29
|
schema: {
|
|
240
30
|
properties: {
|
|
241
31
|
items: {
|
|
@@ -243,110 +33,41 @@ const demoData = await callAI("Generate 4 items with label, status, priority (lo
|
|
|
243
33
|
items: {
|
|
244
34
|
type: "object",
|
|
245
35
|
properties: {
|
|
246
|
-
label: { type: "string" },
|
|
247
|
-
status: { type: "string" },
|
|
248
|
-
priority: { type: "string" },
|
|
249
|
-
notes: { type: "string" }
|
|
36
|
+
label: { type: "string", description: "Short name for the item" },
|
|
37
|
+
status: { type: "string", description: "Current status (active, done, blocked)" },
|
|
38
|
+
priority: { type: "string", description: "Priority level (low, medium, high, critical)" },
|
|
39
|
+
notes: { type: "string", description: "Additional context or details" }
|
|
250
40
|
}
|
|
251
41
|
}
|
|
252
42
|
}
|
|
253
43
|
}
|
|
254
44
|
}
|
|
255
45
|
});
|
|
46
|
+
const demoData = JSON.parse(response);
|
|
47
|
+
console.log(demoData.items); // Array of item objects
|
|
256
48
|
```
|
|
257
49
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
Errors are handled through standard JavaScript try/catch blocks:
|
|
261
|
-
|
|
262
|
-
```javascript
|
|
263
|
-
import { callAI } from 'call-ai';
|
|
264
|
-
|
|
265
|
-
try {
|
|
50
|
+
### Schema Tips
|
|
266
51
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
// If no error was thrown, process the normal response
|
|
272
|
-
console.log(response);
|
|
273
|
-
} catch (error) {
|
|
274
|
-
// API errors are standard Error objects with useful properties
|
|
275
|
-
console.error("API error:", error.message);
|
|
276
|
-
console.error("Status code:", error.status);
|
|
277
|
-
console.error("Error type:", error.errorType);
|
|
278
|
-
console.error("Error details:", error.details);
|
|
279
|
-
}
|
|
280
|
-
```
|
|
52
|
+
- Flat schemas perform better across all models. Avoid nesting deeper than 2 levels.
|
|
53
|
+
- Use simple property names like `name`, `type`, `items`, `price`.
|
|
54
|
+
- Keep array items simple (strings or flat objects).
|
|
281
55
|
|
|
282
|
-
|
|
56
|
+
## Error Handling
|
|
283
57
|
|
|
284
58
|
```javascript
|
|
285
59
|
import { callAI } from 'call-ai';
|
|
286
60
|
|
|
287
61
|
try {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
62
|
+
const response = await callAI("Generate some content", {
|
|
63
|
+
schema: {
|
|
64
|
+
properties: {
|
|
65
|
+
result: { type: "string" }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
291
68
|
});
|
|
292
|
-
|
|
293
|
-
// Any error during streaming will throw an exception
|
|
294
|
-
let finalResponse = '';
|
|
295
|
-
for await (const chunk of generator) {
|
|
296
|
-
finalResponse = chunk;
|
|
297
|
-
console.log("Chunk:", chunk);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Process the final response
|
|
301
|
-
console.log("Final response:", finalResponse);
|
|
69
|
+
console.log(JSON.parse(response));
|
|
302
70
|
} catch (error) {
|
|
303
|
-
// Handle errors with standard try/catch
|
|
304
71
|
console.error("API error:", error.message);
|
|
305
|
-
console.error("Error properties:", {
|
|
306
|
-
status: error.status,
|
|
307
|
-
type: error.errorType,
|
|
308
|
-
details: error.details
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
This approach is idiomatic and consistent with standard JavaScript practices. Errors provide rich information for better debugging and error handling in your applications.
|
|
314
|
-
|
|
315
|
-
## Image Recognition Example
|
|
316
|
-
|
|
317
|
-
Call-AI supports image recognition using multimodal models like GPT-4o. You can pass both text and image content to analyze images in the browser:
|
|
318
|
-
|
|
319
|
-
```javascript
|
|
320
|
-
import { callAI } from 'call-ai';
|
|
321
|
-
|
|
322
|
-
// Function to analyze an image using GPT-4o
|
|
323
|
-
async function analyzeImage(imageFile, prompt = 'Describe this image in detail') {
|
|
324
|
-
// Convert the image file to a data URL
|
|
325
|
-
const dataUrl = await fileToDataUrl(imageFile);
|
|
326
|
-
|
|
327
|
-
const content = [
|
|
328
|
-
{ type: 'text', text: prompt },
|
|
329
|
-
{ type: 'image_url', image_url: { url: dataUrl } }
|
|
330
|
-
];
|
|
331
|
-
|
|
332
|
-
// Call the model with the multimodal content
|
|
333
|
-
const result = await callAI(
|
|
334
|
-
[{ role: 'user', content }],
|
|
335
|
-
{
|
|
336
|
-
model: 'openai/gpt-4o-2024-08-06', // Or 'openai/gpt-4o-latest'
|
|
337
|
-
apiKey: window.CALLAI_API_KEY,
|
|
338
|
-
}
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
return result;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Helper function to convert File to data URL
|
|
345
|
-
async function fileToDataUrl(file) {
|
|
346
|
-
return new Promise((resolve) => {
|
|
347
|
-
const reader = new FileReader();
|
|
348
|
-
reader.onloadend = () => resolve(reader.result);
|
|
349
|
-
reader.readAsDataURL(file);
|
|
350
|
-
});
|
|
351
72
|
}
|
|
352
73
|
```
|
package/llms/d3.md
CHANGED
|
@@ -126,11 +126,22 @@ bars
|
|
|
126
126
|
|
|
127
127
|
## Complete Examples for Coding Agents
|
|
128
128
|
|
|
129
|
+
### Code Structure for D3 + React Apps
|
|
130
|
+
|
|
131
|
+
Structure your component in this order:
|
|
132
|
+
|
|
133
|
+
1. **D3 helper functions** — visualization logic separate from React
|
|
134
|
+
2. **Hooks and state** — useFireproof, useRef, useState
|
|
135
|
+
3. **Effects** — useEffect to call D3 helpers when data changes
|
|
136
|
+
4. **ClassNames object** — colors, dimensions right before JSX so they stay consistent
|
|
137
|
+
5. **JSX return** — layout with refs for D3 to target
|
|
138
|
+
|
|
129
139
|
### 1. Simple Bar Chart
|
|
130
140
|
|
|
131
141
|
```js
|
|
132
142
|
import * as d3 from "d3";
|
|
133
143
|
|
|
144
|
+
// 1. Design tokens and dimensions
|
|
134
145
|
const data = [4, 8, 15, 16, 23, 42];
|
|
135
146
|
const width = 500;
|
|
136
147
|
const height = 300;
|
package/llms/fireproof.txt
CHANGED
|
@@ -7,7 +7,7 @@ Fireproof is a lightweight embedded document database with encrypted live sync,
|
|
|
7
7
|
- **Apps run anywhere:** Bundle UI, data, and logic in one file.
|
|
8
8
|
- **Real-Time & Offline-First:** Automatic persistence and live queries, runs in the browser - no loading or error states.
|
|
9
9
|
- **Unified API:** TypeScript works with Deno, Bun, Node.js, and the browser.
|
|
10
|
-
- **React Hooks:** Leverage `useLiveQuery` and `useDocument` for live collaboration.
|
|
10
|
+
- **React Hooks:** Leverage `useLiveQuery` and `useDocument` for live collaboration. Note: these are NOT top-level exports — they are returned by the `useFireproof()` hook. Always destructure from `const { useLiveQuery, useDocument, database } = useFireproof("db-name")`.
|
|
11
11
|
|
|
12
12
|
Fireproof enforces cryptographic causal consistency and ledger integrity using hash history, providing git-like versioning with lightweight blockchain-style verification. Data is stored and replicated as content-addressed encrypted blobs, making it safe and easy to sync via commodity object storage providers.
|
|
13
13
|
|
|
@@ -99,6 +99,20 @@ For form-based creation flows, use `submit`:
|
|
|
99
99
|
|
|
100
100
|
When you call submit, the document is reset, so if you didn't provide an `_id` then you can use the form to create a stream of new documents as in the basic example above.
|
|
101
101
|
|
|
102
|
+
### Updating Documents in Event Handlers
|
|
103
|
+
|
|
104
|
+
To update an existing document from a click handler or callback, use `database.put()` directly. Never call `useDocument` inside an event handler — that violates React's Rules of Hooks.
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
// ✅ Correct — use database.put() in handlers
|
|
108
|
+
onClick={() => database.put({ ...doc, favorite: !doc.favorite })}
|
|
109
|
+
|
|
110
|
+
// ❌ Wrong — never call hooks inside handlers
|
|
111
|
+
function toggleFavorite(id) {
|
|
112
|
+
const { doc, save } = useDocument({ _id: id }) // BREAKS Rules of Hooks
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
102
116
|
### Query Data
|
|
103
117
|
|
|
104
118
|
Data is queried by sorted indexes defined by the application. Sort by strings, numbers, or booleans, as well as arrays for grouping. Use numbers when possible for sorting continuous data.
|
|
@@ -330,12 +344,13 @@ function handleSubmit(e) {
|
|
|
330
344
|
|
|
331
345
|
## Example React Application
|
|
332
346
|
|
|
333
|
-
Code listing for todo tracker App.jsx:
|
|
347
|
+
Code listing for todo tracker App.jsx. Note the code ordering: hooks, then handlers, then classNames right before JSX.
|
|
334
348
|
```js
|
|
335
349
|
import React from "react";
|
|
336
350
|
import { useFireproof } from "use-fireproof";
|
|
337
351
|
|
|
338
352
|
export default function App() {
|
|
353
|
+
// 1. Hooks and document shapes
|
|
339
354
|
const { useLiveQuery, useDocument, database } = useFireproof("todo-list-db");
|
|
340
355
|
|
|
341
356
|
const {
|
|
@@ -349,11 +364,12 @@ export default function App() {
|
|
|
349
364
|
createdAt: Date.now()
|
|
350
365
|
});
|
|
351
366
|
|
|
352
|
-
const { docs: todos } = useLiveQuery("type", {
|
|
367
|
+
const { docs: todos } = useLiveQuery("type", {
|
|
353
368
|
key: "todo",
|
|
354
|
-
descending: true
|
|
369
|
+
descending: true
|
|
355
370
|
});
|
|
356
371
|
|
|
372
|
+
// 2. Event handlers
|
|
357
373
|
const handleInputChange = (e) => {
|
|
358
374
|
mergeNewTodo({ todo: e.target.value });
|
|
359
375
|
};
|
|
@@ -363,13 +379,20 @@ export default function App() {
|
|
|
363
379
|
submitNewTodo();
|
|
364
380
|
};
|
|
365
381
|
|
|
382
|
+
// 3. ClassNames — right before JSX so colors stay consistent
|
|
383
|
+
const c = {
|
|
384
|
+
bg: "bg-white", card: "bg-gray-50", border: "border-gray-200",
|
|
385
|
+
accent: "bg-[#e63946]", text: "text-gray-500",
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// 4. JSX return
|
|
366
389
|
return (
|
|
367
|
-
<div className=
|
|
390
|
+
<div className={`max-w-md mx-auto p-4 ${c.bg} shadow rounded`}>
|
|
368
391
|
<h2 className="text-2xl font-bold mb-4">Todo List</h2>
|
|
369
392
|
<form onSubmit={handleSubmit} className="mb-4">
|
|
370
393
|
<label htmlFor="todo" className="block mb-2 font-semibold">Todo</label>
|
|
371
394
|
<input
|
|
372
|
-
className=
|
|
395
|
+
className={`w-full ${c.border} border rounded px-2 py-1`}
|
|
373
396
|
id="todo"
|
|
374
397
|
type="text"
|
|
375
398
|
onChange={handleInputChange}
|
|
@@ -378,7 +401,7 @@ export default function App() {
|
|
|
378
401
|
</form>
|
|
379
402
|
<ul className="space-y-3">
|
|
380
403
|
{todos.map((doc) => (
|
|
381
|
-
<li className=
|
|
404
|
+
<li className={`flex flex-col items-start p-2 ${c.border} border rounded ${c.card}`} key={doc._id}>
|
|
382
405
|
<div className="flex items-center justify-between w-full">
|
|
383
406
|
<div className="flex items-center">
|
|
384
407
|
<input
|
|
@@ -390,13 +413,13 @@ export default function App() {
|
|
|
390
413
|
<span className="font-medium">{doc.todo}</span>
|
|
391
414
|
</div>
|
|
392
415
|
<button
|
|
393
|
-
className=
|
|
416
|
+
className={`text-sm ${c.accent} text-white px-2 py-1 rounded`}
|
|
394
417
|
onClick={() => database.del(doc._id)}
|
|
395
418
|
>
|
|
396
419
|
Delete
|
|
397
420
|
</button>
|
|
398
421
|
</div>
|
|
399
|
-
<div className=
|
|
422
|
+
<div className={`text-xs ${c.text} mt-1`}>
|
|
400
423
|
{new Date(doc.createdAt).toISOString()}
|
|
401
424
|
</div>
|
|
402
425
|
</li>
|
|
@@ -414,32 +437,53 @@ This React example shows a simple image uploader application that uses Fireproof
|
|
|
414
437
|
Code listing for App.jsx:
|
|
415
438
|
```js
|
|
416
439
|
import { useFireproof, ImgFile } from "use-fireproof";
|
|
417
|
-
import { useState
|
|
440
|
+
import { useState } from "react";
|
|
418
441
|
|
|
419
442
|
export default function App() {
|
|
443
|
+
// 1. Hooks and document shapes
|
|
420
444
|
const { useDocument, useLiveQuery } = useFireproof("image-uploads");
|
|
421
445
|
const { doc, merge, submit } = useDocument({ _files: {}, description: "" });
|
|
422
446
|
const { docs } = useLiveQuery("_id", { descending: true, limit: 5 });
|
|
423
447
|
const [error, setError] = useState(false);
|
|
424
448
|
|
|
449
|
+
// 2. Event handlers
|
|
450
|
+
const handleFileChange = (e) => {
|
|
451
|
+
if (e.target.files[0]) merge({ _files: { uploaded: e.target.files[0] } });
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
const handleUpload = () => {
|
|
455
|
+
if (doc.description.trim()) {
|
|
456
|
+
submit();
|
|
457
|
+
} else {
|
|
458
|
+
setError(true);
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
// 3. ClassNames
|
|
463
|
+
const c = {
|
|
464
|
+
bg: "bg-white", card: "bg-gray-50",
|
|
465
|
+
accent: "bg-blue-500 hover:bg-blue-600", text: "text-gray-700",
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
// 4. JSX return
|
|
425
469
|
return (
|
|
426
|
-
<div className=
|
|
470
|
+
<div className={`p-6 max-w-lg mx-auto ${c.bg} shadow-lg rounded-lg`}>
|
|
427
471
|
<h2 className="text-2xl font-bold mb-4">Image Uploader</h2>
|
|
428
|
-
<input type="file" accept="image/*" onChange={
|
|
429
|
-
<input
|
|
430
|
-
type="text"
|
|
431
|
-
placeholder="Enter description"
|
|
432
|
-
value={doc.description}
|
|
433
|
-
onChange={e => {setError(false); merge({ description: e.target.value });}}
|
|
472
|
+
<input type="file" accept="image/*" onChange={handleFileChange} className="mb-2 border p-2 w-full rounded" />
|
|
473
|
+
<input
|
|
474
|
+
type="text"
|
|
475
|
+
placeholder="Enter description"
|
|
476
|
+
value={doc.description}
|
|
477
|
+
onChange={e => { setError(false); merge({ description: e.target.value }); }}
|
|
434
478
|
className={`w-full p-2 border rounded mb-4 ${error ? "border-red-500" : "border-gray-300"}`}
|
|
435
479
|
/>
|
|
436
|
-
<button onClick={
|
|
480
|
+
<button onClick={handleUpload} className={`px-4 py-2 ${c.accent} text-white rounded`}>Upload</button>
|
|
437
481
|
<h3 className="text-lg font-semibold mt-6">Recent Uploads</h3>
|
|
438
482
|
<div className="grid grid-cols-2 gap-4 mt-2">
|
|
439
483
|
{docs.map(doc => (
|
|
440
|
-
<div key={doc._id} className=
|
|
484
|
+
<div key={doc._id} className={`border p-2 rounded shadow-sm ${c.card}`}>
|
|
441
485
|
{doc._files?.uploaded && <ImgFile file={doc._files.uploaded} alt="Uploaded Image" className="w-full h-auto rounded" />}
|
|
442
|
-
<p className=
|
|
486
|
+
<p className={`text-sm ${c.text} mt-2`}>{doc.description || "No description"}</p>
|
|
443
487
|
</div>
|
|
444
488
|
))}
|
|
445
489
|
</div>
|
package/llms/three-js.md
CHANGED
|
@@ -1050,6 +1050,16 @@ composer.addPass(new OutputPass());
|
|
|
1050
1050
|
|
|
1051
1051
|
_This guide focuses on Three.js's most impressive capabilities. Each example demonstrates advanced techniques that create visually stunning results with minimal code complexity._
|
|
1052
1052
|
|
|
1053
|
+
### Code Structure for Three.js + React Apps
|
|
1054
|
+
|
|
1055
|
+
Structure your component in this order:
|
|
1056
|
+
|
|
1057
|
+
1. **Three.js helper functions** — scene setup, object creation, animation loops separate from React
|
|
1058
|
+
2. **Hooks and state** — useFireproof, useRef for canvas/scene, useState for UI controls
|
|
1059
|
+
3. **Effects** — useEffect to initialize scene on mount, update on parameter changes, cleanup on unmount
|
|
1060
|
+
4. **ClassNames object** — colors, sizes right before JSX so they stay consistent
|
|
1061
|
+
5. **JSX return** — canvas element with refs, UI controls referencing classNames
|
|
1062
|
+
|
|
1053
1063
|
# Real world example
|
|
1054
1064
|
|
|
1055
1065
|
```javascript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/prompts",
|
|
3
|
-
"version": "2.0.0-dev-cli-
|
|
3
|
+
"version": "2.0.0-dev-cli-f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"description": "",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@adviser/cement": "~0.5.34",
|
|
27
|
-
"@fireproof/core": "~0.24.
|
|
28
|
-
"@fireproof/core-keybag": "~0.24.
|
|
29
|
-
"@fireproof/core-runtime": "~0.24.
|
|
30
|
-
"@fireproof/core-types-base": "~0.24.
|
|
31
|
-
"@fireproof/core-types-protocols-cloud": "~0.24.
|
|
32
|
-
"@fireproof/use-fireproof": "~0.24.
|
|
33
|
-
"@vibes.diy/call-ai-v2": "^2.0.0-dev-cli-
|
|
34
|
-
"@vibes.diy/use-vibes-types": "^2.0.0-dev-cli-
|
|
27
|
+
"@fireproof/core": "~0.24.15",
|
|
28
|
+
"@fireproof/core-keybag": "~0.24.15",
|
|
29
|
+
"@fireproof/core-runtime": "~0.24.15",
|
|
30
|
+
"@fireproof/core-types-base": "~0.24.15",
|
|
31
|
+
"@fireproof/core-types-protocols-cloud": "~0.24.15",
|
|
32
|
+
"@fireproof/use-fireproof": "~0.24.15",
|
|
33
|
+
"@vibes.diy/call-ai-v2": "^2.0.0-dev-cli-f",
|
|
34
|
+
"@vibes.diy/use-vibes-types": "^2.0.0-dev-cli-f",
|
|
35
35
|
"arktype": "~2.2.0",
|
|
36
36
|
"json-schema-faker": "~0.6.0"
|
|
37
37
|
},
|
package/prompts.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UserSettings } from "./settings.js";
|
|
2
2
|
import { Result } from "@adviser/cement";
|
|
3
3
|
import { LlmCatalogEntry } from "./json-docs.js";
|
|
4
|
+
import { ChatMessage } from "@vibes.diy/call-ai-v2";
|
|
4
5
|
export declare const DEFAULT_CODING_MODEL: "anthropic/claude-opus-4.5";
|
|
5
6
|
export declare function normalizeModelId(id: unknown): string | undefined;
|
|
6
7
|
export declare function isPermittedModelId(id: unknown): id is string;
|
|
@@ -20,13 +21,10 @@ interface LlmSelectionOptions {
|
|
|
20
21
|
readonly appMode?: "test" | "production";
|
|
21
22
|
fetch?: typeof fetch;
|
|
22
23
|
readonly callAi: {
|
|
23
|
-
ModuleAndOptionsSelection(msgs:
|
|
24
|
+
ModuleAndOptionsSelection(msgs: ChatMessage[]): Promise<Result<string>>;
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
export declare function generateImportStatements(llms: LlmCatalogEntry[]): string;
|
|
27
|
-
export declare function getSkillText(name: string): Promise<string>;
|
|
28
28
|
export declare function makeBaseSystemPrompt(model: string, sessionDoc: Partial<UserSettings> & LlmSelectionOptions): Promise<SystemPromptResult>;
|
|
29
|
-
export declare
|
|
30
|
-
structure: string[];
|
|
31
|
-
};
|
|
29
|
+
export declare function getSkillText(name: string): Promise<string>;
|
|
32
30
|
export {};
|
package/prompts.js
CHANGED
|
@@ -28,7 +28,7 @@ export async function resolveEffectiveModel(settingsDoc, vibeDoc) {
|
|
|
28
28
|
return defaultCodingModel();
|
|
29
29
|
}
|
|
30
30
|
export async function getDefaultDependencies() {
|
|
31
|
-
return ["fireproof", "callai"];
|
|
31
|
+
return ["fireproof", "callai", "web-audio"];
|
|
32
32
|
}
|
|
33
33
|
async function detectModulesInHistory(history, _opts) {
|
|
34
34
|
const detected = new Set();
|
|
@@ -119,18 +119,6 @@ export function generateImportStatements(llms) {
|
|
|
119
119
|
.join("");
|
|
120
120
|
}
|
|
121
121
|
const keyedLoadAsset = new KeyedResolvOnce();
|
|
122
|
-
export async function getSkillText(name) {
|
|
123
|
-
const rText = await keyedLoadAsset.get(name).once(async () => {
|
|
124
|
-
return loadAsset(`./llms/${name}.txt`, {
|
|
125
|
-
fallBackUrl: "https://esm.sh/@vibes.diy/prompts/",
|
|
126
|
-
basePath: () => import.meta.url,
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
if (rText.isErr()) {
|
|
130
|
-
return Promise.reject(rText.Err());
|
|
131
|
-
}
|
|
132
|
-
return rText.Ok();
|
|
133
|
-
}
|
|
134
122
|
export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
135
123
|
const userPrompt = sessionDoc?.userPrompt || "";
|
|
136
124
|
const history = Array.isArray(sessionDoc?.history) ? sessionDoc.history : [];
|
|
@@ -164,7 +152,6 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
164
152
|
fallBackUrl: "https://esm.sh/@vibes.diy/prompts/",
|
|
165
153
|
basePath: () => {
|
|
166
154
|
const dir = import.meta.url;
|
|
167
|
-
console.log("Base path for loading LLM text asset:", llm.name, dir);
|
|
168
155
|
return dir;
|
|
169
156
|
},
|
|
170
157
|
mock: {
|
|
@@ -183,19 +170,21 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
183
170
|
const concatenatedLlmsTxt = concatenatedLlmsTxts.join("\n");
|
|
184
171
|
const stylePrompt = sessionDoc?.stylePrompt || defaultStylePrompt;
|
|
185
172
|
const demoDataLines = includeDemoData
|
|
186
|
-
? `- If your app has a function that uses callAI with a schema to save data, include a Demo Data button that calls that function with an example prompt. Don't write an extra function, use real app code so the data illustrates what it looks like to use the app.\n- Never have
|
|
173
|
+
? `- If your app has a function that uses callAI with a schema to save data, include a Demo Data button that calls that function with an example prompt. Don't write an extra function, use real app code so the data illustrates what it looks like to use the app.\n- Never have an instance of callAI that is only used to generate demo data, always use the same calls that are triggered by user actions in the app.\n`
|
|
187
174
|
: "";
|
|
188
175
|
const systemPromptLines = [
|
|
189
176
|
"You are an AI assistant tasked with creating React components. You should create components that:",
|
|
190
|
-
"- Use modern React practices and follow the
|
|
177
|
+
"- Use modern React practices and follow the Rules of Hooks: never call hooks (useState, useDocument, useLiveQuery, etc.) inside event handlers, loops, conditions, or nested functions. To update an existing document in a click handler, use `database.put({ ...doc, fieldName: newValue })` instead of useDocument.",
|
|
191
178
|
"- Don't use any TypeScript, just use JavaScript",
|
|
192
|
-
"- Use Tailwind CSS for mobile-first accessible styling",
|
|
179
|
+
"- Use Tailwind CSS for mobile-first accessible styling with bracket notation for custom colors like bg-[#242424]",
|
|
180
|
+
"- Define a classNames object (e.g. `const c = { bg: 'bg-[#f1f5f9]', ink: 'text-[#0f172a]', border: 'border-[#0f172a]', accent: 'bg-[#0f172a]' }`) just before the JSX return, then use them like `className={c.ink}`. Never put raw bracket colors directly in JSX — always go through the classNames object.",
|
|
193
181
|
`- Don't use words from the style prompt in your copy: ${stylePrompt}`,
|
|
194
182
|
"- For dynamic components, like autocomplete, don't use external libraries, implement your own",
|
|
195
183
|
"- Avoid using external libraries unless they are essential for the component to function",
|
|
196
184
|
"- Always import the libraries you need at the top of the file",
|
|
185
|
+
"- 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.",
|
|
197
186
|
"- Use Fireproof for data persistence",
|
|
198
|
-
"- Use `callAI` to fetch AI
|
|
187
|
+
"- Use `callAI` to fetch AI, use schema like this: `JSON.parse(await callAI(prompt, { schema: { properties: { todos: { type: 'array', items: { type: 'string' } } } } }))` and save final responses as individual Fireproof documents.",
|
|
199
188
|
"- For file uploads use drag and drop and store using the `doc._files` API",
|
|
200
189
|
"- Don't try to generate png or base64 data, use placeholder image APIs instead, like https://picsum.photos/400 where 400 is the square size",
|
|
201
190
|
"- Consider and potentially reuse/extend code from previous responses if relevant",
|
|
@@ -205,7 +194,7 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
205
194
|
"- Keep the database name stable as you edit the code",
|
|
206
195
|
"- The system can send you crash reports, fix them by simplifying the affected code",
|
|
207
196
|
"- List data items on the main page of your app so users don't have to hunt for them",
|
|
208
|
-
"- If you save data, make sure it is
|
|
197
|
+
"- If you save data, make sure it is browsable in the app, eg lists should be clickable for more details",
|
|
209
198
|
demoDataLines,
|
|
210
199
|
];
|
|
211
200
|
const systemPrompt = [
|
|
@@ -213,14 +202,12 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
213
202
|
"",
|
|
214
203
|
concatenatedLlmsTxt,
|
|
215
204
|
"",
|
|
216
|
-
"## ImgGen Component",
|
|
217
|
-
"",
|
|
218
|
-
"You should use this component in all cases where you need to generate or edit images. It is a React component that provides a UI for image generation and editing. Make sure to pass the database prop to the component. If you generate images, use a live query to list them (with type 'image') in the UI. The best usage is to save a document with a string field called `prompt` (which is sent to the generator) and an optional `doc._files.original` image and pass the `doc._id` to the component via the `_id` prop. It will handle the rest.",
|
|
219
|
-
"",
|
|
220
205
|
...(userPrompt ? [userPrompt, ""] : []),
|
|
221
|
-
"IMPORTANT: You are working in one JavaScript file
|
|
206
|
+
"IMPORTANT: You are working in one JavaScript file. Define a classNames object just before the JSX return for colors and repeated styles, then reference it in your JSX.",
|
|
222
207
|
"",
|
|
223
|
-
"
|
|
208
|
+
"Before writing code, provide a title and brief description of the app. Then list the top 3 features that are the best fit for a mobile web database with real-time collaboration and describe a short planned workflow showing how those features connect into a coherent user experience.",
|
|
209
|
+
"",
|
|
210
|
+
"Then write the full component code block. After the code block, add a short message (1-2 sentences) describing the core workflow the app supports.",
|
|
224
211
|
"",
|
|
225
212
|
"Begin the component with the import statements. Use react and the following libraries:",
|
|
226
213
|
"",
|
|
@@ -238,7 +225,16 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
238
225
|
model,
|
|
239
226
|
};
|
|
240
227
|
}
|
|
241
|
-
export
|
|
242
|
-
|
|
243
|
-
}
|
|
228
|
+
export async function getSkillText(name) {
|
|
229
|
+
const rText = await keyedLoadAsset.get(name).once(async () => {
|
|
230
|
+
return loadAsset(`./llms/${name}.txt`, {
|
|
231
|
+
fallBackUrl: "https://esm.sh/@vibes.diy/prompts/",
|
|
232
|
+
basePath: () => import.meta.url,
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
if (rText.isErr()) {
|
|
236
|
+
return Promise.reject(rText.Err());
|
|
237
|
+
}
|
|
238
|
+
return rText.Ok();
|
|
239
|
+
}
|
|
244
240
|
//# sourceMappingURL=prompts.js.map
|
package/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../jsr/prompts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAU,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAmB,MAAM,gBAAgB,CAAC;AAGpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAAoC,CAAC;AAGzE,MAAM,kBAAkB,GAAG,eAAwB,CAAC;AAEpD,KAAK,UAAU,kBAAkB;IAC/B,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,SAAS,wBAAwB,CAAC,EAAW;IAC3C,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC7C,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAW;IAC1C,OAAO,wBAAwB,CAAC,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAW;IAC5C,OAAO,OAAO,wBAAwB,CAAC,EAAE,CAAC,KAAK,QAAQ,CAAC;AAC1D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,WAAgC,EAChC,OAAoC;IAEpC,MAAM,aAAa,GAAG,wBAAwB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACvE,IAAI,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C,CAAC,EAAE,CAAC;QACvC,yKAAyK;QACzK,EAAE;QACF,4RAA4R;QAC5R,EAAE;QACF,oJAAoJ;QACpJ,EAAE;QACF,wFAAwF;QACxF,EAAE;QACF,OAAO;QACP,qCAAqC,wBAAwB,CAAC,UAAU,CAAC,EAAE;QAC3E,EAAE;QACF,sCAAsC;QACtC,KAAK;QACL,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO;QACL,YAAY;QACZ,YAAY,EAAE,aAAa;QAC3B,QAAQ,EAAE,eAAe;QACzB,KAAK;KACN,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;QAC3D,OAAO,SAAS,CAAC,UAAU,IAAI,MAAM,EAAE;YACrC,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,GAAG;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,KAAK,CAAC,EAAE,EAAE,CAAC;AACpB,CAAC"}
|
package/settings.d.ts
CHANGED
|
@@ -2,13 +2,6 @@ export interface HistoryMessage {
|
|
|
2
2
|
role: "user" | "assistant" | "system";
|
|
3
3
|
content: string;
|
|
4
4
|
}
|
|
5
|
-
export interface LlmChatMessage {
|
|
6
|
-
readonly role: "system" | "user" | "assistant";
|
|
7
|
-
readonly content: string | readonly {
|
|
8
|
-
readonly type: string;
|
|
9
|
-
readonly text: string;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
5
|
export interface UserSettings {
|
|
13
6
|
_id: string;
|
|
14
7
|
stylePrompt?: string;
|