feat: add fission-aware ai prompts

This commit is contained in:
Naeel
2026-04-28 07:31:19 +03:00
parent 9168fc2d9e
commit 82eba079f6
4 changed files with 529 additions and 18 deletions
+5 -13
View File
@@ -142,26 +142,18 @@ func (s *Server) handleAIAsk(w http.ResponseWriter, r *http.Request) {
return
}
var req struct {
Question string `json:"question"`
}
var req aiPromptRequest
if err := json.NewDecoder(io.LimitReader(r.Body, 4*1024)).Decode(&req); err != nil {
writeJSONError(w, http.StatusBadRequest, "invalid JSON: "+err.Error())
return
}
if strings.TrimSpace(req.Question) == "" {
writeJSONError(w, http.StatusBadRequest, "question is required")
chatReq, err := buildLLMChatRequest(req)
if err != nil {
writeJSONError(w, http.StatusBadRequest, err.Error())
return
}
body, _ := json.Marshal(map[string]any{
"model": "gpt-oss-120b",
"messages": []map[string]string{
{"role": "system", "content": "Ты умный ассистент. Отвечай кратко и по делу."},
{"role": "user", "content": req.Question},
},
"max_tokens": 1024,
})
body, _ := json.Marshal(chatReq)
ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
defer cancel()