ba460802c2
* examples: go-multimodal * examples: add go-pull-progress * examples: add go-chat * fix
31 lines
518 B
Go
31 lines
518 B
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)
|
|
}
|
|
}
|