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
e63ad693
Commit
e63ad693
authored
Jun 28, 2023
by
Michael Yang
Browse files
batch mode
parent
91542980
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
ollama/cmd/cli.py
ollama/cmd/cli.py
+21
-12
No files found.
ollama/cmd/cli.py
View file @
e63ad693
...
@@ -54,15 +54,18 @@ def list_models(*args, **kwargs):
...
@@ -54,15 +54,18 @@ def list_models(*args, **kwargs):
def
generate
(
*
args
,
**
kwargs
):
def
generate
(
*
args
,
**
kwargs
):
if
prompt
:
=
kwargs
.
get
(
'prompt'
):
if
prompt
:
=
kwargs
.
get
(
'prompt'
):
print
(
'>>>'
,
prompt
,
flush
=
True
)
print
(
'>>>'
,
prompt
,
flush
=
True
)
print
(
flush
=
True
)
generate_oneshot
(
*
args
,
**
kwargs
)
generate_oneshot
(
*
args
,
**
kwargs
)
print
(
flush
=
True
)
return
return
return
generate_interactive
(
*
args
,
**
kwargs
)
if
sys
.
stdin
.
isatty
():
return
generate_interactive
(
*
args
,
**
kwargs
)
return
generate_batch
(
*
args
,
**
kwargs
)
def
generate_oneshot
(
*
args
,
**
kwargs
):
def
generate_oneshot
(
*
args
,
**
kwargs
):
print
(
flush
=
True
)
for
output
in
engine
.
generate
(
*
args
,
**
kwargs
):
for
output
in
engine
.
generate
(
*
args
,
**
kwargs
):
output
=
json
.
loads
(
output
)
output
=
json
.
loads
(
output
)
choices
=
output
.
get
(
"choices"
,
[])
choices
=
output
.
get
(
"choices"
,
[])
...
@@ -70,20 +73,26 @@ def generate_oneshot(*args, **kwargs):
...
@@ -70,20 +73,26 @@ def generate_oneshot(*args, **kwargs):
print
(
choices
[
0
].
get
(
"text"
,
""
),
end
=
""
,
flush
=
True
)
print
(
choices
[
0
].
get
(
"text"
,
""
),
end
=
""
,
flush
=
True
)
# end with a new line
# end with a new line
print
()
print
(
flush
=
True
)
print
(
flush
=
True
)
def
generate_interactive
(
*
args
,
**
kwargs
):
def
generate_interactive
(
*
args
,
**
kwargs
):
print
(
'>>> '
,
end
=
''
,
flush
=
True
)
while
True
:
for
line
in
sys
.
stdin
:
print
(
'>>> '
,
end
=
''
,
flush
=
True
)
if
not
sys
.
stdin
.
isatty
():
line
=
next
(
sys
.
stdin
)
print
(
line
,
end
=
''
)
if
not
line
:
return
print
(
flush
=
True
)
kwargs
.
update
({
"prompt"
:
line
})
kwargs
.
update
({
'prompt'
:
line
})
generate_oneshot
(
*
args
,
**
kwargs
)
def
generate_batch
(
*
args
,
**
kwargs
):
for
line
in
sys
.
stdin
:
print
(
'>>> '
,
line
,
end
=
''
,
flush
=
True
)
kwargs
.
update
({
"prompt"
:
line
})
generate_oneshot
(
*
args
,
**
kwargs
)
generate_oneshot
(
*
args
,
**
kwargs
)
print
(
flush
=
True
)
print
(
'>>> '
,
end
=
''
,
flush
=
True
)
def
add
(
model
,
models_home
):
def
add
(
model
,
models_home
):
...
...
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