Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
e20362e0
Commit
e20362e0
authored
Sep 22, 2023
by
Jeffrey Morgan
Browse files
fix multi line input in `ollama run`
parent
c928ceb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
cmd/cmd.go
cmd/cmd.go
+10
-6
No files found.
cmd/cmd.go
View file @
e20362e0
...
...
@@ -32,11 +32,13 @@ import (
"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"
)
if
termType
==
"xterm-256color"
&&
len
(
line
)
==
0
{
if
termType
==
"xterm-256color"
&&
len
(
line
)
==
0
&&
!
p
.
HideHint
{
prompt
:=
"Send a message (/? for help)"
return
[]
rune
(
fmt
.
Sprintf
(
"
\0
33[38;5;245m%s
\0
33[%dD
\0
33[0m"
,
prompt
,
len
(
prompt
)))
}
...
...
@@ -538,8 +540,10 @@ func generateInteractive(cmd *cobra.Command, model string) error {
fmt
.
Fprintln
(
os
.
Stderr
,
completer
.
Tree
(
" "
))
}
var
painter
Painter
config
:=
readline
.
Config
{
Painter
:
P
ainter
{}
,
Painter
:
&
p
ainter
,
Prompt
:
">>> "
,
HistoryFile
:
filepath
.
Join
(
home
,
".ollama"
,
"history"
),
AutoComplete
:
completer
,
...
...
@@ -575,11 +579,10 @@ func generateInteractive(cmd *cobra.Command, model string) error {
case
isMultiLine
:
if
strings
.
HasSuffix
(
line
,
`"""`
)
{
isMultiLine
=
false
painter
.
HideHint
=
false
multiLineBuffer
+=
strings
.
TrimSuffix
(
line
,
`"""`
)
line
=
multiLineBuffer
multiLineBuffer
=
""
scanner
.
SetPrompt
(
">>> "
)
continue
}
else
{
multiLineBuffer
+=
line
+
" "
continue
...
...
@@ -588,6 +591,7 @@ func generateInteractive(cmd *cobra.Command, model string) error {
isMultiLine
=
true
multiLineBuffer
=
strings
.
TrimPrefix
(
line
,
`"""`
)
+
" "
scanner
.
SetPrompt
(
"... "
)
painter
.
HideHint
=
true
continue
case
strings
.
HasPrefix
(
line
,
"/list"
)
:
args
:=
strings
.
Fields
(
line
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment