36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
const quillSystem = `You are Quill crow, the owner's assistant and point of contact in a nest of AI crows.
|
|
Answer the owner in one or two plain sentences. You are text-only: no web, no files, no tools.`
|
|
|
|
// respondQuill answers a message addressed to Quill, the assistant service
|
|
// role (CHATROOM_SPEC section 6). D1: one in-character reply through the
|
|
// flock. Reading the nest for status (D2) and relaying (D3) extend this file.
|
|
func (s *Server) respondQuill(nest Nest, req Message) {
|
|
budget := &Budget{name: "quill-reply", limit: s.p.G.TokenBudgetPerItem}
|
|
system := systemFor("Quill", quillSystem, false)
|
|
prompt := "FROM: " + req.Author + "\nMESSAGE: " + req.Text
|
|
answer, err := s.p.Flock.ask(s.ctx, nil, "Quill", system, prompt, budget)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := Message{
|
|
NestID: nest.ID,
|
|
Kind: "deliver",
|
|
Author: "Quill",
|
|
Text: strings.TrimSpace(answer),
|
|
To: req.Author,
|
|
RefersTo: req.MsgID(),
|
|
TaggedBy: "harness",
|
|
Timestamp: time.Now().UTC().Format(time.RFC3339),
|
|
}
|
|
if record, err := s.msgs.Append(reply); err == nil {
|
|
s.emitNestMessage(record)
|
|
}
|
|
}
|