forked from novitalabs/golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (32 loc) · 791 Bytes
/
main.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
package main
import (
"context"
"fmt"
"time"
"github.com/novitalabs/golang-sdk/request"
"github.com/novitalabs/golang-sdk/types"
)
func main() {
// get your api key refer to https://docs.novita.ai/get-started/
const apiKey = "your-key"
client, err := request.NewClient(apiKey, "")
if err != nil {
fmt.Printf("new client failed, %v\n", err)
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
defer cancel()
// get all models
modelList, err := client.Models(ctx)
if err != nil {
fmt.Printf("get model list failed, %v\n", err)
return
}
// top 10 checkpoint
modelList = modelList.FilterType(types.Checkpoint).TopN(10, func(m *types.Model) float32 {
return m.CivitaiRating
})
for _, m := range modelList {
fmt.Println(m.Name)
}
}