pull models

This commit is contained in:
Bruce MacDonald
2023-07-06 12:24:49 -04:00
committed by Jeffrey Morgan
parent 0833f5af3a
commit a6494f8211
5 changed files with 202 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ package cmd
import (
"context"
"fmt"
"log"
"net"
"net/http"
@@ -23,6 +24,21 @@ func cacheDir() string {
return path.Join(home, ".ollama")
}
func run(model string) error {
client, err := NewAPIClient()
if err != nil {
return err
}
pr := api.PullRequest{
Model: model,
}
callback := func(progress string) {
fmt.Println(progress)
}
_, err = client.Pull(context.Background(), &pr, callback)
return err
}
func serve() error {
sp := path.Join(cacheDir(), "ollama.sock")
@@ -94,7 +110,7 @@ func NewCLI() *cobra.Command {
Short: "Run a model",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return nil
return run(args[0])
},
}