schema changes to Marshal() JSON from gemini-cli
This commit is contained in:
parent
395597646a
commit
5d62516c40
206
chat.proto
206
chat.proto
|
@ -2,63 +2,191 @@ syntax = "proto3";
|
||||||
|
|
||||||
package chatpb;
|
package chatpb;
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/struct.proto";
|
||||||
|
|
||||||
message Row { // `autogenpb:nomutex`
|
// Main request structure
|
||||||
repeated string fields = 1;
|
|
||||||
|
message GeminiRequest { // `autogenpb:marshal` `autogenpb:mutex`
|
||||||
|
string model = 1;
|
||||||
|
Config config = 2;
|
||||||
|
repeated Content contents = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Table { // `autogenpb:nomutex`
|
// Abort signal for the request
|
||||||
int32 columns = 1;
|
message AbortSignal {
|
||||||
repeated Row rows = 2;
|
}
|
||||||
|
|
||||||
|
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"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message FunctionDeclaration {
|
||||||
|
string name = 1;
|
||||||
|
string description = 2;
|
||||||
|
Schema parameters_json_schema = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Tool {
|
||||||
|
repeated FunctionDeclaration functionDeclarations = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configuration for the request
|
||||||
|
message Config {
|
||||||
|
message ThinkingConfig {
|
||||||
|
bool includeThoughts = 1;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties within the JSON schema
|
||||||
|
message Properties {
|
||||||
|
Reasoning reasoning = 1;
|
||||||
|
NextSpeaker next_speaker = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reasoning property
|
||||||
|
message Reasoning {
|
||||||
|
string type = 1;
|
||||||
|
string description = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next speaker property
|
||||||
|
message NextSpeaker {
|
||||||
|
string type = 1;
|
||||||
|
repeated string enum = 2;
|
||||||
|
string description = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Content of the chat
|
||||||
|
message Content {
|
||||||
|
string role = 1;
|
||||||
|
repeated Part parts = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Part of the content
|
||||||
|
message Part {
|
||||||
|
oneof part_type {
|
||||||
|
string text = 1;
|
||||||
|
FunctionCall functionCall = 2;
|
||||||
|
FunctionResponse functionResponse = 3;
|
||||||
|
}
|
||||||
|
string thoughtSignature = 4;
|
||||||
|
}
|
||||||
|
// Function call
|
||||||
|
message FunctionCall {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function response
|
||||||
|
message FunctionResponse {
|
||||||
|
string id = 1;
|
||||||
|
string name = 2;
|
||||||
|
Response response = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Response from a function call
|
||||||
|
message Response {
|
||||||
|
string output = 1;
|
||||||
|
string error = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Row {
|
||||||
|
repeated string fields = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Table {
|
||||||
|
int32 columns = 1;
|
||||||
|
repeated Row rows = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Who {
|
enum Who {
|
||||||
NOONE = 0;
|
NOONE = 0;
|
||||||
REGEX = 1;
|
REGEX = 1;
|
||||||
USER = 2;
|
USER = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEW: A message to hold all the details of a tool call
|
message ToolCall {
|
||||||
message ToolCall { // `autogenpb:nomutex`
|
string name = 1;
|
||||||
string name = 1; // e.g., "Shell"
|
string input = 2;
|
||||||
string input = 2; // The command that was run
|
string description = 3;
|
||||||
string description = 3; // The description for the command
|
string output_stdout = 4;
|
||||||
string output_stdout = 4;
|
string output_stderr = 5;
|
||||||
string output_stderr = 5;
|
int32 exit_code = 6;
|
||||||
int32 exit_code = 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message CodeSnippet { // `autogenpb:nomutex`
|
message CodeSnippet {
|
||||||
string filename = 1;
|
string filename = 1;
|
||||||
string content = 2;
|
string content = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ChatEntry { // `autogenpb:nomutex`
|
message ChatEntry {
|
||||||
Who from = 1;
|
Who from = 1;
|
||||||
google.protobuf.Timestamp ctime = 2;
|
google.protobuf.Timestamp ctime = 2;
|
||||||
string content = 3;
|
string content = 3;
|
||||||
Table table = 4;
|
Table table = 4;
|
||||||
repeated ToolCall ToolCalls = 5;
|
repeated ToolCall ToolCalls = 5;
|
||||||
string ContentFile = 6;
|
string ContentFile = 6;
|
||||||
string uuid = 7; // `autogenpb:unique` `autogenpb:sort`
|
string uuid = 7;
|
||||||
repeated CodeSnippet Snippets = 8;
|
repeated CodeSnippet Snippets = 8;
|
||||||
|
repeated Part parts = 9;
|
||||||
|
GeminiRequest GeminiRequest = 10;
|
||||||
|
int32 RequestCounter = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SessionStats { // `autogenpb:nomutex`
|
message SessionStats {
|
||||||
string uuid = 1;
|
string uuid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Chat { // `autogenpb:nomutex`
|
message Chat {
|
||||||
string uuid = 1; // `autogenpb:unique` `autogenpb:sort`
|
string uuid = 1; // `autogenpb:unique` `autogenpb:sort`
|
||||||
google.protobuf.Timestamp ctime = 2;
|
google.protobuf.Timestamp ctime = 2;
|
||||||
string ChatName = 3;
|
string ChatName = 3;
|
||||||
repeated ChatEntry Entries = 4;
|
repeated ChatEntry Entries = 4;
|
||||||
repeated SessionStats Session = 5;
|
repeated SessionStats Session = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Chats { // `autogenpb:marshal` `autogenpb:mutex`
|
message Chats { // `autogenpb:marshal` `autogenpb:mutex`
|
||||||
string uuid = 1; // `autogenpb:uuid:9fd31f10-c25d-4d66-bc8d-5f6eb7c79057`
|
string uuid = 1; // `autogenpb:uuid:9fd31f10-c25d-4d66-bc8d-5f6eb7c79057` `autogenpb:primary`
|
||||||
string version = 2; // `autogenpb:version:v0.0.1`
|
string version = 2; // `autogenpb:version:v0.0.1`
|
||||||
repeated Chat Chats = 3; // THIS MUST BE Chat and then Chats
|
repeated Chat Chats = 3; // THIS MUST BE Chat and then Chats
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (all *Chats) ConfigSave() error {
|
||||||
return err
|
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))
|
// log.Infof("chatpb.ConfigSave() worked len(Chats)=%d bytes=%d", len(cleanChats.Chats), len(data))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func (all *Chats) ConfigLoad() error {
|
||||||
log.Warn("versions do not match", test.Version, all.Version)
|
log.Warn("versions do not match", test.Version, all.Version)
|
||||||
deleteProtobufFile(cfgname)
|
deleteProtobufFile(cfgname)
|
||||||
}
|
}
|
||||||
log.Info(cfgname, "protobuf versions and uuid match", all.Uuid, all.Version)
|
// log.Info(cfgname, "protobuf versions and uuid match", all.Uuid, all.Version)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,3 +93,11 @@ func (x *Chats) AppendNew(y *Chat) {
|
||||||
|
|
||||||
x.Chats = append(x.Chats, chat)
|
x.Chats = append(x.Chats, chat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a Append() shortcut (that does Clone() with a mutex) notsure if it really works
|
||||||
|
func (x *Chat) AppendEntry(y *ChatEntry) {
|
||||||
|
x.Lock()
|
||||||
|
defer x.Unlock()
|
||||||
|
|
||||||
|
x.Entries = append(x.Entries, proto.Clone(y).(*ChatEntry))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue