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
chenpangpang
open-webui
Commits
d9ce1d3e
Unverified
Commit
d9ce1d3e
authored
Apr 14, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Apr 14, 2024
Browse files
Merge pull request #1544 from lainedfles/generation_info_approximate_total
feat: human readable Generation Info total
parents
9091513c
b93337e6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+5
-1
src/lib/utils/index.ts
src/lib/utils/index.ts
+22
-0
No files found.
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
d9ce1d3e
...
...
@@ -18,6 +18,7 @@
import { synthesizeOpenAISpeech } from '$lib/apis/openai';
import { imageGenerations } from '$lib/apis/images';
import {
approximateToHumanReadable,
extractSentences,
revertSanitizedResponseContent,
sanitizeResponseContent
...
...
@@ -122,7 +123,10 @@
eval_count: ${message.info.eval_count ?? 'N/A'}<br/>
eval_duration: ${
Math.round(((message.info.eval_duration ?? 0) / 1000000) * 100) / 100 ?? 'N/A'
}ms</span>`,
}ms<br/>
approximate_total: ${approximateToHumanReadable(
message.info.total_duration
)}</span>`,
allowHTML: true
});
}
...
...
src/lib/utils/index.ts
View file @
d9ce1d3e
...
...
@@ -467,3 +467,25 @@ export const blobToFile = (blob, fileName) => {
const
file
=
new
File
([
blob
],
fileName
,
{
type
:
blob
.
type
});
return
file
;
};
export
const
approximateToHumanReadable
=
(
nanoseconds
:
number
)
=>
{
const
seconds
=
Math
.
floor
((
nanoseconds
/
1
e9
)
%
60
);
const
minutes
=
Math
.
floor
((
nanoseconds
/
6
e10
)
%
60
);
const
hours
=
Math
.
floor
((
nanoseconds
/
3.6e12
)
%
24
);
const
results
:
string
[]
=
[];
if
(
seconds
>=
0
)
{
results
.
push
(
`
${
seconds
}
s`
);
}
if
(
minutes
>
0
)
{
results
.
push
(
`
${
minutes
}
m`
);
}
if
(
hours
>
0
)
{
results
.
push
(
`
${
hours
}
h`
);
}
return
results
.
reverse
().
join
(
'
'
);
};
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