From af57eec6919c991153a8cd6ee1e9fc0cb2eea394 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 21 Aug 2025 00:52:41 -0500 Subject: [PATCH] example works --- chat.proto | 9 +++++++-- make_chat.go | 57 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/chat.proto b/chat.proto index addf823..a610d2e 100644 --- a/chat.proto +++ b/chat.proto @@ -11,9 +11,14 @@ message Table { repeated Row rows = 2; } +enum Who { + NOONE = 0; + GEMINI = 1; + USER = 2; +} + message Chat { - bool gemini = 1; - bool user = 2; + Who from = 1; string content = 3; Table table = 4; } diff --git a/make_chat.go b/make_chat.go index 26c4ea3..b6736c4 100644 --- a/make_chat.go +++ b/make_chat.go @@ -5,23 +5,31 @@ import "go.wit.com/log" func TestChat() { conversation := NewChats() - chat := new(Chat) - chat.Content = "this was fun" + /* + 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 + 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{"a", "b"} + t.Rows = append(t.Rows, r) - r = new(Row) - r.Fields = []string{"1", "", "2", "3"} - 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.Append(chat) + */ + + t := conversation.AddTable() + t.AddRow([]string{"apple", "pear"}) + + conversation.AddGeminiComment("funny") + conversation.AddUserComment("yes") conversation.AddGeminiComment("I like astronomy") @@ -30,7 +38,13 @@ func TestChat() { 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) t := new(Table) @@ -38,7 +52,7 @@ func (c *Chats) AddTable() { // t.Rows = append(t.Rows, []string{"a", "b"}) r := new(Row) - r.Fields = []string{"a", "b"} + r.Fields = []string{"j", "r", "a", "b"} t.Rows = append(t.Rows, r) r = new(Row) @@ -48,12 +62,23 @@ func (c *Chats) AddTable() { chat.Table = t c.Append(chat) + + return t } func (c *Chats) AddGeminiComment(s string) { 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 c.Append(chat)