106 lines
2.7 KiB
Go
106 lines
2.7 KiB
Go
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
|
|
|
|
package chatpb
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
|
|
"go.wit.com/lib/cobol"
|
|
"go.wit.com/lib/gui/shell"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
func (all *Chats) PrintHumanTable() {
|
|
log.DaemonMode(true)
|
|
|
|
// print the header
|
|
args := []string{"uuid", "name", "age", "master", "devel", "user", "curver", "lasttag", "next", "repo type"}
|
|
sizes := []int{40, 40, 6, 4, 4, 4, 4, 4, 4, 4}
|
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
|
|
|
for chat := range all.IterAll() {
|
|
chat.printChatToTable(sizes)
|
|
}
|
|
log.Infof("Total Chats: %d\n", all.Len())
|
|
}
|
|
|
|
func (c *Chat) printChatToTable(sizes []int) {
|
|
var args []string
|
|
age := c.Ctime.AsTime().String()
|
|
args = []string{c.Uuid, age, c.GetChatName(), "", "", "", "", "", "", ""}
|
|
|
|
start := cobol.StandardTableSize10(sizes, args)
|
|
|
|
log.Info(start)
|
|
}
|
|
|
|
func (c *Chat) PrintChatStatsTable() {
|
|
log.DaemonMode(true)
|
|
|
|
// print the header
|
|
args := []string{"uuid", "name", "age", "master", "devel", "user", "curver", "lasttag", "next", "repo type"}
|
|
sizes := []int{40, 40, 6, 4, 4, 4, 4, 4, 4, 4}
|
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
|
|
|
for _, e := range c.GetSession() {
|
|
var args []string
|
|
args = []string{e.Uuid, "", "", "", "", "", "", "", "", ""}
|
|
|
|
start := cobol.StandardTableSize10(sizes, args)
|
|
|
|
log.Info(start)
|
|
}
|
|
log.Infof("Total Chats: %d\n", len(c.GetEntries()))
|
|
}
|
|
|
|
func (c *Chat) PrintChatEntriesTable() {
|
|
log.DaemonMode(true)
|
|
|
|
// print the header
|
|
args := []string{"uuid", "age", "con file", "Who", "model", "", "", "", "", ""}
|
|
sizes := []int{40, 16, 8, 4, 8, 2, 2, 2, 2, 2}
|
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
|
|
|
for _, e := range c.GetEntries() {
|
|
var args []string
|
|
age := e.Ctime.AsTime().String()
|
|
args = []string{e.Uuid, age, e.GetContentFile(), e.From.String(), "", "", "", "", "", ""}
|
|
|
|
start := cobol.StandardTableSize10(sizes, args)
|
|
log.Info(start)
|
|
}
|
|
log.Infof("Total Chats: %d\n", len(c.GetEntries()))
|
|
}
|
|
|
|
func (c *Chat) PrintChatGeminiTable() {
|
|
log.DaemonMode(true)
|
|
|
|
// print the header
|
|
args := []string{"uuid", "age", "ID", "Who", "model", "", "", "", "", ""}
|
|
sizes := []int{40, 5, 5, 8, 12, 2, 2, 2, 2, 2}
|
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
|
|
|
for _, e := range c.GetEntries() {
|
|
var args []string
|
|
dur := time.Since(e.Ctime.AsTime())
|
|
age := shell.FormatDuration(dur)
|
|
var model string
|
|
var id string
|
|
if e.GeminiRequest == nil {
|
|
model = "nil"
|
|
} else {
|
|
model = e.GeminiRequest.Model
|
|
}
|
|
if e.GetContentFile() != "" {
|
|
parts := strings.Split(e.GetContentFile(), ".")
|
|
id = parts[3]
|
|
}
|
|
args = []string{e.Uuid, age, id, e.From.String(), model, "", "", "", "", ""}
|
|
|
|
start := cobol.StandardTableSize10(sizes, args)
|
|
log.Info(start, e.GetContentFile())
|
|
}
|
|
log.Infof("Total Chats: %d\n", len(c.GetEntries()))
|
|
}
|