summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-02 15:18:41 -0500
committerJeff Carr <[email protected]>2025-09-02 15:18:41 -0500
commitaa2483e255d68bfa6e19aae7531d2c28fb2f1253 (patch)
tree924b393008b54d2a65f3cb7b3f558df225b9890a
parentaebfe325d63a947d936c069a8cffd3b2d631aeae (diff)
more changes to make import from gemini-cli work
-rw-r--r--Makefile5
-rw-r--r--addChat.go17
-rw-r--r--book.proto24
-rw-r--r--chat.proto214
-rw-r--r--config.go2
5 files changed, 156 insertions, 106 deletions
diff --git a/Makefile b/Makefile
index edc546f..35867ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-all: clean chat.pb.go goimports vet
+all: clean chat.pb.go book.pb.go goimports vet
goimports:
goimports -w *.go
@@ -6,6 +6,9 @@ goimports:
chat.pb.go: chat.proto
autogenpb --proto chat.proto
+book.pb.go: book.proto
+ autogenpb --proto book.proto
+
clean:
rm -f *.pb.go *.patch
-rm -f go.*
diff --git a/addChat.go b/addChat.go
index f33650f..5ed87d2 100644
--- a/addChat.go
+++ b/addChat.go
@@ -6,6 +6,7 @@ import (
"time"
"go.wit.com/log"
+ timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
// returns true if the pb was added
@@ -23,14 +24,12 @@ func (c *Chat) AddGeminiRequest(fname string, age time.Time, pb *GeminiRequest)
return false
}
}
- log.Info("not sure if c.Entries == pb for real. need to read Content & Parts")
- /*
- e := new(ChatEntry)
- e.Ctime = timestamppb.New(age)
- e.From = Who_USER
- e.ContentFile = fname
- e.GeminiRequest = pb
- c.AppendEntry(e)
- */
+ log.Info("Adding new ChatEntry for", "/tmp/"+fname)
+ e := new(ChatEntry)
+ e.Ctime = timestamppb.New(age)
+ e.From = Who_USER
+ e.ContentFile = fname
+ e.GeminiRequest = pb
+ c.AppendEntry(e)
return true
}
diff --git a/book.proto b/book.proto
new file mode 100644
index 0000000..526ec42
--- /dev/null
+++ b/book.proto
@@ -0,0 +1,24 @@
+syntax = "proto3";
+
+package chatpb;
+
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/struct.proto";
+import "chat.proto";
+
+message Book {
+ string uuid = 1; // `autogenpb:unique` `autogenpb:sort`
+ google.protobuf.Timestamp ctime = 2;
+ string Title = 3;
+ int32 version = 4;
+ Who from = 5;
+ string content = 6;
+ Table table = 7;
+ GeminiRequest GeminiRequest = 8;
+}
+
+message Books { // `autogenpb:marshal` `autogenpb:mutex` `autogenpb:gui`
+ string uuid = 1; // `autogenpb:uuid:8b6409ad-4498-43a6-b09a-7835c00dcb9a`
+ string version = 2; // `autogenpb:version:v0.0.1`
+ repeated Book Books = 3; // THIS MUST BE Chat and then Chats
+}
diff --git a/chat.proto b/chat.proto
index e7e6c41..32b3db7 100644
--- a/chat.proto
+++ b/chat.proto
@@ -7,10 +7,10 @@ import "google/protobuf/struct.proto";
// Main request structure
-message GeminiRequest { // `autogenpb:marshal` `autogenpb:mutex`
- string model = 1;
- Config config = 2;
- repeated Content contents = 3;
+message GeminiRequest { // `autogenpb:marshal` `autogenpb:mutex`
+ string model = 1;
+ Config config = 2;
+ repeated Content contents = 3;
}
// Abort signal for the request
@@ -18,72 +18,95 @@ message AbortSignal {
}
message Schema {
- string type = 1;
- map<string, Schema> properties = 2;
- repeated string required = 3;
- string description = 4;
- Schema items = 5;
- repeated string enum = 6;
- int32 minimum = 7;
- int32 minLength = 8;
- int32 minItems = 9;
- google.protobuf.Value default_value = 10 [json_name = "default"];
+ string type = 1;
+ map<string, Schema> properties = 2;
+ repeated string required = 3;
+ string description = 4;
+ Schema items = 5;
+ repeated string enum = 6;
+ int32 minimum = 7;
+ int32 minLength = 8;
+ int32 minItems = 9;
+ google.protobuf.Value default_value = 10 [json_name = "default"];
}
message FunctionDeclaration {
- string name = 1;
- string description = 2;
- Schema parameters_json_schema = 3;
+ string name = 1;
+ string description = 2;
+ Schema parameters_json_schema = 3;
+}
+
+message GoogleSearch {
}
message Tool {
- repeated FunctionDeclaration functionDeclarations = 1;
+ repeated FunctionDeclaration functionDeclarations = 1;
+ GoogleSearch googleSearch = 2;
}
// Configuration for the request
message Config {
message ThinkingConfig {
- bool includeThoughts = 1;
+ bool includeThoughts = 1;
+ int32 thinkingBudget = 2;
}
- double temperature = 2;
- double topP = 3;
- string systemInstruction = 4;
- ResponseJsonSchema responseJsonSchema = 5;
- string responseMimeType = 6;
- AbortSignal abort_signal = 7;
- ThinkingConfig thinkingConfig = 8;
- repeated Tool tools = 9;
+ double temperature = 2;
+ double topP = 3;
+ string systemInstruction = 4;
+ ResponseJsonSchema responseJsonSchema = 5;
+ string responseMimeType = 6;
+ AbortSignal abort_signal = 7;
+ ThinkingConfig thinkingConfig = 8;
+ repeated Tool tools = 9;
}
// JSON schema for the response
message ResponseJsonSchema {
- string type = 1;
- Properties properties = 2;
- repeated string required = 3;
+ string type = 1;
+ Properties properties = 2;
+ repeated string required = 3;
}
// Properties within the JSON schema
message Properties {
- Reasoning reasoning = 1;
- NextSpeaker next_speaker = 2;
+ Reasoning reasoning = 1;
+ NextSpeaker next_speaker = 2;
+ CorrectedNewStringEscaping corrected_new_string_escaping = 3;
+ CorrectedTargetSnippet corrected_target_snippet = 4;
+ Confidence confidence = 5;
+}
+
+message Confidence {
+ string type = 1;
+ string description = 2;
+}
+
+message CorrectedTargetSnippet {
+ string type = 1;
+ string description = 2;
}
// Reasoning property
+message CorrectedNewStringEscaping {
+ string type = 1;
+ string description = 2;
+}
+
message Reasoning {
- string type = 1;
- string description = 2;
+ string type = 1;
+ string description = 2;
}
// Next speaker property
message NextSpeaker {
- string type = 1;
- repeated string enum = 2;
- string description = 3;
+ string type = 1;
+ repeated string enum = 2;
+ string description = 3;
}
// Content of the chat
message Content {
- string role = 1;
- repeated Part parts = 2;
+ string role = 1;
+ repeated Part parts = 2;
}
// Part of the content
@@ -93,51 +116,52 @@ message Part {
FunctionCall functionCall = 2;
FunctionResponse functionResponse = 3;
}
- string thoughtSignature = 4;
+ string thoughtSignature = 4;
}
// Function call
message FunctionCall {
- string name = 1;
- argsInfo args = 3;
+ string name = 1;
+ argsInfo args = 3;
}
message argsInfo {
- string absolute_path = 1;
- string description = 2;
- string command = 3;
- string new_string = 4;
- string old_string = 5;
- int32 expected_replacements = 6;
- string file_path = 7;
- string directory = 8;
- string path = 9;
- string thinkingConfig = 10;
- string pattern = 11;
- string content = 12;
- string fact = 13;
- repeated string paths = 14;
+ string absolute_path = 1;
+ string description = 2;
+ string command = 3;
+ string new_string = 4;
+ string old_string = 5;
+ int32 expected_replacements = 6;
+ string file_path = 7;
+ string directory = 8;
+ string path = 9;
+ string thinkingConfig = 10;
+ string pattern = 11;
+ string content = 12;
+ string fact = 13;
+ repeated string paths = 14;
+ string query = 15;
}
// Function response
message FunctionResponse {
- string id = 1;
- string name = 2;
- Response response = 3;
+ string id = 1;
+ string name = 2;
+ Response response = 3;
}
// Response from a function call
message Response {
- string output = 1;
- string error = 2;
+ string output = 1;
+ string error = 2;
}
message Row {
- repeated string fields = 1;
+ repeated string fields = 1;
}
message Table {
- int32 columns = 1;
- repeated Row rows = 2;
+ int32 columns = 1;
+ repeated Row rows = 2;
}
enum Who {
@@ -147,48 +171,48 @@ enum Who {
}
message ToolCall {
- string name = 1;
- string input = 2;
- string description = 3;
- string output_stdout = 4;
- string output_stderr = 5;
- int32 exit_code = 6;
+ string name = 1;
+ string input = 2;
+ string description = 3;
+ string output_stdout = 4;
+ string output_stderr = 5;
+ int32 exit_code = 6;
}
message CodeSnippet {
- string filename = 1;
- string content = 2;
+ string filename = 1;
+ string content = 2;
}
-message ChatEntry { // `autogenpb:marshal`
- Who from = 1;
- google.protobuf.Timestamp ctime = 2;
- string content = 3;
- Table table = 4;
- repeated ToolCall ToolCalls = 5;
- string ContentFile = 6;
- string uuid = 7;
- repeated CodeSnippet Snippets = 8;
- repeated Part parts = 9;
- GeminiRequest GeminiRequest = 10;
- int32 RequestCounter = 11;
- repeated string paths = 12;
+message ChatEntry { // `autogenpb:marshal`
+ Who from = 1;
+ google.protobuf.Timestamp ctime = 2;
+ string content = 3;
+ Table table = 4;
+ repeated ToolCall ToolCalls = 5;
+ string ContentFile = 6;
+ string uuid = 7;
+ repeated CodeSnippet Snippets = 8;
+ repeated Part parts = 9;
+ GeminiRequest GeminiRequest = 10;
+ int32 RequestCounter = 11;
+ repeated string paths = 12;
}
message SessionStats {
- string uuid = 1;
+ string uuid = 1;
}
message Chat {
- string uuid = 1; // `autogenpb:unique` `autogenpb:sort`
- google.protobuf.Timestamp ctime = 2;
- string ChatName = 3;
- repeated ChatEntry Entries = 4;
- repeated SessionStats Session = 5;
+ string uuid = 1; // `autogenpb:unique` `autogenpb:sort`
+ google.protobuf.Timestamp ctime = 2;
+ string ChatName = 3;
+ repeated ChatEntry Entries = 4;
+ repeated SessionStats Session = 5;
}
-message Chats { // `autogenpb:marshal` `autogenpb:mutex` `autogenpb:gui`
- string uuid = 1; // `autogenpb:uuid:9fd31f10-c25d-4d66-bc8d-5f6eb7c79057` `autogenpb:primary`
- string version = 2; // `autogenpb:version:v0.0.1`
- repeated Chat Chats = 3; // THIS MUST BE Chat and then Chats
+message Chats { // `autogenpb:marshal` `autogenpb:mutex` `autogenpb:gui`
+ string uuid = 1; // `autogenpb:uuid:9fd31f10-c25d-4d66-bc8d-5f6eb7c79057` `autogenpb:primary`
+ string version = 2; // `autogenpb:version:v0.0.1`
+ repeated Chat Chats = 3; // THIS MUST BE Chat and then Chats
}
diff --git a/config.go b/config.go
index 727b18b..715aabc 100644
--- a/config.go
+++ b/config.go
@@ -77,7 +77,7 @@ func (all *Chats) ConfigSave() error {
log.Infof("chatpb.ConfigSave() failed len(Chats)=%d bytes=%d", len(cleanChats.Chats), len(data))
return err
}
- configWrite("regex.text", []byte(cleanChats.FormatTEXT()))
+ // configWrite("regex.text", []byte(cleanChats.FormatTEXT()))
// log.Infof("chatpb.ConfigSave() worked len(Chats)=%d bytes=%d", len(cleanChats.Chats), len(data))
return nil
}