more stuff for importing JSON output from gemini-cli
This commit is contained in:
parent
559e276c44
commit
49ad81bc27
|
@ -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
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -78,7 +78,7 @@ func (c *Chat) PrintChatGeminiTable() {
|
||||||
|
|
||||||
// print the header
|
// print the header
|
||||||
args := []string{"uuid", "age", "ID", "Who", "model", "", "", "", "", ""}
|
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))
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
||||||
|
|
||||||
for _, e := range c.GetEntries() {
|
for _, e := range c.GetEntries() {
|
||||||
|
@ -94,7 +94,11 @@ func (c *Chat) PrintChatGeminiTable() {
|
||||||
}
|
}
|
||||||
if e.GetContentFile() != "" {
|
if e.GetContentFile() != "" {
|
||||||
parts := strings.Split(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, "", "", "", "", ""}
|
args = []string{e.Uuid, age, id, e.From.String(), model, "", "", "", "", ""}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue