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
41419f75
"...text-generation-inference.git" did not exist on "55bd4fed7da83a566dca08b0bb29dbc5929a90eb"
Commit
41419f75
authored
Jun 26, 2023
by
Bruce MacDonald
Browse files
take full path to the model in the api
parent
df5fdd66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
ollama.py
ollama.py
+4
-4
No files found.
ollama.py
View file @
41419f75
...
@@ -17,16 +17,16 @@ lock = threading.Lock()
...
@@ -17,16 +17,16 @@ lock = threading.Lock()
def
load
(
model
):
def
load
(
model
):
with
lock
:
with
lock
:
if
not
os
.
path
.
exists
(
f
"
./models/
{
model
}
.bin
"
):
if
not
os
.
path
.
exists
(
f
"
{
model
}
"
):
return
{
"error"
:
"The model does not exist."
}
return
{
"error"
:
"The model does not exist."
}
if
model
not
in
llms
:
if
model
not
in
llms
:
llms
[
model
]
=
Llama
(
model_path
=
f
"
./models/
{
model
}
.bin
"
)
llms
[
model
]
=
Llama
(
model_path
=
f
"
{
model
}
"
)
return
None
return
None
def
unload
(
model
):
def
unload
(
model
):
with
lock
:
with
lock
:
if
not
os
.
path
.
exists
(
f
"
./models/
{
model
}
.bin
"
):
if
not
os
.
path
.
exists
(
f
"
{
model
}
"
):
return
{
"error"
:
"The model does not exist."
}
return
{
"error"
:
"The model does not exist."
}
llms
.
pop
(
model
,
None
)
llms
.
pop
(
model
,
None
)
return
None
return
None
...
@@ -89,7 +89,7 @@ def generate_route_handler():
...
@@ -89,7 +89,7 @@ def generate_route_handler():
return
Response
(
"Model is required"
,
status
=
400
)
return
Response
(
"Model is required"
,
status
=
400
)
if
not
prompt
:
if
not
prompt
:
return
Response
(
"Prompt is required"
,
status
=
400
)
return
Response
(
"Prompt is required"
,
status
=
400
)
if
not
os
.
path
.
exists
(
f
"
./models/
{
model
}
.bin
"
):
if
not
os
.
path
.
exists
(
f
"
{
model
}
"
):
return
{
"error"
:
"The model does not exist."
},
400
return
{
"error"
:
"The model does not exist."
},
400
return
Response
(
return
Response
(
stream_with_context
(
query
(
model
,
prompt
)),
mimetype
=
"text/event-stream"
stream_with_context
(
query
(
model
,
prompt
)),
mimetype
=
"text/event-stream"
...
...
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