-
Notifications
You must be signed in to change notification settings - Fork 1
/
tools.go
41 lines (36 loc) · 882 Bytes
/
tools.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"context"
"fmt"
"os"
"github.com/google/generative-ai-go/genai"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
)
type Tool struct{}
// KnownModels retrieves the list of available generative models
func (t Tool) KnownModels() (string, error) {
var res string
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY")))
if err != nil {
return "", err
}
defer client.Close()
iter := client.ListModels(ctx)
for {
m, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
return "", err
}
res += fmt.Sprintf("%s %s\n", m.Name, m.Description)
}
return res, nil
}
// RetrieveAWSAccountIDs obtains data from steampipe service
func (t Tool) RetrieveAWSAccountIDs() (string, error) {
return QueryPostgres("SELECT account_id FROM aws_account")
}