From fbbed0475bc680afb754bbe9ba471c584d884a8f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 30 Aug 2025 18:07:41 -0500 Subject: parse stuff --- json.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'json.go') diff --git a/json.go b/json.go index e663fc5..e55521d 100644 --- a/json.go +++ b/json.go @@ -45,10 +45,7 @@ type FunctionResponse struct { Response map[string]interface{} `json:"response"` } -// parseJSON opens the given file, reads it, and unmarshals it into our structs. -func parseJSON(filename string) (*GeminiRequest, error) { - log.Infof("Attempting to parse file: %s\n", filename) - +func parsePB(filename string) (*chatpb.GeminiRequest, error) { // Read the entire file data, err := os.ReadFile(filename) if err != nil { @@ -58,6 +55,18 @@ func parseJSON(filename string) (*GeminiRequest, error) { if err := pb.UnmarshalJSON(data); err != nil { return nil, err } + return pb, nil +} + +// parseJSON opens the given file, reads it, and unmarshals it into our structs. +func parseJSON(filename string) (*GeminiRequest, error) { + log.Infof("Attempting to parse file: %s\n", filename) + + // Read the entire file + data, err := os.ReadFile(filename) + if err != nil { + return nil, log.Errorf("failed to read file %s: %w", filename, err) + } // Unmarshal the JSON data var req *GeminiRequest -- cgit v1.2.3