-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
53 lines (41 loc) · 980 Bytes
/
models.go
File metadata and controls
53 lines (41 loc) · 980 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
53
package dllama
import (
"fmt"
"github.com/taubyte/dllama-go/symbols"
)
func ListModels() ([]string, error) {
listId := symbols.ListModels()
if int64(listId) < 0 {
return nil, fmt.Errorf("ListModels returned %d", listId)
}
buf := make([]byte, 1024)
var models []string
for {
n := symbols.ListModelsNext(listId, &buf[0])
if n < 0 {
return nil, fmt.Errorf("ListModelsNext returned %d", n)
}
if n == 0 {
break
}
models = append(models, string(buf[:n]))
}
return models, nil
}
func FetchHuggingFaceModel(name string, repo string, file string) error {
nameBytes := []byte(name)
repoBytes := []byte(repo)
fileBytes := []byte(file)
errBuf := make([]byte, 1024)
var errLen uint32
ret := symbols.FetchHFModel(
&nameBytes[0], uint32(len(nameBytes)),
&repoBytes[0], uint32(len(repoBytes)),
&fileBytes[0], uint32(len(fileBytes)),
&errBuf[0], &errLen,
)
if ret != 0 {
return fmt.Errorf("%s", string(errBuf[:errLen]))
}
return nil
}