mirror of
https://github.com/ollama/ollama.git
synced 2025-05-11 10:26:53 +02:00
pull models
This commit is contained in:
parent
0833f5af3a
commit
a6494f8211
5 changed files with 202 additions and 9 deletions
|
@ -35,7 +35,7 @@ func checkError(resp *http.Response, body []byte) error {
|
|||
return apiError
|
||||
}
|
||||
|
||||
func (c *Client) stream(ctx context.Context, method string, path string, reqData any, callback func (data []byte)) error {
|
||||
func (c *Client) stream(ctx context.Context, method string, path string, reqData any, callback func(data []byte)) error {
|
||||
var reqBody io.Reader
|
||||
var data []byte
|
||||
var err error
|
||||
|
@ -140,3 +140,14 @@ func (c *Client) Generate(ctx context.Context, req *GenerateRequest, callback fu
|
|||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (c *Client) Pull(ctx context.Context, req *PullRequest, callback func(token string)) (*PullResponse, error) {
|
||||
var res PullResponse
|
||||
if err := c.stream(ctx, http.MethodPost, "/api/pull", req, func(token []byte) {
|
||||
callback(string(token))
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue