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
orangecat
ollama
Commits
e3fb1fd3
Commit
e3fb1fd3
authored
Aug 03, 2023
by
Jeffrey Morgan
Browse files
server: compare options correctly
parent
29b897f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
server/routes.go
server/routes.go
+15
-13
No files found.
server/routes.go
View file @
e3fb1fd3
...
...
@@ -52,25 +52,26 @@ func GenerateHandler(c *gin.Context) {
return
}
if
model
.
Digest
!=
loaded
.
digest
||
!
reflect
.
DeepEqual
(
loaded
.
options
,
req
.
Options
)
{
opts
:=
api
.
DefaultOptions
()
if
err
:=
opts
.
FromMap
(
model
.
Options
);
err
!=
nil
{
log
.
Printf
(
"could not load model options: %v"
,
err
)
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
if
err
:=
opts
.
FromMap
(
req
.
Options
);
err
!=
nil
{
log
.
Printf
(
"could not merge model options: %v"
,
err
)
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
if
model
.
Digest
!=
loaded
.
digest
||
!
reflect
.
DeepEqual
(
loaded
.
options
,
opts
)
{
if
loaded
.
llm
!=
nil
{
loaded
.
llm
.
Close
()
loaded
.
llm
=
nil
loaded
.
digest
=
""
}
opts
:=
api
.
DefaultOptions
()
if
err
:=
opts
.
FromMap
(
model
.
Options
);
err
!=
nil
{
log
.
Printf
(
"could not load model options: %v"
,
err
)
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
if
err
:=
opts
.
FromMap
(
req
.
Options
);
err
!=
nil
{
log
.
Printf
(
"could not merge model options: %v"
,
err
)
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
}
llm
,
err
:=
llama
.
New
(
model
.
ModelPath
,
opts
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
...
...
@@ -79,6 +80,7 @@ func GenerateHandler(c *gin.Context) {
loaded
.
llm
=
llm
loaded
.
digest
=
model
.
Digest
loaded
.
options
=
opts
}
sessionDuration
:=
5
*
time
.
Minute
...
...
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