feat: the assistant's Агент and Думать modes as pills; thinking shows folded above the answer

This commit is contained in:
redtea committed 2026-10-15 22:24:29 +03:00
1 parent 847bcd68c0
commit 8d7489b577
3 files changed
+51 -7

No files matched your search

+7
View File
@@ -361,6 +361,9 @@ const aiAgent = `
Режим агента: ты сам ведёшь задачу шаг за шагом. В каждом ответе - коротко, что делаешь, и ровно одно действие. Получив результат, решай следующий шаг.
Когда задача решена (или решить нельзя) - ответь итогом без блоков действий.`
const aiThink = `
Режим размышления: начни ответ строкой ::думаю:: и подумай - разбери задачу, варианты и риски; затем строка ::ответ:: и сам ответ.`
// POST /api/panel/ai/chat - {messages, context}: the answer, streamed as
// plain text. A failure after the start ends the text with "[ошибка: …]".
func (s *Server) handleAIChat(w http.ResponseWriter, r *http.Request) {
@@ -373,6 +376,7 @@ func (s *Server) handleAIChat(w http.ResponseWriter, r *http.Request) {
Messages []aiMsg `json:"messages"`
Context string `json:"context"`
Agent bool `json:"agent"`
Think bool `json:"think"`
}
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20)).Decode(&in); err != nil || len(in.Messages) == 0 {
http.Error(w, "плохой запрос", http.StatusBadRequest)
@@ -412,6 +416,9 @@ func (s *Server) handleAIChat(w http.ResponseWriter, r *http.Request) {
if in.Agent {
system += aiAgent
}
if in.Think {
system += aiThink
}
err := aiStream(r.Context(), s.aiConfig(), system+"\n\n--- Панель сейчас ---\n"+in.Context, in.Messages, emit)
if err != nil && r.Context().Err() == nil {
if !wrote {