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
464d8178
Unverified
Commit
464d8178
authored
Apr 02, 2024
by
Daniel Hiltgen
Committed by
GitHub
Apr 02, 2024
Browse files
Merge pull request #3464 from dhiltgen/subprocess
Fix numgpu opt miscomparison
parents
531324a9
6589eb8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
llm/server.go
llm/server.go
+2
-2
server/routes.go
server/routes.go
+5
-5
No files found.
llm/server.go
View file @
464d8178
...
@@ -33,14 +33,14 @@ type LlamaServer struct {
...
@@ -33,14 +33,14 @@ type LlamaServer struct {
cmd
*
exec
.
Cmd
cmd
*
exec
.
Cmd
done
chan
error
// Channel to signal when the process exits
done
chan
error
// Channel to signal when the process exits
status
*
StatusWriter
status
*
StatusWriter
options
*
api
.
Options
options
api
.
Options
}
}
var
cpuOnlyFamilies
=
[]
string
{
var
cpuOnlyFamilies
=
[]
string
{
"mamba"
,
"mamba"
,
}
}
func
NewLlamaServer
(
model
string
,
adapters
,
projectors
[]
string
,
opts
*
api
.
Options
)
(
*
LlamaServer
,
error
)
{
func
NewLlamaServer
(
model
string
,
adapters
,
projectors
[]
string
,
opts
api
.
Options
)
(
*
LlamaServer
,
error
)
{
if
_
,
err
:=
os
.
Stat
(
model
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
model
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
server/routes.go
View file @
464d8178
...
@@ -69,7 +69,7 @@ var loaded struct {
...
@@ -69,7 +69,7 @@ var loaded struct {
var
defaultSessionDuration
=
5
*
time
.
Minute
var
defaultSessionDuration
=
5
*
time
.
Minute
// load a model into memory if it is not already loaded, it is up to the caller to lock loaded.mu before calling this function
// load a model into memory if it is not already loaded, it is up to the caller to lock loaded.mu before calling this function
func
load
(
c
*
gin
.
Context
,
model
*
Model
,
opts
*
api
.
Options
,
sessionDuration
time
.
Duration
)
error
{
func
load
(
c
*
gin
.
Context
,
model
*
Model
,
opts
api
.
Options
,
sessionDuration
time
.
Duration
)
error
{
ctx
,
cancel
:=
context
.
WithTimeout
(
c
,
10
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
c
,
10
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
...
@@ -107,7 +107,7 @@ func load(c *gin.Context, model *Model, opts *api.Options, sessionDuration time.
...
@@ -107,7 +107,7 @@ func load(c *gin.Context, model *Model, opts *api.Options, sessionDuration time.
loaded
.
adapters
=
model
.
AdapterPaths
loaded
.
adapters
=
model
.
AdapterPaths
loaded
.
projectors
=
model
.
ProjectorPaths
loaded
.
projectors
=
model
.
ProjectorPaths
loaded
.
llama
=
llama
loaded
.
llama
=
llama
loaded
.
Options
=
opts
loaded
.
Options
=
&
opts
}
}
if
loaded
.
expireTimer
==
nil
{
if
loaded
.
expireTimer
==
nil
{
...
@@ -220,7 +220,7 @@ func GenerateHandler(c *gin.Context) {
...
@@ -220,7 +220,7 @@ func GenerateHandler(c *gin.Context) {
sessionDuration
=
req
.
KeepAlive
.
Duration
sessionDuration
=
req
.
KeepAlive
.
Duration
}
}
if
err
:=
load
(
c
,
model
,
&
opts
,
sessionDuration
);
err
!=
nil
{
if
err
:=
load
(
c
,
model
,
opts
,
sessionDuration
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
...
@@ -465,7 +465,7 @@ func EmbeddingsHandler(c *gin.Context) {
...
@@ -465,7 +465,7 @@ func EmbeddingsHandler(c *gin.Context) {
sessionDuration
=
req
.
KeepAlive
.
Duration
sessionDuration
=
req
.
KeepAlive
.
Duration
}
}
if
err
:=
load
(
c
,
model
,
&
opts
,
sessionDuration
);
err
!=
nil
{
if
err
:=
load
(
c
,
model
,
opts
,
sessionDuration
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
...
@@ -1272,7 +1272,7 @@ func ChatHandler(c *gin.Context) {
...
@@ -1272,7 +1272,7 @@ func ChatHandler(c *gin.Context) {
sessionDuration
=
req
.
KeepAlive
.
Duration
sessionDuration
=
req
.
KeepAlive
.
Duration
}
}
if
err
:=
load
(
c
,
model
,
&
opts
,
sessionDuration
);
err
!=
nil
{
if
err
:=
load
(
c
,
model
,
opts
,
sessionDuration
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
...
...
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