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
ad841384
Commit
ad841384
authored
Jul 07, 2023
by
Bruce MacDonald
Browse files
do not pull when local is available
parent
a88576e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
cmd/cmd.go
cmd/cmd.go
+21
-16
No files found.
cmd/cmd.go
View file @
ad841384
...
@@ -35,8 +35,6 @@ func RunRun(cmd *cobra.Command, args []string) error {
...
@@ -35,8 +35,6 @@ func RunRun(cmd *cobra.Command, args []string) error {
if
err
:=
pull
(
args
[
0
]);
err
!=
nil
{
if
err
:=
pull
(
args
[
0
]);
err
!=
nil
{
return
err
return
err
}
}
fmt
.
Println
(
"Up to date."
)
case
err
!=
nil
:
case
err
!=
nil
:
return
err
return
err
}
}
...
@@ -45,20 +43,27 @@ func RunRun(cmd *cobra.Command, args []string) error {
...
@@ -45,20 +43,27 @@ func RunRun(cmd *cobra.Command, args []string) error {
}
}
func
pull
(
model
string
)
error
{
func
pull
(
model
string
)
error
{
client
:=
api
.
NewClient
()
// TODO: check if the local model is up to date with remote
_
,
err
:=
os
.
Stat
(
cacheDir
()
+
"/models/"
+
model
+
".bin"
)
var
bar
*
progressbar
.
ProgressBar
switch
{
return
client
.
Pull
(
case
errors
.
Is
(
err
,
os
.
ErrNotExist
)
:
context
.
Background
(),
client
:=
api
.
NewClient
()
&
api
.
PullRequest
{
Model
:
model
},
var
bar
*
progressbar
.
ProgressBar
func
(
progress
api
.
PullProgress
)
error
{
return
client
.
Pull
(
if
bar
==
nil
{
context
.
Background
(),
bar
=
progressbar
.
DefaultBytes
(
progress
.
Total
)
&
api
.
PullRequest
{
Model
:
model
},
}
func
(
progress
api
.
PullProgress
)
error
{
if
bar
==
nil
{
return
bar
.
Set64
(
progress
.
Completed
)
bar
=
progressbar
.
DefaultBytes
(
progress
.
Total
)
},
}
)
return
bar
.
Set64
(
progress
.
Completed
)
},
)
case
err
!=
nil
:
return
err
}
return
nil
}
}
func
RunGenerate
(
_
*
cobra
.
Command
,
args
[]
string
)
error
{
func
RunGenerate
(
_
*
cobra
.
Command
,
args
[]
string
)
error
{
...
...
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