example works

This commit is contained in:
Jeff Carr 2025-08-21 00:52:41 -05:00
parent cdcd0fe38e
commit af57eec691
2 changed files with 48 additions and 18 deletions

View File

@ -11,9 +11,14 @@ message Table {
repeated Row rows = 2; repeated Row rows = 2;
} }
enum Who {
NOONE = 0;
GEMINI = 1;
USER = 2;
}
message Chat { message Chat {
bool gemini = 1; Who from = 1;
bool user = 2;
string content = 3; string content = 3;
Table table = 4; Table table = 4;
} }

View File

@ -5,23 +5,31 @@ import "go.wit.com/log"
func TestChat() { func TestChat() {
conversation := NewChats() conversation := NewChats()
chat := new(Chat) /*
chat.Content = "this was fun" chat := new(Chat)
chat.Content = "this was fun"
t := new(Table) t := new(Table)
t.Columns = 4 t.Columns = 4
// t.Rows = append(t.Rows, []string{"a", "b"}) // t.Rows = append(t.Rows, []string{"a", "b"})
chat.Table = t chat.Table = t
r := new(Row) r := new(Row)
r.Fields = []string{"a", "b"} r.Fields = []string{"a", "b"}
t.Rows = append(t.Rows, r) t.Rows = append(t.Rows, r)
r = new(Row) r = new(Row)
r.Fields = []string{"1", "", "2", "3"} r.Fields = []string{"1", "", "2", "3"}
t.Rows = append(t.Rows, r) t.Rows = append(t.Rows, r)
conversation.Append(chat) conversation.Append(chat)
*/
t := conversation.AddTable()
t.AddRow([]string{"apple", "pear"})
conversation.AddGeminiComment("funny")
conversation.AddUserComment("yes")
conversation.AddGeminiComment("I like astronomy") conversation.AddGeminiComment("I like astronomy")
@ -30,7 +38,13 @@ func TestChat() {
log.Println(dump) log.Println(dump)
} }
func (c *Chats) AddTable() { func (t *Table) AddRow(f []string) {
r := new(Row)
r.Fields = f
t.Rows = append(t.Rows, r)
}
func (c *Chats) AddTable() *Table {
chat := new(Chat) chat := new(Chat)
t := new(Table) t := new(Table)
@ -38,7 +52,7 @@ func (c *Chats) AddTable() {
// t.Rows = append(t.Rows, []string{"a", "b"}) // t.Rows = append(t.Rows, []string{"a", "b"})
r := new(Row) r := new(Row)
r.Fields = []string{"a", "b"} r.Fields = []string{"j", "r", "a", "b"}
t.Rows = append(t.Rows, r) t.Rows = append(t.Rows, r)
r = new(Row) r = new(Row)
@ -48,12 +62,23 @@ func (c *Chats) AddTable() {
chat.Table = t chat.Table = t
c.Append(chat) c.Append(chat)
return t
} }
func (c *Chats) AddGeminiComment(s string) { func (c *Chats) AddGeminiComment(s string) {
chat := new(Chat) chat := new(Chat)
chat.Gemini = true chat.From = Who_GEMINI
chat.Content = s
c.Append(chat)
}
func (c *Chats) AddUserComment(s string) {
chat := new(Chat)
chat.From = Who_USER
chat.Content = s chat.Content = s
c.Append(chat) c.Append(chat)