aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-02-04 08:52:45 -0500
committerXe Iaso <me@xeiaso.net>2024-02-04 08:53:04 -0500
commit34931ffe019cfc3c7dc3195606488394805a9008 (patch)
tree60744c7dff1c9cdee235b608a4e13a7000da30c6 /web
parent60939a2e6ce459ffabb02e365bdaef66f006e8ae (diff)
downloadx-34931ffe019cfc3c7dc3195606488394805a9008.tar.xz
x-34931ffe019cfc3c7dc3195606488394805a9008.zip
cmd/mimi: increase keepalive, ground output
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'web')
-rw-r--r--web/ollama/ollama.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/web/ollama/ollama.go b/web/ollama/ollama.go
index c679ec3..29f0da9 100644
--- a/web/ollama/ollama.go
+++ b/web/ollama/ollama.go
@@ -7,6 +7,8 @@ import (
"fmt"
"net/http"
"time"
+
+ "within.website/x/web"
)
type Client struct {
@@ -36,7 +38,7 @@ type CompleteRequest struct {
Template *string `json:"template,omitempty"`
Stream bool `json:"stream"`
Options map[string]any `json:"options"`
- KeepAlive string `json:"keep_alive"`
+ KeepAlive time.Duration `json:"keep_alive"`
}
type CompleteResponse struct {
@@ -53,7 +55,7 @@ type CompleteResponse struct {
}
func (c *Client) Chat(ctx context.Context, inp *CompleteRequest) (*CompleteResponse, error) {
- inp.KeepAlive = "-1"
+ inp.KeepAlive = 24 * time.Hour
buf := &bytes.Buffer{}
if err := json.NewEncoder(buf).Encode(inp); err != nil {
@@ -74,6 +76,10 @@ func (c *Client) Chat(ctx context.Context, inp *CompleteRequest) (*CompleteRespo
}
defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ return nil, web.NewError(http.StatusOK, resp)
+ }
+
var result CompleteResponse
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, fmt.Errorf("ollama: error decoding response: %w", err)