Third revision: web search, MCP sign-in, exams, intelligent UI, clarifying questions
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m0s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m0s
- Built-in Parallel web search (keyless; optional sign-in for higher limits and research) with its own settings page; OAuth sign-in (RFC 9728/8414/7591, PKCE, RFC 8707) for any MCP server, with token refresh and pre-registered client support - Friendly tool steps (icon, name, status; details on click) and ids stripped from results; per-chat tool switches; taller thinking box - Exams within classes: exam tabs, scoped lists, uploads, imports and Generate; exam-only material for generation; class setting for what the groups are called - Assistant can ask clarifying questions in an inline form before generating - OpenUI blocks (charts, questions, flashcards, inputs) in assistant, Explain and share chats - Explain beside the quiz on wide screens, grounded in the cited source pages - Quiz results: percentage ring coloured by score band, rainbow at 100 - Share links: assistant button like the owner's, hidden during quizzes; documents readable in the browser - Live draft and library updates over server-sent events Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60cf2322f7
commit
c595e0ff2c
54 changed files with 4710 additions and 387 deletions
|
|
@ -265,7 +265,7 @@ export const generateRequestSchema = z.object({
|
|||
source: z
|
||||
.object({
|
||||
documentIds: z.array(z.string()).max(50).optional(),
|
||||
/** Use every processed document in the class. */
|
||||
/** Use every processed document in the class, or in the exam (folder) when folderId is set. */
|
||||
allClassDocuments: z.boolean().optional(),
|
||||
text: z.string().max(400_000).optional(),
|
||||
quizId: z.string().optional(),
|
||||
|
|
@ -480,7 +480,11 @@ async function gatherSources(app: AppContext, req: GenerateRequest, budgetTokens
|
|||
const inline: string[] = [];
|
||||
|
||||
let documentIds = src.documentIds ?? [];
|
||||
if (src.allClassDocuments && req.classId) {
|
||||
if (src.allClassDocuments && req.folderId) {
|
||||
// An exam's material only: generating for Exam 2 never draws on Exam 1's slides.
|
||||
documentIds = db.all<{ id: string }>(`SELECT id FROM documents WHERE folder_id = ? AND status = 'ready' AND chunk_count > 0 ORDER BY sort_order, created_at`, req.folderId).map((d) => d.id);
|
||||
if (documentIds.length === 0) throw badRequest('This exam has no processed documents yet. Upload its slides or notes first, or choose documents yourself.');
|
||||
} else if (src.allClassDocuments && req.classId) {
|
||||
documentIds = db.all<{ id: string }>(`SELECT id FROM documents WHERE class_id = ? AND status = 'ready' AND chunk_count > 0 ORDER BY sort_order, created_at`, req.classId).map((d) => d.id);
|
||||
}
|
||||
if (documentIds.length > 0) {
|
||||
|
|
@ -520,8 +524,9 @@ async function gatherSources(app: AppContext, req: GenerateRequest, budgetTokens
|
|||
);
|
||||
}
|
||||
if (src.weakAreas) {
|
||||
const ids = missedQuestionIds(db, { classId: req.classId ?? undefined }, 40);
|
||||
const topics = weakTopics(db, { classId: req.classId ?? undefined }, 10);
|
||||
const scope = { classId: req.classId ?? undefined, folderId: req.folderId ?? undefined };
|
||||
const ids = missedQuestionIds(db, scope, 40);
|
||||
const topics = weakTopics(db, scope, 10);
|
||||
if (ids.length === 0 && topics.length === 0) throw badRequest('There is not enough quiz history yet to find weak areas. Take a few quizzes first.');
|
||||
const missed = ids
|
||||
.map((id) => db.get<{ stem: string; topic: string; rationale: string }>('SELECT stem, topic, rationale FROM questions WHERE id = ?', id))
|
||||
|
|
@ -538,7 +543,8 @@ async function gatherSources(app: AppContext, req: GenerateRequest, budgetTokens
|
|||
// Pull supporting passages from the class documents for those topics.
|
||||
if (req.classId && out.groups.length === 0) {
|
||||
const query = [...topics.map((t) => t.topic), ...missed.slice(0, 10).map((q) => q.topic)].filter(Boolean).join(' ');
|
||||
const hits = query ? await hybridSearch(app, query, { classId: req.classId }, 24) : [];
|
||||
const examDocs = req.folderId ? db.all<{ id: string }>(`SELECT id FROM documents WHERE folder_id = ? AND status = 'ready'`, req.folderId).map((d) => d.id) : [];
|
||||
const hits = query ? await hybridSearch(app, query, examDocs.length ? { documentIds: examDocs } : { classId: req.classId }, 24) : [];
|
||||
if (hits.length > 0) {
|
||||
const perGroup = Math.max(1, Math.ceil(hits.length / groups));
|
||||
for (let i = 0; i < hits.length; i += perGroup) out.groups.push(hits.slice(i, i + perGroup));
|
||||
|
|
@ -700,6 +706,10 @@ const NOTE_TITLES: Record<string, string> = { study_guide: 'study guide', summar
|
|||
export function startGeneration(app: AppContext, input: z.input<typeof generateRequestSchema>, opts: { conversationId?: string | null; origin?: DraftMeta['origin'] } = {}): { draftId: string; done: Promise<DraftDto> } {
|
||||
const req = generateRequestSchema.parse(input);
|
||||
if (req.classId) getClass(app.db, req.classId);
|
||||
if (req.folderId) {
|
||||
const folder = app.db.get<{ class_id: string }>('SELECT class_id FROM folders WHERE id = ?', req.folderId);
|
||||
if (!folder || (req.classId && folder.class_id !== req.classId)) throw badRequest('That exam is not part of this class.');
|
||||
}
|
||||
// Fail fast (before creating a draft) when no model is configured.
|
||||
const resolved = resolveModel(app, 'generate', req.modelId);
|
||||
const draftId = createDraft(app.db, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue