Unverified Commit 68c182db authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge branch 'dev' into main

parents 242e70d1 876853f2
This diff is collapsed.
This diff is collapsed.
......@@ -472,29 +472,20 @@ export const blobToFile = (blob, fileName) => {
return file;
};
// promptTemplate replaces any occurrences of the following in the template with the prompt
// {{prompt}} will be replaced with the prompt
// {{prompt:start:<length>}} will be replaced with the first <length> characters of the prompt
// {{prompt:end:<length>}} will be replaced with the last <length> characters of the prompt
// Character length is used as we don't have the ability to tokenize the prompt
export const promptTemplate = (template: string, prompt: string) => {
prompt = prompt.replace(/{{prompt}}|{{prompt:start:\d+}}|{{prompt:end:\d+}}/g, '');
template = template.replace(/{{prompt}}/g, prompt);
// Replace all instances of {{prompt:start:<length>}} with the first <length> characters of the prompt
const startRegex = /{{prompt:start:(\d+)}}/g;
let startMatch: RegExpMatchArray | null;
while ((startMatch = startRegex.exec(template)) !== null) {
const length = parseInt(startMatch[1]);
template = template.replace(startMatch[0], prompt.substring(0, length));
}
template = template.replace(/{{prompt:start:(\d+)}}/g, (match, length) =>
prompt.substring(0, parseInt(length))
);
// Replace all instances of {{prompt:end:<length>}} with the last <length> characters of the prompt
const endRegex = /{{prompt:end:(\d+)}}/g;
let endMatch: RegExpMatchArray | null;
while ((endMatch = endRegex.exec(template)) !== null) {
const length = parseInt(endMatch[1]);
template = template.replace(endMatch[0], prompt.substring(prompt.length - length));
}
template = template.replace(/{{prompt:end:(\d+)}}/g, (match, length) =>
prompt.slice(-parseInt(length))
);
return template;
};
......@@ -520,3 +511,34 @@ export const approximateToHumanReadable = (nanoseconds: number) => {
return results.reverse().join(' ');
};
export const getTimeRange = (timestamp) => {
const now = new Date();
const date = new Date(timestamp * 1000); // Convert Unix timestamp to milliseconds
// Calculate the difference in milliseconds
const diffTime = now.getTime() - date.getTime();
const diffDays = diffTime / (1000 * 3600 * 24);
const nowDate = now.getDate();
const nowMonth = now.getMonth();
const nowYear = now.getFullYear();
const dateDate = date.getDate();
const dateMonth = date.getMonth();
const dateYear = date.getFullYear();
if (nowYear === dateYear && nowMonth === dateMonth && nowDate === dateDate) {
return 'Today';
} else if (nowYear === dateYear && nowMonth === dateMonth && nowDate - dateDate === 1) {
return 'Yesterday';
} else if (diffDays <= 7) {
return 'Previous 7 days';
} else if (diffDays <= 30) {
return 'Previous 30 days';
} else if (nowYear === dateYear) {
return date.toLocaleString('default', { month: 'long' });
} else {
return date.getFullYear().toString();
}
};
......@@ -177,7 +177,7 @@
</script>
<div class=" hidden lg:flex fixed bottom-0 right-0 px-3 py-3 z-10">
<Tooltip content="Help" placement="left">
<Tooltip content={$i18n.t('Help')} placement="left">
<button
id="show-shortcuts-button"
bind:this={showShortcutsButtonElement}
......@@ -201,11 +201,11 @@
>
{#if loaded}
{#if !['user', 'admin'].includes($user.role)}
<div class="fixed w-full h-full flex z-50">
<div class="fixed w-full h-full flex z-[999]">
<div
class="absolute w-full h-full backdrop-blur-md bg-white/20 dark:bg-gray-900/50 flex justify-center"
class="absolute w-full h-full backdrop-blur-lg bg-white/10 dark:bg-gray-900/50 flex justify-center"
>
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="m-auto pb-10 flex flex-col justify-center">
<div class="max-w-md">
<div class="text-center dark:text-white text-2xl font-medium z-50">
Account Activation Pending<br /> Contact Admin for WebUI Access
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment