aboutsummaryrefslogtreecommitdiff
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
parent4ffd197b17689fce979943ffb739a7a1aff4ca12 (diff)
downloadx-a702ce19be284f0a287d0f5ff2d4c730c8bc4a07.tar.xz
x-a702ce19be284f0a287d0f5ff2d4c730c8bc4a07.zip
fuck
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--llm/codeinterpreter/python/python.go9
-rw-r--r--web/ollama/ollama.go16
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
}