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
9e5dfc66
"vscode:/vscode.git/clone" did not exist on "558673e139790b6c1d9e2403034b5b35b704324b"
Unverified
Commit
9e5dfc66
authored
Jun 30, 2023
by
Michael Yang
Committed by
GitHub
Jun 30, 2023
Browse files
Merge pull request #29 from jmorganca/pull-model-name
Pull model name
parents
3c5a5436
76fb9eea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
ollama/cmd/cli.py
ollama/cmd/cli.py
+1
-1
ollama/engine.py
ollama/engine.py
+1
-1
ollama/model.py
ollama/model.py
+11
-11
No files found.
ollama/cmd/cli.py
View file @
9e5dfc66
...
...
@@ -151,7 +151,7 @@ def pull(*args, **kwargs):
def
run
(
*
args
,
**
kwargs
):
name
=
model
.
pull
(
*
args
,
**
kwargs
)
name
=
model
.
pull
(
model_name
=
kwargs
.
pop
(
'model'
),
*
args
,
**
kwargs
)
kwargs
.
update
({
"model"
:
name
})
print
(
f
"Running
{
name
}
..."
)
generate
(
*
args
,
**
kwargs
)
ollama/engine.py
View file @
9e5dfc66
...
...
@@ -30,7 +30,7 @@ def load(model_name, models={}):
if
not
models
.
get
(
model_name
,
None
):
model_path
=
path
.
expanduser
(
model_name
)
if
not
path
.
exists
(
model_path
):
model_path
=
path
.
join
(
MODELS_CACHE_PATH
,
model_name
+
".bin"
)
model_path
=
MODELS_CACHE_PATH
/
model_name
+
".bin"
runners
=
{
model_type
:
cls
...
...
ollama/model.py
View file @
9e5dfc66
...
...
@@ -7,7 +7,7 @@ from tqdm import tqdm
MODELS_MANIFEST
=
'https://ollama.ai/api/models'
MODELS_CACHE_PATH
=
path
.
join
(
Path
.
home
()
,
'.ollama'
,
'models'
)
MODELS_CACHE_PATH
=
Path
.
home
()
/
'.ollama'
/
'models'
def
models
(
*
args
,
**
kwargs
):
...
...
@@ -78,7 +78,7 @@ def find_bin_file(json_response, location, branch):
def
download_file
(
download_url
,
file_name
,
file_size
):
local_filename
=
path
.
join
(
MODELS_CACHE_PATH
,
file_name
)
+
'.bin'
local_filename
=
MODELS_CACHE_PATH
/
file_name
+
'.bin'
first_byte
=
path
.
getsize
(
local_filename
)
if
path
.
exists
(
local_filename
)
else
0
...
...
@@ -110,25 +110,25 @@ def download_file(download_url, file_name, file_size):
return
local_filename
def
pull
(
model
,
*
args
,
**
kwargs
):
if
path
.
exists
(
model
):
def
pull
(
model
_name
,
*
args
,
**
kwargs
):
if
path
.
exists
(
model
_name
):
# a file on the filesystem is being specified
return
model
return
model
_name
# check the remote model location and see if it needs to be downloaded
url
=
model
url
=
model
_name
file_name
=
""
if
not
validators
.
url
(
url
)
and
not
url
.
startswith
(
'huggingface.co'
):
url
=
get_url_from_directory
(
model
)
file_name
=
model
url
=
get_url_from_directory
(
model
_name
)
file_name
=
model
_name
if
not
(
url
.
startswith
(
'http://'
)
or
url
.
startswith
(
'https://'
)):
url
=
f
'https://
{
url
}
'
if
not
validators
.
url
(
url
):
if
model
in
models
(
MODELS_CACHE_PATH
):
if
model
_name
in
models
(
MODELS_CACHE_PATH
):
# the model is already downloaded, and specified by name
return
model
raise
Exception
(
f
'Unknown model
{
model
}
'
)
return
model
_name
raise
Exception
(
f
'Unknown model
{
model
_name
}
'
)
local_filename
=
download_from_repo
(
url
,
file_name
)
...
...
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