sub in the functions
This commit is contained in:
parent
c63a746d0b
commit
c65619154e
|
@ -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()
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
structs.go
11
structs.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue