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
a86a4f8c
Commit
a86a4f8c
authored
Jul 04, 2023
by
Bruce MacDonald
Browse files
resume download of models from directory
parent
35f202f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
ollama/cmd/cli.py
ollama/cmd/cli.py
+12
-6
ollama/model.py
ollama/model.py
+16
-6
No files found.
ollama/cmd/cli.py
View file @
a86a4f8c
...
...
@@ -175,12 +175,18 @@ def search(*args, **kwargs):
def
pull
(
*
args
,
**
kwargs
):
model
.
pull
(
model_name
=
kwargs
.
pop
(
'model'
),
*
args
,
**
kwargs
)
print
(
"Up to date."
)
try
:
model
.
pull
(
model_name
=
kwargs
.
pop
(
'model'
),
*
args
,
**
kwargs
)
print
(
"Up to date."
)
except
Exception
as
e
:
print
(
f
"An error occurred:
{
e
}
"
)
def
run
(
*
args
,
**
kwargs
):
name
=
model
.
pull
(
model_name
=
kwargs
.
pop
(
'model'
),
*
args
,
**
kwargs
)
kwargs
.
update
({
"model"
:
name
})
print
(
f
"Running
{
name
}
..."
)
generate
(
*
args
,
**
kwargs
)
try
:
name
=
model
.
pull
(
model_name
=
kwargs
.
pop
(
'model'
),
*
args
,
**
kwargs
)
kwargs
.
update
({
"model"
:
name
})
print
(
f
"Running
{
name
}
..."
)
generate
(
*
args
,
**
kwargs
)
except
Exception
as
e
:
print
(
f
"An error occurred:
{
e
}
"
)
ollama/model.py
View file @
a86a4f8c
...
...
@@ -123,16 +123,26 @@ def download_file(download_url, file_name, file_size):
def
pull
(
model_name
,
*
args
,
**
kwargs
):
maybe_existing_model_location
=
MODELS_CACHE_PATH
/
str
(
model_name
+
'.bin'
)
if
path
.
exists
(
model_name
)
or
path
.
exists
(
maybe_existing_model_location
):
# a file on the filesystem is being specified
return
model_name
# check the remote model location and see if it needs to be downloaded
url
=
model_name
file_name
=
""
if
not
validators
.
url
(
url
)
and
not
url
.
startswith
(
'huggingface.co'
):
url
=
get_url_from_directory
(
model_name
)
file_name
=
model_name
try
:
url
=
get_url_from_directory
(
model_name
)
except
Exception
as
e
:
# may not have been able to check remote directory, return now
return
model_name
if
url
is
model_name
:
# this is not a model from our directory, so can't check remote
maybe_existing_model_location
=
MODELS_CACHE_PATH
/
str
(
model_name
+
'.bin'
)
if
path
.
exists
(
model_name
)
or
path
.
exists
(
maybe_existing_model_location
):
# a file on the filesystem is being specified
return
model_name
raise
Exception
(
"unknown model"
)
else
:
# this is a model from our directory, check remote
file_name
=
model_name
if
not
(
url
.
startswith
(
'http://'
)
or
url
.
startswith
(
'https://'
)):
url
=
f
'https://
{
url
}
'
...
...
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