From a702ce19be284f0a287d0f5ff2d4c730c8bc4a07 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 3 Aug 2024 22:26:18 -0400 Subject: fuck Signed-off-by: Xe Iaso --- llm/codeinterpreter/python/python.go | 9 +++++---- web/ollama/ollama.go | 16 +++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/llm/codeinterpreter/python/python.go b/llm/codeinterpreter/python/python.go index 06457b1..5f2ac6f 100644 --- a/llm/codeinterpreter/python/python.go +++ b/llm/codeinterpreter/python/python.go @@ -4,7 +4,6 @@ import ( "bytes" "context" _ "embed" - "fmt" "os" "github.com/tetratelabs/wazero" @@ -63,9 +62,11 @@ func Run(ctx context.Context, tmpDir, userCode string) (*Result, error) { mod, err := r.InstantiateModule(ctx, code, config) if err != nil { - fmt.Println(fout.String()) - fmt.Println(ferr.String()) - return nil, err + result := &Result{ + Stdout: fout.String(), + Stderr: ferr.String(), + } + return result, err } defer mod.Close(ctx) 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 } -- cgit v1.2.3