summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addChat.go28
-rw-r--r--find.go24
-rw-r--r--humanTable.go8
3 files changed, 58 insertions, 2 deletions
diff --git a/addChat.go b/addChat.go
new file mode 100644
index 0000000..972bb42
--- /dev/null
+++ b/addChat.go
@@ -0,0 +1,28 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+package chatpb
+
+import (
+ "time"
+
+ "go.wit.com/log"
+ timestamppb "google.golang.org/protobuf/types/known/timestamppb"
+)
+
+// returns true if the pb was added
+// to indicate that ConfigSave() should be run to write it out to disk
+func (c *Chat) AddGeminiRequest(fname string, age time.Time, pb *GeminiRequest) bool {
+ for _, e := range c.GetEntries() {
+ if e.GetContentFile() == fname {
+ log.Info("fname already here", fname)
+ return false
+ }
+ }
+ e := new(ChatEntry)
+ e.Ctime = timestamppb.New(age)
+ e.From = Who_USER
+ e.ContentFile = fname
+ e.GeminiRequest = pb
+ c.AppendEntry(e)
+ return true
+}
diff --git a/find.go b/find.go
new file mode 100644
index 0000000..8f05871
--- /dev/null
+++ b/find.go
@@ -0,0 +1,24 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+package chatpb
+
+func (all *Chats) FindUuid(id string) *Chat {
+ for chat := range all.IterAll() {
+ if chat.Uuid == id {
+ return chat
+ }
+
+ for _, e := range chat.GetSession() {
+ if id == e.Uuid {
+ return chat
+ }
+ }
+
+ for _, e := range chat.GetEntries() {
+ if id == e.Uuid {
+ return chat
+ }
+ }
+ }
+ return nil
+}
diff --git a/humanTable.go b/humanTable.go
index 29e6411..b134efb 100644
--- a/humanTable.go
+++ b/humanTable.go
@@ -78,7 +78,7 @@ func (c *Chat) PrintChatGeminiTable() {
// print the header
args := []string{"uuid", "age", "ID", "Who", "model", "", "", "", "", ""}
- sizes := []int{40, 5, 5, 8, 12, 2, 2, 2, 2, 2}
+ sizes := []int{40, 5, 5, 8, 16, 2, 2, 2, 2, 2}
log.Info(cobol.StandardTableSize10(sizes, args))
for _, e := range c.GetEntries() {
@@ -94,7 +94,11 @@ func (c *Chat) PrintChatGeminiTable() {
}
if e.GetContentFile() != "" {
parts := strings.Split(e.GetContentFile(), ".")
- id = parts[3]
+ if len(parts) < 4 {
+ id = "??"
+ } else {
+ id = parts[3]
+ }
}
args = []string{e.Uuid, age, id, e.From.String(), model, "", "", "", "", ""}