ollama client library: Include command output in the error message.

This helps debugging ollama-based tests.

PiperOrigin-RevId: 597316714
This commit is contained in:
Etienne Perot
2024-01-10 12:02:39 -08:00
committed by gVisor bot
parent 5b33e4a3d8
commit 99de8a774d
+7 -1
View File
@@ -124,7 +124,13 @@ func (llm *Ollama) request(ctx context.Context, endpoint string, data []byte) ([
Image: "basic/busybox",
Links: []string{llm.container.MakeLink("llm")},
}, cmd...)
return []byte(out), err
if err != nil {
if out != "" {
return []byte(out), fmt.Errorf("command %q failed (%w): %v", strings.Join(cmd, " "), err, out)
}
return nil, fmt.Errorf("could not run command %q: %w", strings.Join(cmd, " "), err)
}
return []byte(out), nil
}
// jsonGet performs a JSON HTTP GET request.