feat: add fission-aware ai prompts
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user