Skip to content

Commit 9612c31

Browse files
committed
Few minor fixes in the main
1 parent 1ca4d87 commit 9612c31

1 file changed

Lines changed: 28 additions & 34 deletions

File tree

src/repl/main.go

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,10 @@ func runStdinMode(config *Config, args []string) {
7878

7979
// Send to LLM without streaming (for stdin mode)
8080
res, err := client.SendMessageWithImages(messages, false, images)
81-
fmt.Println(res)
82-
8381
if err != nil {
8482
fmt.Fprintf(os.Stderr, "REPL error: %v\n", err)
85-
if config.PROVIDER == "ollama" {
86-
fmt.Fprintf(os.Stderr, "Ollama troubleshooting tips:\n")
87-
fmt.Fprintf(os.Stderr, "1. Check if Ollama is running: ps aux | grep ollama\n")
88-
fmt.Fprintf(os.Stderr, "2. Verify Ollama server is accessible at %s:%s\n", config.OllamaHost, config.OllamaPort)
89-
fmt.Fprintf(os.Stderr, "3. Confirm model '%s' is available: ollama list\n", config.OllamaModel)
90-
fmt.Fprintf(os.Stderr, "4. Try pulling the model: ollama pull %s\n", config.OllamaModel)
91-
}
92-
// No need to exit on connection errors - matches REPL behavior
9383
}
84+
fmt.Println(res)
9485
}
9586

9687
type ClaudeRequest struct {
@@ -813,23 +804,22 @@ BEDROCK_MODEL=anthropic.claude-3-5-sonnet-v1
813804
}
814805
func showHelp() {
815806
fmt.Print(`$ mai-repl [--] | [-h] | [prompt] < INPUT
816-
-- = stdin mode
817-
-1 = don't stream response, print once at the end
818-
-a <string> = set the user agent for HTTP requests
819-
-b <url> = specify a custom base URL for API requests
820-
-c <key=value> = set configuration option
821-
-h = show this help message
822-
-H = show help for the environment variables (same as -hh)
823-
-i <path> = attach an image to send to the model
824-
-m <model> = select the model for the given provider
825-
-n = do not load ~/.mairc
826-
-p <provider> = select the provider to use
827-
-r = enter the repl mode (default behaviour) (see -- for stdin mode)
828-
-s = don't display the ---8<--- lines in the output
829-
-t = enable tools processing
807+
-- stdin mode (see -r)
808+
-1 don't stream response, print once at the end
809+
-a <string> set the user agent for HTTP requests
810+
-b <url> specify a custom base URL for API requests
811+
-c <key=value> set configuration option
812+
-h show this help message
813+
-H show environment variables help (same as -hh)
814+
-i <path> attach an image to send to the model
815+
-m <model> select the model for the given provider
816+
-n do not load ~/.mairc
817+
-p <provider> select the provider to use
818+
-t enable tools processing
830819
Files:
831-
~/.mairc : script to be loaded before the repl is shown
832-
./prompts : directory containing custom prompts
820+
~/.mairc : script to be loaded before the repl is shown
821+
~/.mai/chats : storage for all the mai chats
822+
./prompts : directory containing custom prompts
833823
`)
834824
}
835825

@@ -886,6 +876,7 @@ func main() {
886876
if defaultModel := os.Getenv("MAI_MODEL"); defaultModel != "" {
887877
setModelForProvider(config, defaultModel)
888878
}
879+
replMode := false
889880

890881
// Process command line flags
891882
for i := 0; i < len(args); i++ {
@@ -895,10 +886,12 @@ func main() {
895886
config.SkipRcFile = true
896887
args = append(args[:i], args[i+1:]...)
897888
i--
898-
case "-s":
899-
config.ShowScissors = true
900-
args = append(args[:i], args[i+1:]...)
901-
i--
889+
/*
890+
case "-s":
891+
config.ShowScissors = true
892+
args = append(args[:i], args[i+1:]...)
893+
i--
894+
*/
902895
case "-t":
903896
// Set usetools to true
904897
config.options.Set("usetools", "true")
@@ -926,6 +919,8 @@ func main() {
926919
fmt.Fprintf(os.Stderr, "Error: -p requires a provider argument\n")
927920
os.Exit(1)
928921
}
922+
case "-r":
923+
replMode = true
929924
case "-b":
930925
if i+1 < len(args) {
931926
config.BaseURL = args[i+1]
@@ -976,7 +971,7 @@ func main() {
976971

977972
// Check for REPL mode: interactive terminal or explicit -r flag
978973
stdinIsTerminal := term.IsTerminal(int(os.Stdin.Fd()))
979-
if (len(args) > 0 && args[0] == "-r") || (len(args) == 0 && stdinIsTerminal) {
974+
if replMode || stdinIsTerminal {
980975
// Not stdin mode, will load .mairc
981976
config.IsStdinMode = false
982977

@@ -986,15 +981,14 @@ func main() {
986981
os.Exit(1)
987982
}
988983

984+
// TODO: use MAI_COLORS ?
985+
// repl.config.options.Set("markdown", "false")
989986
if err := repl.Run(); err != nil {
990987
fmt.Fprintf(os.Stderr, "REPL error: %v\n", err)
991988
os.Exit(1)
992989
}
993990
} else {
994-
995-
// If we got here, we're in stdin mode
996991
config.IsStdinMode = true
997-
998992
runStdinMode(config, args)
999993
}
1000994
}

0 commit comments

Comments
 (0)