Review recorded explanations of a solution on the site
The admin can upload a recording of themselves explaining a problem's solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and get interview-style feedback, committed as reviews/<id>.md so every attempt is kept. Claude can't take audio, so the recording is transcribed first by an OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY, with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler words and when complexity first comes up are measured from the word timestamps and given to Claude with the timestamped transcript, the statement and optionally the code. The reply covers the verdict, scores in five areas, the approach and its complexity, missed edge cases, delivery and what to work on. Recordings are kept for playback in an S3 bucket (Garage) when the S3_* settings are given, and are thrown away otherwise. Reviews are admin-only. The job runs in the background like Explain, and the statement fetch and save-error handling are now shared between the two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Package handlers is the site's REST API: the problem list and pages (public
|
||||
// for solved problems, everything for the admin), the admin's edits, the
|
||||
// Claude explanations (explain.go), and the Gitea webhook that tells the
|
||||
// server to pull.
|
||||
// Claude explanations (explain.go) and recording reviews (review.go), and
|
||||
// the Gitea webhook that tells the server to pull.
|
||||
package handlers
|
||||
|
||||
import (
|
||||
@@ -49,9 +49,17 @@ type Server struct {
|
||||
// Statements reads a statement from the problem's judge; nil means the
|
||||
// real judges.
|
||||
Statements Fetcher
|
||||
// Transcriber turns review recordings into text; nil when
|
||||
// TRANSCRIBE_API_KEY is not set, which turns reviews off.
|
||||
Transcriber Transcriber
|
||||
// Audio keeps review recordings for playback; nil when the S3_*
|
||||
// settings are not given, and the recordings are then thrown away.
|
||||
Audio AudioStore
|
||||
|
||||
idx atomic.Pointer[index.Index]
|
||||
jobs explain.Jobs
|
||||
idx atomic.Pointer[index.Index]
|
||||
// Separate, so a review and an explanation of one problem can run at
|
||||
// the same time.
|
||||
jobs, reviewJobs explain.Jobs
|
||||
}
|
||||
|
||||
// SetIndex swaps in a freshly built index. repo.Repo calls it (through
|
||||
@@ -85,6 +93,10 @@ func (s *Server) Routes(api *gin.RouterGroup) {
|
||||
admin.GET("/problems/:name/statement/fetch", s.fetchStatement)
|
||||
admin.POST("/problems/:name/explain", s.startExplain)
|
||||
admin.GET("/problems/:name/explain", s.explainStatus)
|
||||
admin.POST("/problems/:name/review", s.startReview)
|
||||
admin.GET("/problems/:name/review", s.reviewStatus)
|
||||
admin.GET("/problems/:name/reviews/:id/audio", s.reviewAudio)
|
||||
admin.DELETE("/problems/:name/reviews/:id", s.deleteReview)
|
||||
api.POST("/hooks/gitea", s.webhook)
|
||||
}
|
||||
|
||||
@@ -123,7 +135,11 @@ func (s *Server) list(ctx *gin.Context) {
|
||||
out := []index.Summary{}
|
||||
for _, p := range idx.Problems {
|
||||
if visible(p, admin) {
|
||||
out = append(out, p.Summary)
|
||||
sum := p.Summary
|
||||
if !admin {
|
||||
sum.ReviewCount = 0
|
||||
}
|
||||
out = append(out, sum)
|
||||
}
|
||||
}
|
||||
sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name })
|
||||
@@ -162,11 +178,12 @@ func (s *Server) get(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
// The statement is the judge's text, kept for the admin and for Claude;
|
||||
// the public page links to the judge instead. The index is shared, so
|
||||
// this blanks a copy.
|
||||
if !admin && p.Statement != "" {
|
||||
// the public page links to the judge instead. Reviews are a transcript
|
||||
// of the admin talking. The index is shared, so this blanks a copy.
|
||||
if !admin && (p.Statement != "" || len(p.Reviews) > 0) {
|
||||
c := *p
|
||||
c.Statement = ""
|
||||
c.Reviews, c.ReviewCount = []index.Review{}, 0
|
||||
p = &c
|
||||
}
|
||||
ctx.JSON(http.StatusOK, p)
|
||||
|
||||
Reference in New Issue
Block a user