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
01d2667f
Commit
01d2667f
authored
Jun 27, 2023
by
Bruce MacDonald
Browse files
add function
parent
74549007
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
README.md
README.md
+8
-8
ollama/cmd/cli.py
ollama/cmd/cli.py
+3
-3
ollama/engine.py
ollama/engine.py
+7
-0
No files found.
README.md
View file @
01d2667f
...
...
@@ -50,22 +50,22 @@ models = ollama.models()
Serve the ollama http server
##
Cooming Soon
##
# `ollama.add(filepath)`
### `ollama.pull(model)`
Download a model
Add a model by importing from a file
```
python
ollama
.
pull
(
"huggingface.co/thebloke/llama-7b-ggm
l"
)
ollama
.
add
(
"./path/to/mode
l"
)
```
##
# `ollama.import(filename)`
##
Cooming Soon
Import a model from a file
### `ollama.pull(model)`
Download a model
```
python
ollama
.
import
(
"./path/to/mode
l"
)
ollama
.
pull
(
"huggingface.co/thebloke/llama-7b-ggm
l"
)
```
### `ollama.search("query")`
...
...
ollama/cmd/cli.py
View file @
01d2667f
...
...
@@ -23,8 +23,8 @@ def main():
generate_parser
.
set_defaults
(
fn
=
generate
)
add_parser
=
subparsers
.
add_parser
(
"add"
)
add_parser
.
add_argument
(
"
model_
file"
)
generate
_parser
.
set_defaults
(
fn
=
add
)
add_parser
.
add_argument
(
"file"
)
add
_parser
.
set_defaults
(
fn
=
add
)
args
=
parser
.
parse_args
()
args
=
vars
(
args
)
...
...
@@ -48,4 +48,4 @@ def generate(*args, **kwargs):
def
add
(
*
args
,
**
kwargs
):
model
.
add
(
*
args
,
**
kwargs
)
engine
.
add
(
*
args
,
**
kwargs
)
ollama/engine.py
View file @
01d2667f
import
os
import
json
import
sys
import
shutil
from
contextlib
import
contextmanager
from
llama_cpp
import
Llama
as
LLM
from
template
import
template
...
...
@@ -61,3 +62,9 @@ def load(model, models_home=".", llms={}):
def
unload
(
model
,
llms
=
{}):
if
model
in
llms
:
llms
.
pop
(
model
)
def
add
(
file
,
models_home
=
"."
,
*
args
,
**
kwargs
):
if
not
os
.
path
.
exists
(
file
):
raise
ValueError
(
"Model file {model} not found"
)
shutil
.
move
(
file
,
models_home
)
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