Merge branch 'dev' into feat/customizable-title-prompt-length

This commit is contained in:
Timothy Jaeryang Baek 2024-04-14 14:02:53 -07:00 committed by GitHub
commit a938ffb586
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 187 additions and 43 deletions

View file

@ -493,4 +493,25 @@ export const templatePrompt = (template: string, prompt: string) => {
}
return template;
export const approximateToHumanReadable = (nanoseconds: number) => {
const seconds = Math.floor((nanoseconds / 1e9) % 60);
const minutes = Math.floor((nanoseconds / 6e10) % 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(' ');
};