summaryrefslogtreecommitdiff
path: root/internal/logging/chatlogger.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/logging/chatlogger.go')
-rw-r--r--internal/logging/chatlogger.go28
1 files changed, 28 insertions, 0 deletions
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)
+ }
+}