day1
This commit is contained in:
commit
cdcd0fe38e
|
@ -0,0 +1,5 @@
|
||||||
|
go.*
|
||||||
|
*.swp
|
||||||
|
*.patch
|
||||||
|
*.mbox
|
||||||
|
*.pb.go
|
|
@ -0,0 +1,16 @@
|
||||||
|
all: clean chat.pb.go goimports vet
|
||||||
|
echo okay?
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
goimports -w *.go
|
||||||
|
|
||||||
|
chat.pb.go: chat.proto
|
||||||
|
autogenpb --proto chat.proto
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.pb.go *.patch
|
||||||
|
-rm -f go.*
|
||||||
|
|
||||||
|
vet:
|
||||||
|
@GO111MODULE=off go vet
|
||||||
|
@echo this go library package builds okay
|
|
@ -0,0 +1,25 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package chatpb;
|
||||||
|
|
||||||
|
message Row {
|
||||||
|
repeated string fields = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Table {
|
||||||
|
int32 columns = 1;
|
||||||
|
repeated Row rows = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Chat {
|
||||||
|
bool gemini = 1;
|
||||||
|
bool user = 2;
|
||||||
|
string content = 3;
|
||||||
|
Table table = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Chats { // `autogenpb:marshal` `autogenpb:mutex`
|
||||||
|
string uuid = 1; // `autogenpb:uuid:9fd31f10-c25d-4d66-bc8d-5f6eb7c79057`
|
||||||
|
string version = 2; // `autogenpb:version:v0.0.1`
|
||||||
|
repeated Chat Chats = 3; // THIS MUST BE Chat and then Chats
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package chatpb
|
||||||
|
|
||||||
|
import "go.wit.com/log"
|
||||||
|
|
||||||
|
func TestChat() {
|
||||||
|
conversation := NewChats()
|
||||||
|
|
||||||
|
chat := new(Chat)
|
||||||
|
chat.Content = "this was fun"
|
||||||
|
|
||||||
|
t := new(Table)
|
||||||
|
t.Columns = 4
|
||||||
|
// t.Rows = append(t.Rows, []string{"a", "b"})
|
||||||
|
chat.Table = t
|
||||||
|
|
||||||
|
r := new(Row)
|
||||||
|
r.Fields = []string{"a", "b"}
|
||||||
|
t.Rows = append(t.Rows, r)
|
||||||
|
|
||||||
|
r = new(Row)
|
||||||
|
r.Fields = []string{"1", "", "2", "3"}
|
||||||
|
t.Rows = append(t.Rows, r)
|
||||||
|
|
||||||
|
conversation.Append(chat)
|
||||||
|
|
||||||
|
conversation.AddGeminiComment("I like astronomy")
|
||||||
|
|
||||||
|
dump := conversation.FormatTEXT()
|
||||||
|
|
||||||
|
log.Println(dump)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Chats) AddTable() {
|
||||||
|
chat := new(Chat)
|
||||||
|
|
||||||
|
t := new(Table)
|
||||||
|
t.Columns = 4
|
||||||
|
// t.Rows = append(t.Rows, []string{"a", "b"})
|
||||||
|
|
||||||
|
r := new(Row)
|
||||||
|
r.Fields = []string{"a", "b"}
|
||||||
|
t.Rows = append(t.Rows, r)
|
||||||
|
|
||||||
|
r = new(Row)
|
||||||
|
r.Fields = []string{"1", "", "2", "3"}
|
||||||
|
t.Rows = append(t.Rows, r)
|
||||||
|
|
||||||
|
chat.Table = t
|
||||||
|
|
||||||
|
c.Append(chat)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Chats) AddGeminiComment(s string) {
|
||||||
|
chat := new(Chat)
|
||||||
|
|
||||||
|
chat.Gemini = true
|
||||||
|
chat.Content = s
|
||||||
|
|
||||||
|
c.Append(chat)
|
||||||
|
}
|
Loading…
Reference in New Issue