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 {
if
err
:=
pull
(
args
[
0
]);
err
!=
nil
{
return
err
}
fmt
.
Println
(
"Up to date."
)
case
err
!=
nil
:
return
err
}
...
...
@@ -45,20 +43,27 @@ func RunRun(cmd *cobra.Command, args []string) error {
}
func
pull
(
model
string
)
error
{
client
:=
api
.
NewClient
()
var
bar
*
progressbar
.
ProgressBar
return
client
.
Pull
(
context
.
Background
(),
&
api
.
PullRequest
{
Model
:
model
},
func
(
progress
api
.
PullProgress
)
error
{
if
bar
==
nil
{
bar
=
progressbar
.
DefaultBytes
(
progress
.
Total
)
}
return
bar
.
Set64
(
progress
.
Completed
)
},
)
// TODO: check if the local model is up to date with remote
_
,
err
:=
os
.
Stat
(
cacheDir
()
+
"/models/"
+
model
+
".bin"
)
switch
{
case
errors
.
Is
(
err
,
os
.
ErrNotExist
)
:
client
:=
api
.
NewClient
()
var
bar
*
progressbar
.
ProgressBar
return
client
.
Pull
(
context
.
Background
(),
&
api
.
PullRequest
{
Model
:
model
},
func
(
progress
api
.
PullProgress
)
error
{
if
bar
==
nil
{
bar
=
progressbar
.
DefaultBytes
(
progress
.
Total
)
}
return
bar
.
Set64
(
progress
.
Completed
)
},
)
case
err
!=
nil
:
return
err
}
return
nil
}
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