From c83acd3f5749fe240464283a43f8b03797a1b544 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 17 Aug 2025 22:46:25 +0300 Subject: refactor as per manual code reviews --- internal/logging/chatlogger.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 internal/logging/chatlogger.go (limited to 'internal/logging/chatlogger.go') diff --git a/internal/logging/chatlogger.go b/internal/logging/chatlogger.go new file mode 100644 index 0000000..b6b84a3 --- /dev/null +++ b/internal/logging/chatlogger.go @@ -0,0 +1,28 @@ +package logging + +// ChatLogger provides a structured way to log chat interactions. +type ChatLogger struct { + Provider string +} + +// NewChatLogger creates a new ChatLogger for a given provider. +func NewChatLogger(provider string) *ChatLogger { + return &ChatLogger{Provider: provider} +} + +// LogStart logs the beginning of a chat or stream interaction. +func (cl *ChatLogger) LogStart(stream bool, model string, temp float64, maxTokens int, stop []string, messages []struct { + Role string + Content string +}) { + chatOrStream := "chat" + if stream { + chatOrStream = "stream" + } + Logf("llm/"+cl.Provider+" ", "%s start model=%s temp=%.2f max_tokens=%d stop=%d messages=%d", + chatOrStream, model, temp, maxTokens, len(stop), len(messages)) + for i, m := range messages { + Logf("llm/"+cl.Provider+" ", "msg[%d] role=%s size=%d preview=%s%s%s", + i, m.Role, len(m.Content), AnsiCyan, PreviewForLog(m.Content), AnsiBase) + } +} -- cgit v1.2.3