diff options
| author | Jeff Carr <[email protected]> | 2025-09-01 01:55:06 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-01 01:55:06 -0500 | 
| commit | c65619154eb37912be8af563de113e028665633c (patch) | |
| tree | 6f305a21a6292c18463bc07bb302cf0b26ed08a3 | |
| parent | c63a746d0baa7880c54a0069b03f1924c3be3f46 (diff) | |
sub in the functions
| -rw-r--r-- | addResponse.go | 13 | ||||
| -rw-r--r-- | convertToPB.go | 12 | ||||
| -rw-r--r-- | doPlayback.go | 6 | ||||
| -rw-r--r-- | structs.go | 11 | ||||
| -rw-r--r-- | submitChat.go | 27 | 
5 files changed, 61 insertions, 8 deletions
diff --git a/addResponse.go b/addResponse.go new file mode 100644 index 0000000..4c04c69 --- /dev/null +++ b/addResponse.go @@ -0,0 +1,13 @@ +package main + +import ( +	"go.wit.com/log" +	"google.golang.org/genai" +) + +func addResponse(resp *genai.GenerateContentResponse) { +	pb := convertToPB(resp) +	log.Info(resp) +	me.lastChat.AppendEntry(pb) +	me.chats.ConfigSave() +} diff --git a/convertToPB.go b/convertToPB.go new file mode 100644 index 0000000..3f87e34 --- /dev/null +++ b/convertToPB.go @@ -0,0 +1,12 @@ +package main + +import ( +	"go.wit.com/lib/protobuf/chatpb" +	"google.golang.org/genai" +) + +func convertToPB(resp *genai.GenerateContentResponse) *chatpb.ChatEntry { +	pb := new(chatpb.ChatEntry) +	// TODO: add the code to convert the response to the protobuf +	return pb +} diff --git a/doPlayback.go b/doPlayback.go index 2db75ae..8482805 100644 --- a/doPlayback.go +++ b/doPlayback.go @@ -77,9 +77,9 @@ func listChats(chats *chatpb.Chats) {  	// Get the last chat  	numChats := len(chats.GetChats())  	if numChats > 0 { -		lastChat := chats.GetChats()[numChats-1] -		log.Printf("The current Gemini API session is UUID: %s\n", lastChat.GetUuid()) -		dumpchat(lastChat) +		me.lastChat = chats.GetChats()[numChats-1] +		log.Printf("The current Gemini API session is UUID: %s\n", me.lastChat.GetUuid()) +		dumpchat(me.lastChat)  	}  } @@ -16,9 +16,10 @@ var me *mainType  // this app's variables  type mainType struct { -	pp     *arg.Parser   // for parsing the command line args.  Yay to alexf lint! -	chats  *chatpb.Chats // all our prior conversations with regex -	myGui  *gui.Node     // the gui toolkit handle -	client *genai.Client // the Google Gemini AI client variable -	ctx    context.Context +	pp       *arg.Parser     // for parsing the command line args.  Yay to alexf lint! +	chats    *chatpb.Chats   // all our prior conversations with regex +	myGui    *gui.Node       // the gui toolkit handle +	client   *genai.Client   // the Google Gemini AI client variable +	ctx      context.Context // global context. what does this acutally mean? +	lastChat *chatpb.Chat    // the last chat. append to here  } diff --git a/submitChat.go b/submitChat.go new file mode 100644 index 0000000..89e0160 --- /dev/null +++ b/submitChat.go @@ -0,0 +1,27 @@ +package main + +import ( +	"fmt" + +	"go.wit.com/log" +	"google.golang.org/genai" +) + +func submitChat(content []*genai.Content) error { +	resp, err := me.client.Models.GenerateContent(me.ctx, "gemini-2.5-flash", content, nil) +	if err != nil { +		return log.Errorf("error sending message: %v", err) +	} + +	log.Info("Response from API:") +	for _, cand := range resp.Candidates { +		if cand.Content != nil { +			for _, part := range cand.Content.Parts { +				fmt.Println(part) +			} +		} +	} +	// TODO: add the response to the protobuf +	addResponse(resp) +	return nil +}  | 
