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
0ebec075
Unverified
Commit
0ebec075
authored
Aug 16, 2023
by
Michael Yang
Committed by
GitHub
Aug 16, 2023
Browse files
Merge pull request #345 from jmorganca/exit-non-zero
set non-zero error code on error
parents
08265515
76b85bc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
cmd/cmd.go
cmd/cmd.go
+23
-3
main.go
main.go
+2
-1
No files found.
cmd/cmd.go
View file @
0ebec075
...
...
@@ -78,6 +78,7 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
spinner
=
NewSpinner
(
resp
.
Status
)
go
spinner
.
Spin
(
100
*
time
.
Millisecond
)
}
return
nil
}
...
...
@@ -87,6 +88,9 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
if
spinner
!=
nil
{
spinner
.
Stop
()
if
spinner
.
description
!=
"success"
{
return
errors
.
New
(
"unexpected end to create model"
)
}
}
return
nil
...
...
@@ -155,6 +159,11 @@ func PushHandler(cmd *cobra.Command, args []string) error {
if
err
:=
client
.
Push
(
context
.
Background
(),
&
request
,
fn
);
err
!=
nil
{
return
err
}
if
bar
!=
nil
&&
!
bar
.
IsFinished
()
{
return
errors
.
New
(
"unexpected end to push model"
)
}
return
nil
}
...
...
@@ -253,12 +262,18 @@ func pull(model string, insecure bool) error {
currentDigest
=
""
fmt
.
Println
(
resp
.
Status
)
}
return
nil
}
if
err
:=
client
.
Pull
(
context
.
Background
(),
&
request
,
fn
);
err
!=
nil
{
return
err
}
if
bar
!=
nil
&&
!
bar
.
IsFinished
()
{
return
errors
.
New
(
"unexpected end to pull model"
)
}
return
nil
}
...
...
@@ -325,6 +340,10 @@ func generate(cmd *cobra.Command, model, prompt string) error {
fmt
.
Println
()
fmt
.
Println
()
if
!
latest
.
Done
{
return
errors
.
New
(
"unexpected end of response"
)
}
verbose
,
err
:=
cmd
.
Flags
()
.
GetBool
(
"verbose"
)
if
err
!=
nil
{
return
err
...
...
@@ -688,9 +707,10 @@ func NewCLI() *cobra.Command {
log
.
SetFlags
(
log
.
LstdFlags
|
log
.
Lshortfile
)
rootCmd
:=
&
cobra
.
Command
{
Use
:
"ollama"
,
Short
:
"Large language model runner"
,
SilenceUsage
:
true
,
Use
:
"ollama"
,
Short
:
"Large language model runner"
,
SilenceUsage
:
true
,
SilenceErrors
:
true
,
CompletionOptions
:
cobra
.
CompletionOptions
{
DisableDefaultCmd
:
true
,
},
...
...
main.go
View file @
0ebec075
...
...
@@ -4,8 +4,9 @@ import (
"context"
"github.com/jmorganca/ollama/cmd"
"github.com/spf13/cobra"
)
func
main
()
{
cmd
.
NewCLI
()
.
ExecuteContext
(
context
.
Background
())
cobra
.
CheckErr
(
cmd
.
NewCLI
()
.
ExecuteContext
(
context
.
Background
())
)
}
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