update with code snippet
This commit is contained in:
parent
d7dec7865a
commit
2d7b5fe532
1
Makefile
1
Makefile
|
@ -1,5 +1,4 @@
|
|||
all: clean chat.pb.go goimports vet
|
||||
echo okay?
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
|
|
@ -29,6 +29,11 @@ message ToolCall {
|
|||
int32 exit_code = 6;
|
||||
}
|
||||
|
||||
message CodeSnippet {
|
||||
string filename = 1;
|
||||
string content = 2;
|
||||
}
|
||||
|
||||
message Chat {
|
||||
Who from = 1;
|
||||
google.protobuf.Timestamp ctime = 2;
|
||||
|
@ -37,6 +42,7 @@ message Chat {
|
|||
repeated ToolCall ToolCalls = 5;
|
||||
string ContentFile = 6; // `autogenpb:unique` `autogenpb:sort`
|
||||
string uuid = 7; // `autogenpb:unique` `autogenpb:sort`
|
||||
repeated CodeSnippet Snippets = 8;
|
||||
}
|
||||
|
||||
message Chats { // `autogenpb:marshal` `autogenpb:mutex`
|
||||
|
|
|
@ -10,7 +10,12 @@ func ExampleChat() *Chats {
|
|||
t := conversation.AddTable()
|
||||
t.AddRow([]string{"apple", "pear"})
|
||||
|
||||
conversation.AddGeminiComment("funny")
|
||||
gchat := conversation.AddGeminiComment("funny")
|
||||
|
||||
snip := new(CodeSnippet)
|
||||
snip.Filename = "log/snip1.txt"
|
||||
gchat.Snippets = append(gchat.Snippets, snip)
|
||||
|
||||
conversation.AddUserComment("yes")
|
||||
|
||||
conversation.AddGeminiComment("I like astronomy")
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package chatpb
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func (c *Chats) AddGeminiComment(s string) *Chat {
|
||||
chat := new(Chat)
|
||||
|
||||
chat.From = Who_GEMINI
|
||||
chat.Content = s
|
||||
chat.Ctime = timestamppb.New(time.Now())
|
||||
|
||||
c.Append(chat)
|
||||
|
||||
return chat
|
||||
}
|
||||
|
||||
func (c *Chats) AddUserComment(s string) *Chat {
|
||||
chat := new(Chat)
|
||||
|
||||
chat.From = Who_USER
|
||||
chat.Content = s
|
||||
|
||||
c.Append(chat)
|
||||
|
||||
return chat
|
||||
}
|
||||
|
||||
func UnmarshalChats(data []byte) (*Chats, error) {
|
||||
c := new(Chats)
|
||||
err := c.Unmarshal(data)
|
||||
return c, err
|
||||
}
|
||||
|
||||
func UnmarshalChatsTEXT(data []byte) (*Chats, error) {
|
||||
c := new(Chats)
|
||||
err := c.UnmarshalTEXT(data)
|
||||
return c, err
|
||||
}
|
34
make_chat.go
34
make_chat.go
|
@ -1,10 +1,7 @@
|
|||
package chatpb
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.wit.com/log"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func TestChat() {
|
||||
|
@ -70,34 +67,3 @@ func (c *Chats) AddTable() *Table {
|
|||
|
||||
return t
|
||||
}
|
||||
|
||||
func (c *Chats) AddGeminiComment(s string) {
|
||||
chat := new(Chat)
|
||||
|
||||
chat.From = Who_GEMINI
|
||||
chat.Content = s
|
||||
chat.Ctime = timestamppb.New(time.Now())
|
||||
|
||||
c.Append(chat)
|
||||
}
|
||||
|
||||
func (c *Chats) AddUserComment(s string) {
|
||||
chat := new(Chat)
|
||||
|
||||
chat.From = Who_USER
|
||||
chat.Content = s
|
||||
|
||||
c.Append(chat)
|
||||
}
|
||||
|
||||
func UnmarshalChats(data []byte) (*Chats, error) {
|
||||
c := new(Chats)
|
||||
err := c.Unmarshal(data)
|
||||
return c, err
|
||||
}
|
||||
|
||||
func UnmarshalChatsTEXT(data []byte) (*Chats, error) {
|
||||
c := new(Chats)
|
||||
err := c.UnmarshalTEXT(data)
|
||||
return c, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue