You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
g, err:=genkit.New()
iferr!=nil {
log.Fatal(err)
}
updateTool:=genkit.DefineTool(
g,
"updateInfo",
"use this to set the party information",
func(ctx context.Context, newName, partyThemestring) (string, error) {
genkit.SessionFromContext(ctx, g).UpdateState(PartyDetails{ Name: newName, PartyTheme: partyTheme })
return"changed name to "+newName+" and party theme to "+partyTheme, nil
}
)
themeIdeasTool:=g.Prompt("themeIdeasPrompt").AsTool()
typePartyDetailsstruct {
NamestringPartyThemestring
}
s, err:=genkit.NewSession(
g,
chat.WithId("my-session"), // optional, defaults to uuid
chat.WithStore(...), // optional, defaults to in-memorychat.WithStateType(PartyDetails{ Name: "Alex", PartyTheme: "Halloween" }), // pulls out type and initial values
)
iferr!=nil {
log.Fatal(err)
}
// Mostly same options as `Generate` but redefined in their own package since not everything will apply and there are chat-specific ones.c, err:=genkit.NewChat(
g,
chat.WithSession(s), // optional, if left off then no state is keptchat.WithSystemText("You are a helpful assistant helping the customer create the best party ever."),
chat.WithTools(updateTool, themeIdeasTool),
)
iferr!=nil {
log.Fatal(err)
}
res, err :=c.Send("my name is Tom and I like animals") // optional chat.WithStreaming(...)iferr!=nil {
log.Fatal(err)
}
fmt.Println(res)
The text was updated successfully, but these errors were encountered:
https://firebase.google.com/docs/genkit/chat
https://firebase.google.com/docs/genkit/multi-agent
The text was updated successfully, but these errors were encountered: