v3: AI SDK pivot — pi removed, Next.js 16 + AI SDK 7 + AI Elements teacher app
The teaching agent no longer runs on pi. Stack: - ToolLoopAgent (ai@7) + OpenRouter (OPENROUTER_API_KEY), model via LH_MODEL, default anthropic/claude-sonnet-4.5 with reasoning tokens - quiz/ask_user_question = client-side tools (no server execute): the call lands as a typed tool part in input-available state; the card grades via src/core/question-core.ts; addToolOutput sends the verdict; the teacher's reaction continues the same assistant message - resume-mid-quiz is free: the pending tool part persists in the transcript - persistence: one JSON per chat (data/chats/), full UIMessage transcripts, saved onFinish (also on abort) - UI: AI Elements (owned copy-paste components, pruned to the five in use) + button-based QuizCard/AnsweredCard (ask answers never graded) - pi fully removed: TUI, extensions, Fastify+WS server, bridge, custom protocol all deleted (recoverable from git history) - tests: question-core units carry over; chat-flow integration drives handleChatRequest with MockLanguageModelV4 (48 tests, zero tokens); render smoke tests guard the cards (renderToStaticMarkup) Carried over unchanged: teacher system prompt, question-core, schema/ ledger/derive/extract pipeline, data model.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { handleChatRequest } from "@/src/server/chat-handler";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
return handleChatRequest(req);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { getChat } from "@/src/store/chats";
|
||||
|
||||
export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const chat = getChat(id);
|
||||
if (!chat) return Response.json({ error: "Not found" }, { status: 404 });
|
||||
return Response.json(chat);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { createChat, listChats, titleFromPrompt } from "@/src/store/chats";
|
||||
|
||||
export async function GET() {
|
||||
return Response.json({ chats: listChats() });
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = (await req.json().catch(() => ({}))) as { title?: unknown };
|
||||
const title = typeof body.title === "string" ? body.title : "";
|
||||
const chat = createChat(titleFromPrompt(title || "Untitled session"));
|
||||
return Response.json({ id: chat.id, title: chat.title });
|
||||
}
|
||||
Reference in New Issue
Block a user