relay model runner error message to client (#720)

* give direction to user when runner fails
* also relay errors from timeout
* increase timeout to 3 minutes
This commit is contained in:
Bruce MacDonald
2023-10-12 11:16:37 -04:00
committed by GitHub
parent 92578798bb
commit 56497663c8
2 changed files with 42 additions and 15 deletions

View File

@@ -479,18 +479,7 @@ func generate(cmd *cobra.Command, model, prompt string, wordWrap bool) error {
}
if err := client.Generate(cancelCtx, &request, fn); err != nil {
if strings.Contains(err.Error(), "failed to load model") {
// tell the user to check the server log, if it exists locally
home, nestedErr := os.UserHomeDir()
if nestedErr != nil {
// return the original error
return err
}
logPath := filepath.Join(home, ".ollama", "logs", "server.log")
if _, nestedErr := os.Stat(logPath); nestedErr == nil {
err = fmt.Errorf("%w\nFor more details, check the error logs at %s", err, logPath)
}
} else if strings.Contains(err.Error(), "context canceled") && abort {
if strings.Contains(err.Error(), "context canceled") && abort {
spinner.Finish()
return nil
}