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
32aec66e
Commit
32aec66e
authored
Jul 18, 2023
by
Michael Yang
Browse files
add load duration
parent
35af37a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
api/types.go
api/types.go
+5
-0
server/routes.go
server/routes.go
+5
-2
No files found.
api/types.go
View file @
32aec66e
...
...
@@ -91,6 +91,7 @@ type GenerateResponse struct {
Context
[]
int
`json:"context,omitempty"`
TotalDuration
time
.
Duration
`json:"total_duration,omitempty"`
LoadDuration
time
.
Duration
`json:"load_duration,omitempty"`
PromptEvalCount
int
`json:"prompt_eval_count,omitempty"`
PromptEvalDuration
time
.
Duration
`json:"prompt_eval_duration,omitempty"`
EvalCount
int
`json:"eval_count,omitempty"`
...
...
@@ -102,6 +103,10 @@ func (r *GenerateResponse) Summary() {
fmt
.
Fprintf
(
os
.
Stderr
,
"total duration: %v
\n
"
,
r
.
TotalDuration
)
}
if
r
.
LoadDuration
>
0
{
fmt
.
Fprintf
(
os
.
Stderr
,
"load duration: %v
\n
"
,
r
.
LoadDuration
)
}
if
r
.
PromptEvalCount
>
0
{
fmt
.
Fprintf
(
os
.
Stderr
,
"prompt eval count: %d token(s)
\n
"
,
r
.
PromptEvalCount
)
}
...
...
server/routes.go
View file @
32aec66e
...
...
@@ -33,7 +33,7 @@ func GenerateHandler(c *gin.Context) {
mu
.
Lock
()
defer
mu
.
Unlock
()
s
tart
:=
time
.
Now
()
checkpointS
tart
:=
time
.
Now
()
var
req
api
.
GenerateRequest
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
...
...
@@ -74,6 +74,8 @@ func GenerateHandler(c *gin.Context) {
activeSession
.
LLM
=
llm
}
checkpointLoaded
:=
time
.
Now
()
prompt
,
err
:=
model
.
Prompt
(
req
)
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
...
...
@@ -88,7 +90,8 @@ func GenerateHandler(c *gin.Context) {
r
.
CreatedAt
=
time
.
Now
()
.
UTC
()
r
.
SessionID
=
activeSession
.
ID
if
r
.
Done
{
r
.
TotalDuration
=
time
.
Since
(
start
)
r
.
TotalDuration
=
time
.
Since
(
checkpointStart
)
r
.
LoadDuration
=
checkpointLoaded
.
Sub
(
checkpointStart
)
}
ch
<-
r
...
...
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