跳转至

拉取模型

源码

main.go

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/ollama/ollama/api"
)

func main() {
    client, err := api.ClientFromEnvironment()
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    req := &api.PullRequest{
        Model: "mistral",
    }
    progressFunc := func(resp api.ProgressResponse) error {
        fmt.Printf("Progress: status=%v, total=%v, completed=%v\n", resp.Status, resp.Total, resp.Completed)
        return nil
    }

    err = client.Pull(ctx, req, progressFunc)
    if err != nil {
        log.Fatal(err)
    }
}

仓库地址

go-pull-progress