This commit is contained in:
2026-08-23 20:49:40 +02:00
parent 3b678ca857
commit f3d4fb56ed
31 changed files with 3608 additions and 111 deletions
+13 -4
View File
@@ -140,10 +140,19 @@ func (s *server) handleChatCompletions(w http.ResponseWriter, r *http.Request) {
return
}
system, user := splitMessages(req.Messages)
comp, err := processing.HeuristicCompleter{}.Complete(context.Background(), system, user)
if err != nil {
http.Error(w, `{"error":{"message":"completer failed"}}`, http.StatusInternalServerError)
return
var comp processing.Completion
// A category formula in the prompt is answered in that formula's shape, so a
// local run proves the formula reached the model and the reply passes the
// pipeline's formula gate. Everything else keeps the heuristic fallback.
if text, ok := buildFormulaReply(system, user); ok {
comp = processing.Completion{Text: text}
} else {
var err error
comp, err = processing.HeuristicCompleter{}.Complete(context.Background(), system, user)
if err != nil {
http.Error(w, `{"error":{"message":"completer failed"}}`, http.StatusInternalServerError)
return
}
}
model := strings.TrimSpace(req.Model)
if model == "" {