|
@@ -32,11 +32,13 @@ import (
|
|
"github.com/jmorganca/ollama/version"
|
|
"github.com/jmorganca/ollama/version"
|
|
)
|
|
)
|
|
|
|
|
|
-type Painter struct{}
|
|
|
|
|
|
+type Painter struct {
|
|
|
|
+ HideHint bool
|
|
|
|
+}
|
|
|
|
|
|
-func (p Painter) Paint(line []rune, l int) []rune {
|
|
|
|
|
|
+func (p Painter) Paint(line []rune, _ int) []rune {
|
|
termType := os.Getenv("TERM")
|
|
termType := os.Getenv("TERM")
|
|
- if termType == "xterm-256color" && len(line) == 0 {
|
|
|
|
|
|
+ if termType == "xterm-256color" && len(line) == 0 && !p.HideHint {
|
|
prompt := "Send a message (/? for help)"
|
|
prompt := "Send a message (/? for help)"
|
|
return []rune(fmt.Sprintf("\033[38;5;245m%s\033[%dD\033[0m", prompt, len(prompt)))
|
|
return []rune(fmt.Sprintf("\033[38;5;245m%s\033[%dD\033[0m", prompt, len(prompt)))
|
|
}
|
|
}
|
|
@@ -538,8 +540,10 @@ func generateInteractive(cmd *cobra.Command, model string) error {
|
|
fmt.Fprintln(os.Stderr, completer.Tree(" "))
|
|
fmt.Fprintln(os.Stderr, completer.Tree(" "))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var painter Painter
|
|
|
|
+
|
|
config := readline.Config{
|
|
config := readline.Config{
|
|
- Painter: Painter{},
|
|
|
|
|
|
+ Painter: &painter,
|
|
Prompt: ">>> ",
|
|
Prompt: ">>> ",
|
|
HistoryFile: filepath.Join(home, ".ollama", "history"),
|
|
HistoryFile: filepath.Join(home, ".ollama", "history"),
|
|
AutoComplete: completer,
|
|
AutoComplete: completer,
|
|
@@ -575,11 +579,10 @@ func generateInteractive(cmd *cobra.Command, model string) error {
|
|
case isMultiLine:
|
|
case isMultiLine:
|
|
if strings.HasSuffix(line, `"""`) {
|
|
if strings.HasSuffix(line, `"""`) {
|
|
isMultiLine = false
|
|
isMultiLine = false
|
|
|
|
+ painter.HideHint = false
|
|
multiLineBuffer += strings.TrimSuffix(line, `"""`)
|
|
multiLineBuffer += strings.TrimSuffix(line, `"""`)
|
|
- line = multiLineBuffer
|
|
|
|
multiLineBuffer = ""
|
|
multiLineBuffer = ""
|
|
scanner.SetPrompt(">>> ")
|
|
scanner.SetPrompt(">>> ")
|
|
- continue
|
|
|
|
} else {
|
|
} else {
|
|
multiLineBuffer += line + " "
|
|
multiLineBuffer += line + " "
|
|
continue
|
|
continue
|
|
@@ -588,6 +591,7 @@ func generateInteractive(cmd *cobra.Command, model string) error {
|
|
isMultiLine = true
|
|
isMultiLine = true
|
|
multiLineBuffer = strings.TrimPrefix(line, `"""`) + " "
|
|
multiLineBuffer = strings.TrimPrefix(line, `"""`) + " "
|
|
scanner.SetPrompt("... ")
|
|
scanner.SetPrompt("... ")
|
|
|
|
+ painter.HideHint = true
|
|
continue
|
|
continue
|
|
case strings.HasPrefix(line, "/list"):
|
|
case strings.HasPrefix(line, "/list"):
|
|
args := strings.Fields(line)
|
|
args := strings.Fields(line)
|