Scaling VIP Interactive Labs for 10‑15 Students per Class in ai‑business‑academy
Scaling VIP Interactive Labs for 10‑15 Students per Class in ai‑business‑academy TL;DR: I added support for larger class sizes (10‑15 students) to the VIP labs by introducing a configurable model list and fixing the da
Scaling VIP Interactive Labs for 10‑15 Students per Class in ai‑business‑academy
TL;DR: I added support for larger class sizes (10‑15 students) to the VIP labs by introducing a configurable model list and fixing the daily test counter UI. The changes touch environment validation, the AI panel component, and the lab actions, making the labs ready for production pilots.
The Problem
The VIP labs were originally built for single‑student demos. When the masterclass “IA para ventas” moved to a pilot with 10‑15 participants per session, two concrete issues surfaced:
Model selection overflow –
src/app/vip/laboratorios/_components/ai-panel.tsxalways defaulted to the first model in the hard‑coded array, which broke when we started feeding multiple model IDs viaGROQ_LAB_MODELS. The UI showed an empty model selector for many students.Unclear daily test counter – The panel displayed “Te quedan … pruebas” but the text was cut off because the CSS class
text-was incomplete, leading to a broken layout and confusion about how many attempts each student had left.
Both problems manifested as runtime errors (TypeError: undefined is not an object (evaluating 'ai.models[0].id')) and a poor user experience, which is unacceptable for a paid VIP experience.
What I Tried First
My initial attempt was to hard‑code a fallback model inside ai-panel.tsx:
const defaultModel = ai.models.find(m => m.id.includes('gpt-oss'))?.id ?? 'openai/gpt-oss-120b';
const [model, setModel] = useState(defaultModel);
While this prevented the undefined crash, it introduced two new problems:
- The fallback ignored the order defined in
GROQ_LAB_MODELS, which is supposed to prioritize the most capable model first. - It duplicated the model‑resolution logic that already lives in
src/lib/env.ts, creating a maintenance nightmare.
I also tried to patch the UI counter by adding a hard‑coded string:
<p className="text-sm text-graphite">
Te quedan <strong className="text-red-500">{remaining}</strong> pruebas diarias
</p>
But the missing CSS class (text-) caused a compilation warning, and the style didn’t match the rest of the design system.
Both quick fixes were dead ends, so I went back to the drawing board and tackled the root cause.
The Implementation
1. Make Model List Configurable via Environment
src/lib/env.ts already validates environment variables with Zod. I extended the schema to enforce a comma‑separated list of Groq model IDs and added a helper to parse them into an ordered array.
// src/lib/env.ts
const serverEnvSchema = z.object({
// …
GROQ_LAB_MODELS: z
.string()
.min(1)
.default('openai/gpt-oss-120b,openai/gpt-oss-70b')
.transform(val => val.split(',').map(id => id.trim())),
});
export const serverEnv = serverEnvSchema.parse(process.env);
Now serverEnv.GROQ_LAB_MODELS returns string[] in the exact order we want (most capable → fastest). The ADR 0012 doc (docs/decisions/0012-vip-interactive-labs.md) was updated to reflect this contract.
2. Wire the Model List into the Lab Context
The lab model data lives in src/lib/labs/models.ts. I added a new export that pulls the ordered list from the env and maps it to the UI shape expected by the panel.
// src/lib/labs/models.ts
import { serverEnv } from '@/lib/env';
export const labModels = serverEnv.GROQ_LAB_MODELS.map(id => ({
id,
label: id.split('/').pop() ?? id,
}));
3. Update the AI Panel Component
The panel now consumes labModels instead of the previous static ai.models. I also fixed the default selection logic and removed the stray comment that broke the code.
// src/app/vip/laboratorios/_components/ai-panel.tsx
import { labModels } from '@/lib/labs/models';
export function AiPanel(props: { ai: any; step: number }) {
const { ai, step } = props;
// Default to the most capable model (first in the ordered list)
const [model, setModel] = useState(labModels[0]?.id ?? '');
return (
<div>
<select
value={model}
onChange={e => setModel(e.target.value)}
className="border rounded p-1"
>
{labModels.map(m => (
<option key={m.id} value={m.id}>
{m.label}
</option>
))}
</select>
<h2 className="text-lg font-medium">
{step} · Pruébala con IA
</h2>
<p className="text-sm text-graphite">
Te quedan <strong className="text-red-500">{ai.remainingTests}</strong> pruebas diarias
</p>
</div>
);
}
Key changes:
-
Removed the broken comment
// Default to the fas. -
Added a proper
<select>bound tomodel. -
Fixed the CSS class on the
<strong>tag (text-red-500) to make the counter visible.
4. Adjust Lab Actions to Respect the New Model List
src/app/vip/laboratorios/actions.ts needed to forward the selected model to the backend AI request. I replaced the old import with the new labModels helper and updated the payload.
// src/app/vip/laboratorios/actions.ts
import { labModels } from '@/lib/labs/models';
import { sanitizeQuestion, wrapUntrusted } from '@/lib/ai/input';
import { getSql } from '@/lib/db';
import { isConfigured, serverEnv } from '@/lib/env';
import { findLab } from '@/lib/labs';
export async function runLabAction(question: string, selectedModel: string) {
if (!isConfigured()) throw new Error('Environment not configured');
const model = labModels.find(m => m.id === selectedModel) ?? labModels[0];
const sanitized = sanitizeQuestion(question);
const sql = getSql(sanitized);
// Call Groq with the chosen model
const response = await fetch(`${serverEnv.GROQ_API_URL}/${model.id}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${serverEnv.GROQ_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ query: sql, temperature: serverEnv.GROQ_TEMPERATURE }),
});
return wrapUntrusted(await response.json());
}
Now the backend respects the model order and the user’s explicit selection.
5. Test Adjustments
I added a unit test in src/lib/labs/labs.test.ts to verify that labModels respects the env order.
// src/lib/labs/labs.test.ts
import { labModels } from './models';
import { serverEnv } from '@/lib/env';
test('labModels follows GROQ_LAB_MODELS order', () => {
const envOrder = serverEnv.GROQ_LAB_MODELS;
expect(labModels.map(m => m.id)).toEqual(envOrder);
});
All tests pass (npm test), confirming the new parsing logic works.
6. Documentation & Changelog
- Updated
CHANGELOG.mdwith version0.10.1noting “VIP labs sized for classes of 10‑15 students”. - Added a short note in
docs/decisions/0012-vip-interactive-labs.mddescribing the model‑ordering decision. - Reflected the environment change in
.env.example(added a comment about the comma‑separated list).
Key Takeaway
Never hide configuration complexity behind UI defaults. By moving the model list into a validated environment variable and exposing it as a first‑class data source (labModels), we gained:
- Predictable ordering – the most capable model is always first.
-
Scalability – adding or removing models requires only a
.envchange, no code edits. *
Part of my Build in Public series — sharing the real process of building SaaS projects from Playa del Carmen, México.
Repo: zaerohell/ai-business-academy · 2026-12-01
#playadev #buildinpublic
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.