changed protobuf
This commit is contained in:
parent
185677e464
commit
21ca3300d4
14
chat.proto
14
chat.proto
|
@ -40,22 +40,16 @@ message ChatEntry { // `autogenpb:nomute
|
||||||
string content = 3;
|
string content = 3;
|
||||||
Table table = 4;
|
Table table = 4;
|
||||||
repeated ToolCall ToolCalls = 5;
|
repeated ToolCall ToolCalls = 5;
|
||||||
string ContentFile = 6; // `autogenpb:unique` `autogenpb:sort`
|
string ContentFile = 6;
|
||||||
string uuid = 7; // `autogenpb:unique` `autogenpb:sort`
|
string uuid = 7; // `autogenpb:unique` `autogenpb:sort`
|
||||||
repeated CodeSnippet Snippets = 8;
|
repeated CodeSnippet Snippets = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Chat { // `autogenpb:nomutex`
|
message Chat { // `autogenpb:nomutex`
|
||||||
Who from = 1;
|
string uuid = 1; // `autogenpb:unique` `autogenpb:sort`
|
||||||
google.protobuf.Timestamp ctime = 2;
|
google.protobuf.Timestamp ctime = 2;
|
||||||
string content = 3;
|
string ChatName = 3;
|
||||||
Table table = 4;
|
repeated ChatEntry Entries = 4;
|
||||||
repeated ToolCall ToolCalls = 5;
|
|
||||||
string ContentFile = 6; // `autogenpb:unique` `autogenpb:sort`
|
|
||||||
string uuid = 7; // `autogenpb:unique` `autogenpb:sort`
|
|
||||||
repeated CodeSnippet Snippets = 8;
|
|
||||||
string ChatName = 9;
|
|
||||||
repeated ChatEntry Entries = 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Chats { // `autogenpb:marshal` `autogenpb:mutex`
|
message Chats { // `autogenpb:marshal` `autogenpb:mutex`
|
||||||
|
|
|
@ -10,11 +10,14 @@ func ExampleChat() *Chats {
|
||||||
t := conversation.AddTable()
|
t := conversation.AddTable()
|
||||||
t.AddRow([]string{"apple", "pear"})
|
t.AddRow([]string{"apple", "pear"})
|
||||||
|
|
||||||
gchat := conversation.AddGeminiComment("funny")
|
conversation.AddGeminiComment("funny")
|
||||||
|
|
||||||
|
/*
|
||||||
|
gchat := conversation.AddGeminiComment("funny")
|
||||||
snip := new(CodeSnippet)
|
snip := new(CodeSnippet)
|
||||||
snip.Filename = "log/snip1.txt"
|
snip.Filename = "log/snip1.txt"
|
||||||
gchat.Snippets = append(gchat.Snippets, snip)
|
gchat.Snippets = append(gchat.Snippets, snip)
|
||||||
|
*/
|
||||||
|
|
||||||
conversation.AddUserComment("yes")
|
conversation.AddUserComment("yes")
|
||||||
|
|
||||||
|
|
12
helpers.go
12
helpers.go
|
@ -12,8 +12,8 @@ import (
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Chats) AddGeminiComment(s string) *Chat {
|
func (c *Chats) AddGeminiComment(s string) *ChatEntry {
|
||||||
chat := new(Chat)
|
chat := new(ChatEntry)
|
||||||
|
|
||||||
chat.From = Who_GEMINI
|
chat.From = Who_GEMINI
|
||||||
chat.Content = s
|
chat.Content = s
|
||||||
|
@ -24,8 +24,8 @@ func (c *Chats) AddGeminiComment(s string) *Chat {
|
||||||
return chat
|
return chat
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Chats) AddUserComment(s string) *Chat {
|
func (c *Chats) AddUserComment(s string) *ChatEntry {
|
||||||
chat := new(Chat)
|
chat := new(ChatEntry)
|
||||||
|
|
||||||
chat.From = Who_USER
|
chat.From = Who_USER
|
||||||
chat.Content = s
|
chat.Content = s
|
||||||
|
@ -172,12 +172,12 @@ func (c *Chat) VerifyUuid() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Chats) AppendNew(y *Chat) {
|
func (x *Chats) AppendNew(y *ChatEntry) {
|
||||||
x.Lock()
|
x.Lock()
|
||||||
defer x.Unlock()
|
defer x.Unlock()
|
||||||
|
|
||||||
var chat *Chat
|
var chat *Chat
|
||||||
chat = proto.Clone(y).(*Chat)
|
chat = proto.Clone(y).(*ChatEntry)
|
||||||
|
|
||||||
x.Chats = append(x.Chats, chat)
|
x.Chats = append(x.Chats, chat)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue