go-ollama: changed development to dev container and added streaming capabilities to methods v0.1.1
This commit is contained in:
@@ -13,15 +13,15 @@ type CopyModelRequest struct {
|
||||
Destination string `json:"destination"`
|
||||
}
|
||||
|
||||
func (o Ollama) CopyModel(reqBody CopyModelRequest) (int, error) {
|
||||
func (o Ollama) CopyModel(reqBody CopyModelRequest) error {
|
||||
reqBodyBytes, err := json.Marshal(reqBody)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
return err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/create", o.baseUrl), bytes.NewReader(reqBodyBytes))
|
||||
req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/copy", o.baseUrl), bytes.NewReader(reqBodyBytes))
|
||||
if err != nil {
|
||||
return -1, err
|
||||
return err
|
||||
}
|
||||
|
||||
for key, val := range o.customHeaders {
|
||||
@@ -31,12 +31,12 @@ func (o Ollama) CopyModel(reqBody CopyModelRequest) (int, error) {
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return resp.StatusCode, errors.New("status code is not 200")
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return errors.New("status code is not 200")
|
||||
}
|
||||
return resp.StatusCode, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user