diff options
| author | Jeff Carr <[email protected]> | 2025-09-01 00:29:48 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-01 00:29:48 -0500 |
| commit | 4a800a7cfd6e8d59b021ff1b5a0ea9d42b89b7b3 (patch) | |
| tree | f6343d4cf86e121e5874f85502a4822613e54093 /convertToGenai.go | |
| parent | eba85c6b97dbbab8b9b437e557a3dd5e6de41984 (diff) | |
attempts to submit data to the Gemini API
Diffstat (limited to 'convertToGenai.go')
| -rw-r--r-- | convertToGenai.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/convertToGenai.go b/convertToGenai.go new file mode 100644 index 0000000..a9dd1b4 --- /dev/null +++ b/convertToGenai.go @@ -0,0 +1,28 @@ +package main + +import ( + "go.wit.com/lib/protobuf/chatpb" + "google.golang.org/genai" +) + +// convertToGenai transforms the parsed JSON request into the genai.Content format. +func convertToGenai(req *chatpb.GeminiRequest) ([]*genai.Content, error) { + var contents []*genai.Content + for _, c := range req.Contents { + genaiParts := []*genai.Part{} // Create a slice of the interface type + for _, p := range c.Parts { + if p.Text != "" { + // genai.Text returns a Part interface, which is what we need + var tmp *genai.Part + tmp = new(genai.Part) + tmp.Text = p.Text + genaiParts = append(genaiParts, tmp) + } + } + contents = append(contents, &genai.Content{ + Role: c.Role, + Parts: genaiParts, + }) + } + return contents, nil +} |
