feat(llm): add LLM call recording with admin panel integration

- llm.Adapter: SetCallLogger hook for recording every API call
- llm.CallLogger: ring-buffer with Recent+Stats for admin API
- main.go: wire DeepSeek adapter to CallLogger
- Fix: single CallLogger instance for both recording and display
- Metrics: model name, duration, success/fail, tokens
- All 16 packages pass
This commit is contained in:
Aska committed 2026-08-12 19:10:51 +08:00
1 parent 5b2bcc9441
commit 6a4887e52a
6 files changed
+131 -67

No files matched your search

@@ -4,7 +4,7 @@ package background
import (
"context"
"log"
"git.yeij.top/AskaEth/Cyrene_v2/internal/logger"
"sync"
"time"
)
@@ -45,19 +45,19 @@ func New(enabled bool, thinkInterval, silenceTimeout time.Duration) *Thinker {
// Start begins the background thinking loops.
func (t *Thinker) Start(ctx context.Context) {
if !t.enabled {
log.Println("[thinker] background thinking disabled")
logger.Info("[thinker] background thinking disabled")
return
}
go t.silenceLoop(ctx)
go t.postChatLoop(ctx)
log.Printf("[thinker] started (interval=%v, silence=%v)", t.thinkInterval, t.silenceTimeout)
logger.Infof("[thinker] started (interval=%v, silence=%v)", t.thinkInterval, t.silenceTimeout)
}
// Stop shuts down the thinker.
func (t *Thinker) Stop() {
close(t.stopCh)
log.Println("[thinker] stopped")
logger.Info("[thinker] stopped")
}
// TriggerPostChat schedules a post-chat think after a conversation.
@@ -140,7 +140,7 @@ func (t *Thinker) generateThought(trigger string, sessionID string) {
}
t.mu.Unlock()
log.Printf("[thinker] %s thought generated for session %s", trigger, sessionID)
logger.Infof("[thinker] %s thought generated for session %s", trigger, sessionID)
}
// RecentThoughts returns the most recent thoughts.