feat: let AI chat read lesson video transcripts on demand
Add get_lesson_transcript (teacher) and read_lesson_transcript (student) tools that fetch a lesson's uploaded-video transcript from media_transcript by the video assetIds. The agents call them only when a question is about the video's spoken content, so text-only chats keep a cacheable prefix.
This commit is contained in:
@@ -7,6 +7,7 @@ import * as schema from '@cio/db/schema';
|
||||
import type { AiTutorSettings } from '@cio/ai-assistant';
|
||||
|
||||
import { getLesson } from '@cio/core/services/lesson/lesson';
|
||||
import { getLessonVideoTranscript } from '@cio/core/services/agent/lesson-transcript';
|
||||
import { getExercise } from '@cio/core/services/exercise/exercise';
|
||||
import { listCourseSections } from '@cio/core/services/course/section';
|
||||
import { AppError } from '@api/utils/errors';
|
||||
@@ -191,6 +192,19 @@ export function buildStudentAgentTools(orgId: string, userId: string, courseId:
|
||||
}
|
||||
}),
|
||||
|
||||
read_lesson_transcript: tool({
|
||||
description:
|
||||
"Read the transcript of a lesson's uploaded video(s). A video's spoken content is NOT part of the lesson body, so use this whenever the learner asks about what the video says, explains, or demonstrates. Only uploaded videos are transcribed — embedded links (YouTube, etc.) return no transcript.",
|
||||
inputSchema: readLessonParam,
|
||||
execute: async (args) => {
|
||||
return executeStudentTool('read_lesson_transcript', { orgId, userId, courseId, args }, async () => {
|
||||
await verifyLessonBelongsToCourse(args.lessonId, courseId);
|
||||
|
||||
return getLessonVideoTranscript(args.lessonId, orgId);
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
read_exercise: tool({
|
||||
description:
|
||||
'Read an exercise prompt — the question text and options visible to a student. Answer keys, correct flags, and marking schemes are stripped before returning.',
|
||||
|
||||
Reference in New Issue
Block a user