Skip to content

Commit 0dcb3ed

Browse files
localai-botclaude
andcommitted
feat: improve CLI error messages with actionable guidance
- transcript.go: Model not found error now suggests available models commands - util.go: GGUF error explains format and how to get models - worker_p2p.go: Token error explains purpose and how to obtain one - run.go: Startup failure includes troubleshooting steps and docs link - model_config_loader.go: Config validation errors include file path and guidance Refs: H2 - UX Review Issue Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: localai-bot <localai-bot@noreply.github.com>
1 parent 9db6be3 commit 0dcb3ed

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

core/cli/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (r *RunCMD) Run(ctx *cliContext.Context) error {
289289

290290
app, err := application.New(opts...)
291291
if err != nil {
292-
return fmt.Errorf("failed basic startup tasks with error %s", err.Error())
292+
return fmt.Errorf("LocalAI failed to start: %w.\nTroubleshooting steps:\n 1. Check that your models directory exists and is accessible: %s\n 2. Verify model config files are valid YAML: 'local-ai util usecase-heuristic <config>'\n 3. Check available disk space and file permissions\n 4. Run with --log-level=debug for more details\nSee https://localai.io/basics/troubleshooting/ for more help", err, r.ModelsPath)
293293
}
294294

295295
appHTTP, err := http.API(app)

core/cli/transcript.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cli
33
import (
44
"context"
55
"encoding/json"
6-
"errors"
76
"fmt"
87
"strings"
98

@@ -61,7 +60,7 @@ func (t *TranscriptCMD) Run(ctx *cliContext.Context) error {
6160

6261
c, exists := cl.GetModelConfig(t.Model)
6362
if !exists {
64-
return errors.New("model not found")
63+
return fmt.Errorf("model %q not found. Run 'local-ai models list' to see available models, or install one with 'local-ai models install <model>'. See https://localai.io/models/ for more information", t.Model)
6564
}
6665

6766
c.Threads = &t.Threads

core/cli/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (u *CreateOCIImageCMD) Run(ctx *cliContext.Context) error {
7474

7575
func (u *GGUFInfoCMD) Run(ctx *cliContext.Context) error {
7676
if len(u.Args) == 0 {
77-
return fmt.Errorf("no GGUF file provided")
77+
return fmt.Errorf("no GGUF file provided. Usage: local-ai util gguf-info <path-to-file.gguf>\nGGUF is a binary format for storing quantized language models. You can download GGUF models from https://huggingface.co or install one with 'local-ai models install <model>'")
7878
}
7979
// We try to guess only if we don't have a template defined already
8080
f, err := gguf.ParseGGUFFile(u.Args[0])

core/cli/worker/worker_p2p.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (r *P2P) Run(ctx *cliContext.Context) error {
3838
// Check if the token is set
3939
// as we always need it.
4040
if r.Token == "" {
41-
return fmt.Errorf("Token is required")
41+
return fmt.Errorf("a P2P token is required to join the network. Set it via the LOCALAI_TOKEN environment variable or the --token flag. You can generate a token by running 'local-ai run --p2p' on the main node. See https://localai.io/features/distribute/ for more information")
4242
}
4343

4444
port, err := freeport.GetFreePort()

core/config/model_config_loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ func (bcl *ModelConfigLoader) ReadModelConfig(file string, opts ...ConfigLoaderO
190190
bcl.configs[c.Name] = *c
191191
} else {
192192
if err != nil {
193-
return fmt.Errorf("config is not valid: %w", err)
193+
return fmt.Errorf("model config %q is not valid: %w. Ensure the YAML file has a valid 'name' field and correct syntax. See https://localai.io/docs/getting-started/customize-model/ for config reference", file, err)
194194
}
195-
return fmt.Errorf("config is not valid")
195+
return fmt.Errorf("model config %q is not valid. Ensure the YAML file has a valid 'name' field and correct syntax. See https://localai.io/docs/getting-started/customize-model/ for config reference", file)
196196
}
197197

198198
return nil

0 commit comments

Comments
 (0)