feat: add teaching asset prompts
This commit is contained in:
47
internal/httpapi/teaching_assets.go
Normal file
47
internal/httpapi/teaching_assets.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"tutor/internal/teachingassets"
|
||||
"tutor/internal/workflows"
|
||||
)
|
||||
|
||||
type generateTeachingAssetPromptRequest struct {
|
||||
ConceptID string `json:"concept_id"`
|
||||
AssetType workflows.AssetType `json:"asset_type"`
|
||||
}
|
||||
|
||||
func (h Handler) generateTeachingAssetPrompt(w http.ResponseWriter, r *http.Request) {
|
||||
if h.assets == nil {
|
||||
writeError(w, http.StatusNotFound, "teaching assets not configured")
|
||||
return
|
||||
}
|
||||
|
||||
var req generateTeachingAssetPromptRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
prompt, err := h.assets.GeneratePrompt(teachingassets.GenerateInput{
|
||||
ConceptID: req.ConceptID,
|
||||
AssetType: req.AssetType,
|
||||
})
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusCreated, prompt)
|
||||
}
|
||||
|
||||
func (h Handler) getTeachingAssets(w http.ResponseWriter, _ *http.Request) {
|
||||
if h.assets == nil {
|
||||
writeError(w, http.StatusNotFound, "teaching assets not configured")
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, h.assets.Snapshot())
|
||||
}
|
||||
Reference in New Issue
Block a user