summaryrefslogtreecommitdiff
path: root/humanTable.go
blob: 689677bc17b82afc11356b3c004eb17b6b2daa7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// 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, 16, 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(), ".")
			if len(parts) < 4 {
				id = "??"
			} else {
				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()))
}

func (gr *GeminiRequest) PrintGeminiTable() {
	if gr == nil {
		return
	}
	log.DaemonMode(true)

	// print the header
	args := []string{"model", "what", "age", "cId", "partId", "", "", "", "", ""}
	sizes := []int{16, 8, 4, 4, 4, 16, 120, 2, 2, 2}
	log.Info(cobol.StandardTableSize10(sizes, args))

	var countCONTENTS int
	var countPARTS int
	for x, c := range gr.GetContents() {
		model := gr.Model
		cId := log.Sprintf("%d", x)
		countCONTENTS += 1
		for i, p := range c.GetParts() {
			var args []string
			partId := log.Sprintf("%d", i)

			// removes newline chars from the text
			parts := strings.Split(p.GetText(), "\n")
			txt := strings.Join(parts, "__")

			what := "TXT"

			if fc := p.GetFunctionCall(); fc != nil {
				what = "FuncCall"
				txt = log.Sprintf("%s, %v", fc.Name, fc.Args)

			}
			if fr := p.GetFunctionResponse(); fr != nil {
				what = "FuncResp"
				txt = fr.Name
				txt = log.Sprintf("%s %s, %v", fr.Id, fr.Name, fr.Response)
			}

			args = []string{model, what, "", cId, partId, p.ThoughtSignature, txt, "", "", ""}

			start := cobol.StandardTableSize10(sizes, args)
			log.Info(start)
			countPARTS += 1
		}
	}
	log.Infof("Total Contents (%d) Parts (%d)\n", countCONTENTS, countPARTS)
}