aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-08-03 22:26:18 -0400
committerXe Iaso <me@xeiaso.net>2024-08-03 22:26:18 -0400
commita702ce19be284f0a287d0f5ff2d4c730c8bc4a07 (patch)
tree9cd3037010230726314a5a40abb28ec6eed89790 /web
parent4ffd197b17689fce979943ffb739a7a1aff4ca12 (diff)
downloadx-a702ce19be284f0a287d0f5ff2d4c730c8bc4a07.tar.xz
x-a702ce19be284f0a287d0f5ff2d4c730c8bc4a07.zip
fuck
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'web')
-rw-r--r--web/ollama/ollama.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/web/ollama/ollama.go b/web/ollama/ollama.go
index 98b24ff..7210c58 100644
--- a/web/ollama/ollama.go
+++ b/web/ollama/ollama.go
@@ -9,6 +9,7 @@ import (
"io"
"log/slog"
"net/http"
+ "os"
"time"
"within.website/x/valid"
@@ -63,11 +64,15 @@ type Tool struct {
Function Function `json:"function"`
}
+type ToolInvocation struct {
+ Function ToolCall `json:"function"`
+}
+
type Message struct {
- Content string `json:"content"`
- Role string `json:"role"`
- Images [][]byte `json:"images"`
- ToolCalls []ToolCall `json:"tool_calls"`
+ Content string `json:"content"`
+ Role string `json:"role"`
+ Images [][]byte `json:"images"`
+ ToolCalls []ToolInvocation `json:"tool_calls"`
}
type CompleteRequest struct {
@@ -118,9 +123,10 @@ func (c *Client) Chat(ctx context.Context, inp *CompleteRequest) (*CompleteRespo
}
var result CompleteResponse
- if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
+ if err := json.NewDecoder(io.TeeReader(resp.Body, os.Stderr)).Decode(&result); err != nil {
return nil, fmt.Errorf("ollama: error decoding response: %w", err)
}
+ fmt.Fprintln(os.Stderr)
return &result, nil
}