@vibes.diy/prompts 14.3.271 → 14.3.273
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/backend.md +1 -1
- package/llms/youtube.md +57 -1
- package/package.json +5 -5
package/llms/backend.md
CHANGED
|
@@ -178,7 +178,7 @@ const yt = await ctx.youtube.fetch("/channels?part=statistics&forHandle=@name");
|
|
|
178
178
|
const budget = await ctx.youtube.status(); // { available, unitsLeftToday, dailyUnits } — spends nothing
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
- An app that reads YouTube numbers loads the `youtube` skill: `ctx.youtube.fetch` for `channels`, `videos`, `playlistItems` and `
|
|
181
|
+
- An app that reads YouTube numbers loads the `youtube` skill: `ctx.youtube.fetch` for `channels`, `videos`, `playlistItems`, `playlists` and `commentThreads` (what viewers are saying), the app's daily unit budget and its `over_budget` refusal, and the evening-and-morning sampling behind an overnight recap.
|
|
182
182
|
|
|
183
183
|
- An app that takes money loads the `stripe` skill (one-time charges) or the `stripe-subscriptions` skill (recurring): the Connect Stripe setup item, `ctx.stripe.fetch` with the order's `mode` on every call, hosted Checkout and a complete example.
|
|
184
184
|
- The account a charge uses is the owner's per-app choice, a `setup:live` document the owner writes from the Setup screen; `ctx.stripe.status()` says which accounts are ready, and a ready live account alone leaves the app in test. The `stripe` skill carries that choice, the Setup screen and the sweep for buyers who never come back.
|
package/llms/youtube.md
CHANGED
|
@@ -5,7 +5,7 @@ channel's uploads inside the page needs no key, no backend and no setup: it is
|
|
|
5
5
|
YouTube's own player in a frame, and section 0 is all of it. **Counting** a
|
|
6
6
|
channel (subscribers, views, which videos picked up overnight) is the **YouTube
|
|
7
7
|
Data API v3**, read from `backend.js` with `ctx.youtube.fetch`. Vibes holds the
|
|
8
|
-
key, so the owner pastes a channel link and the numbers arrive; sections 1–
|
|
8
|
+
key, so the owner pastes a channel link and the numbers arrive; sections 1–9 are
|
|
9
9
|
the recipe that keeps the budget comfortable and the numbers honest. Build the
|
|
10
10
|
first for "show our videos", "my band's page", "a playlist of clips"; build the
|
|
11
11
|
second when the ask is about the numbers.
|
|
@@ -271,6 +271,62 @@ Google Cloud key instead: the owner saves it in Settings → Secrets as
|
|
|
271
271
|
with `ctx.fetch`, adding `key=` from `ctx.secrets`, exactly as the owner-key
|
|
272
272
|
services do. Build it that way only when the app's own numbers ask for it.
|
|
273
273
|
|
|
274
|
+
## 9. What commenters are talking about
|
|
275
|
+
|
|
276
|
+
One page of a video's top-level comments, the most relevant first, as plain
|
|
277
|
+
text:
|
|
278
|
+
|
|
279
|
+
```js
|
|
280
|
+
const res = await ctx.youtube.fetch(
|
|
281
|
+
`/commentThreads?part=snippet&videoId=${videoId}&maxResults=100&order=relevance&textFormat=plainText`
|
|
282
|
+
);
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Each item's words are `snippet.topLevelComment.snippet.textDisplay`, with
|
|
286
|
+
`likeCount` beside them; `nextPageToken` reads the next 100. A page is **1 unit**,
|
|
287
|
+
so one page each for a channel's 10 latest uploads is 10 units a day.
|
|
288
|
+
|
|
289
|
+
A video whose comments are turned off answers commentThreads with a 403 whose reason is commentsDisabled; the app labels that video "Comments are off" and moves on, never treating it as an error.
|
|
290
|
+
|
|
291
|
+
```js
|
|
292
|
+
if (res.status === 403 && (await res.clone().json()).error?.errors?.[0]?.reason === "commentsDisabled") {
|
|
293
|
+
return { videoId, commentsOff: true };
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Themes across a channel's recent videos come from the daily job, in one
|
|
298
|
+
`ctx.callAI` call (the backend docs' server-side AI call, 5 calls and about
|
|
299
|
+
64k characters per run):
|
|
300
|
+
|
|
301
|
+
1. Once a day in the scheduled tick (the morning full reading in section 5
|
|
302
|
+
already has the latest uploads), read one comment page for each of the
|
|
303
|
+
5–10 newest videos.
|
|
304
|
+
2. Keep a compact sample in memory for this run only: the 20 most-liked
|
|
305
|
+
comments per video, each cut to 200 characters. Ten videos stay near 40k
|
|
306
|
+
characters.
|
|
307
|
+
3. Ask `ctx.callAI` with a `schema` for 3–5 themes, each with a short label, a
|
|
308
|
+
one-sentence summary and the video ids it came from, then `JSON.parse` the
|
|
309
|
+
string it returns.
|
|
310
|
+
4. Store the themes (``_id: `themes-${channelId}-${day}` ``, `type: "themes"`),
|
|
311
|
+
each video's comment count, and `commentsOff` for the videos that have it.
|
|
312
|
+
The comment text itself stays in the run and is never written, and the
|
|
313
|
+
28-day sweep in section 5 deletes theme docs with the samples.
|
|
314
|
+
|
|
315
|
+
```js
|
|
316
|
+
const themes = JSON.parse(await ctx.callAI(
|
|
317
|
+
`Viewer comments on a YouTube channel's latest videos, grouped by video id:\n${JSON.stringify(sample)}\n` +
|
|
318
|
+
"Name the 3-5 things viewers talk about most.",
|
|
319
|
+
{ schema: { properties: { themes: { type: "array", items: { type: "object", properties: {
|
|
320
|
+
label: { type: "string" }, summary: { type: "string" }, videoIds: { type: "array", items: { type: "string" } },
|
|
321
|
+
} } } }, required: ["themes"] } }
|
|
322
|
+
)).themes;
|
|
323
|
+
await ctx.db.put({ _id: `themes-${channelId}-${day}`, type: "themes", channelId, day, themes, commentsOff });
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
A failed `ctx.callAI` throws: keep yesterday's themes on screen and try again
|
|
327
|
+
on the next morning's tick. Visitors read the stored themes doc; only the tick
|
|
328
|
+
spends units and AI credits.
|
|
329
|
+
|
|
274
330
|
## Complete backend.js
|
|
275
331
|
|
|
276
332
|
### `backend.js`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/prompts",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.273",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"exports": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@adviser/cement": "~0.5.34",
|
|
42
|
-
"@vibes.diy/api-types": "14.3.
|
|
43
|
-
"@vibes.diy/call-ai-v2": "14.3.
|
|
44
|
-
"@vibes.diy/identity": "14.3.
|
|
45
|
-
"@vibes.diy/use-vibes-types": "14.3.
|
|
42
|
+
"@vibes.diy/api-types": "14.3.273",
|
|
43
|
+
"@vibes.diy/call-ai-v2": "14.3.273",
|
|
44
|
+
"@vibes.diy/identity": "14.3.273",
|
|
45
|
+
"@vibes.diy/use-vibes-types": "14.3.273",
|
|
46
46
|
"arktype": "~2.2.8",
|
|
47
47
|
"json-schema-faker": "~0.6.3"
|
|
48
48
|
},
|