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
2ad8a074
Commit
2ad8a074
authored
Oct 18, 2023
by
Michael Yang
Browse files
generate: set created_at
move the empty response so it's more visible
parent
7e547c68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
server/routes.go
server/routes.go
+8
-7
No files found.
server/routes.go
View file @
2ad8a074
...
@@ -182,6 +182,12 @@ func GenerateHandler(c *gin.Context) {
...
@@ -182,6 +182,12 @@ func GenerateHandler(c *gin.Context) {
ch
:=
make
(
chan
any
)
ch
:=
make
(
chan
any
)
go
func
()
{
go
func
()
{
defer
close
(
ch
)
defer
close
(
ch
)
// an empty request loads the model
if
req
.
Prompt
==
""
&&
req
.
Template
==
""
&&
req
.
System
==
""
{
ch
<-
api
.
GenerateResponse
{
CreatedAt
:
time
.
Now
()
.
UTC
(),
Model
:
req
.
Model
,
Done
:
true
}
return
}
fn
:=
func
(
r
api
.
GenerateResponse
)
{
fn
:=
func
(
r
api
.
GenerateResponse
)
{
loaded
.
expireAt
=
time
.
Now
()
.
Add
(
sessionDuration
)
loaded
.
expireAt
=
time
.
Now
()
.
Add
(
sessionDuration
)
loaded
.
expireTimer
.
Reset
(
sessionDuration
)
loaded
.
expireTimer
.
Reset
(
sessionDuration
)
...
@@ -196,13 +202,8 @@ func GenerateHandler(c *gin.Context) {
...
@@ -196,13 +202,8 @@ func GenerateHandler(c *gin.Context) {
ch
<-
r
ch
<-
r
}
}
// an empty request loads the model
if
err
:=
loaded
.
runner
.
Predict
(
c
.
Request
.
Context
(),
req
.
Context
,
prompt
,
fn
);
err
!=
nil
{
if
req
.
Prompt
==
""
&&
req
.
Template
==
""
&&
req
.
System
==
""
{
ch
<-
gin
.
H
{
"error"
:
err
.
Error
()}
ch
<-
api
.
GenerateResponse
{
Model
:
req
.
Model
,
Done
:
true
}
}
else
{
if
err
:=
loaded
.
runner
.
Predict
(
c
.
Request
.
Context
(),
req
.
Context
,
prompt
,
fn
);
err
!=
nil
{
ch
<-
gin
.
H
{
"error"
:
err
.
Error
()}
}
}
}
}()
}()
...
...
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