attempt to marshal JSON file to protobuf
This commit is contained in:
parent
6888512b3b
commit
512ebf5be6
5
json.go
5
json.go
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"go.wit.com/lib/protobuf/chatpb"
|
||||
"go.wit.com/log"
|
||||
"google.golang.org/genai"
|
||||
)
|
||||
|
@ -53,6 +54,10 @@ func parseJSON(filename string) (*GeminiRequest, error) {
|
|||
if err != nil {
|
||||
return nil, log.Errorf("failed to read file %s: %w", filename, err)
|
||||
}
|
||||
pb := new(chatpb.GeminiRequest)
|
||||
if err := pb.UnmarshalJSON(data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unmarshal the JSON data
|
||||
var req *GeminiRequest
|
||||
|
|
7
main.go
7
main.go
|
@ -65,13 +65,14 @@ func main() {
|
|||
_ = aiClient
|
||||
|
||||
if argv.JsonFile != "" {
|
||||
req, err := parseJSON(argv.JsonFile)
|
||||
jstruct, err := parseJSON(argv.JsonFile)
|
||||
if err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
log.Info("parseJSON() ok. model =", req.Model)
|
||||
log.Info("parseJSON() ok. model =", jstruct.Model)
|
||||
|
||||
genaiContent, err := convertToGenai(req)
|
||||
// Marshal this JSON file into a protobuf
|
||||
genaiContent, err := convertToGenai(jstruct)
|
||||
if err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue