Skip to content

Add Ask the Smol lab (search → persona → chat + Gemini adapter + preview fallback) - #152

Merged
tacticalnoot merged 1 commit into
mainfrom
codex/create-ask-the-smol-lab-experiment
May 29, 2026
Merged

Add Ask the Smol lab (search → persona → chat + Gemini adapter + preview fallback)#152
tacticalnoot merged 1 commit into
mainfrom
codex/create-ask-the-smol-lab-experiment

Conversation

@tacticalnoot

Copy link
Copy Markdown
Owner

Motivation

  • Provide a lightweight labs experiment that lets visitors pick any Smol and chat with a compact, fictional "song-spirit" derived from that Smol's metadata.
  • Make the persona-to-model pipeline transparent and inspectable so humans can see the universal system prompt, the per-smol context, and the final composed prompt.
  • Reuse existing Smol data loaders and the repo's Gemini/radio patterns so the feature degrades gracefully if server-side keys are missing.

Description

  • Add a new lab route /labs/ask-the-smol (with /labs/smol-oracle as a redirect) and a Svelte client component AskTheSmolLab.svelte that loads the canonical Smol corpus, supports search/select, shows a selected-smol panel, chat UI, suggested starters, and a collapsible Prompt Inspector.
  • Implement a defensive normalizer normalizeSmol.ts and typed persona package (types.ts + buildSmolPersonaPrompt.ts) that compose the single universal system prompt and a compact SMOL CONTEXT block used for every query.
  • Add a server-side adapter src/pages/api/ask-the-smol.ts that mirrors the existing radio/AI pattern (@google/genai, same-origin guardrails, rate limit) and calls Gemini when GEMINI_API_KEY is present; it returns structured error JSON when the key is missing or the provider call fails.
  • Provide a deterministic, honest local preview fallback (localPreviewReply.ts) so the UX and prompt inspector remain usable without a working LLM, and add a browser-side API client askSmolClient.ts.
  • Register the experiment in labs/registry.json and add documentation docs/labs/ASK_THE_SMOL.md explaining data sources, prompt composition, fallback behavior, safety rules, and testing steps.

Files added or modified (high level): src/pages/labs/ask-the-smol.astro, src/components/labs/AskTheSmolLab.svelte, src/pages/api/ask-the-smol.ts, src/lib/smolPersona/* (types, normalizer, prompt builder, local preview, client), labs/registry.json, and docs/labs/ASK_THE_SMOL.md.

Testing

  • pnpm test (unit tests) passed (all existing automated tests in tests/*.test.js ran and passed).
  • pnpm build completed successfully; the build emitted existing repo warnings (large chunks and a few module warnings) but finished without errors.
  • pnpm check (TypeScript/Svelte check) surfaced pre-existing unrelated type errors in other components (these are not introduced by this PR) and therefore failed; the new Ask the Smol files are TypeScript-checked and typed to the repo conventions.

Notes: the runtime dev server was started successfully for manual verification; Gemini was not present in the environment (GEMINI_API_KEY missing), so API calls fall back to the local preview mode; attempting an automated Playwright screenshot in this environment failed due to an external browser download restriction (CDN 403) unrelated to the feature code.


Codex Task

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying smol-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9cdce7a
Status:⚡️  Build in progress...

View logs

@tacticalnoot
tacticalnoot merged commit 385c53f into main May 29, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant