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

Merge pull request #1965 from open-webui/dev

0.1.124
parents 30b05311 b44ae536
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,13 +3,21 @@ ...@@ -3,13 +3,21 @@
"code": "en-US", "code": "en-US",
"title": "English (US)" "title": "English (US)"
}, },
{
"code": "en-GB",
"title": "English (GB)"
},
{
"code": "ar-BH",
"title": "العربية (AR)"
},
{ {
"code": "bg-BG", "code": "bg-BG",
"title": "Bulgarian (BG)" "title": "Bulgarian (BG)"
}, },
{ {
"code": "bn-BD", "code": "bn-BD",
"title": "Banlga (বাংলা)" "title": "Bangla (বাংলা)"
}, },
{ {
"code": "ca-ES", "code": "ca-ES",
...@@ -19,10 +27,6 @@ ...@@ -19,10 +27,6 @@
"code": "de-DE", "code": "de-DE",
"title": "Deutsch" "title": "Deutsch"
}, },
{
"code": "en-GB",
"title": "English (GB)"
},
{ {
"code": "es-ES", "code": "es-ES",
"title": "Spanish" "title": "Spanish"
...@@ -31,6 +35,10 @@ ...@@ -31,6 +35,10 @@
"code": "fa-IR", "code": "fa-IR",
"title": "فارسی (Farsi)" "title": "فارسی (Farsi)"
}, },
{
"code": "fi-FI",
"title": "Finnish"
},
{ {
"code": "fr-CA", "code": "fr-CA",
"title": "French (Canada)" "title": "French (Canada)"
...@@ -39,6 +47,10 @@ ...@@ -39,6 +47,10 @@
"code": "fr-FR", "code": "fr-FR",
"title": "French (France)" "title": "French (France)"
}, },
{
"code": "hi-IN",
"title": "Hindi (हिंदी)"
},
{ {
"code": "it-IT", "code": "it-IT",
"title": "Italian" "title": "Italian"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -102,6 +102,7 @@ type AudioSettings = { ...@@ -102,6 +102,7 @@ type AudioSettings = {
STTEngine?: string; STTEngine?: string;
TTSEngine?: string; TTSEngine?: string;
speaker?: string; speaker?: string;
model?: string;
}; };
type TitleSettings = { type TitleSettings = {
......
...@@ -472,29 +472,20 @@ export const blobToFile = (blob, fileName) => { ...@@ -472,29 +472,20 @@ export const blobToFile = (blob, fileName) => {
return file; 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) => { export const promptTemplate = (template: string, prompt: string) => {
prompt = prompt.replace(/{{prompt}}|{{prompt:start:\d+}}|{{prompt:end:\d+}}/g, '');
template = template.replace(/{{prompt}}/g, prompt); template = template.replace(/{{prompt}}/g, prompt);
// Replace all instances of {{prompt:start:<length>}} with the first <length> characters of the prompt // Replace all instances of {{prompt:start:<length>}} with the first <length> characters of the prompt
const startRegex = /{{prompt:start:(\d+)}}/g; template = template.replace(/{{prompt:start:(\d+)}}/g, (match, length) =>
let startMatch: RegExpMatchArray | null; prompt.substring(0, parseInt(length))
while ((startMatch = startRegex.exec(template)) !== null) { );
const length = parseInt(startMatch[1]);
template = template.replace(startMatch[0], prompt.substring(0, length));
}
// Replace all instances of {{prompt:end:<length>}} with the last <length> characters of the prompt // Replace all instances of {{prompt:end:<length>}} with the last <length> characters of the prompt
const endRegex = /{{prompt:end:(\d+)}}/g; template = template.replace(/{{prompt:end:(\d+)}}/g, (match, length) =>
let endMatch: RegExpMatchArray | null; prompt.slice(-parseInt(length))
while ((endMatch = endRegex.exec(template)) !== null) { );
const length = parseInt(endMatch[1]);
template = template.replace(endMatch[0], prompt.substring(prompt.length - length));
}
return template; return template;
}; };
...@@ -520,3 +511,34 @@ export const approximateToHumanReadable = (nanoseconds: number) => { ...@@ -520,3 +511,34 @@ export const approximateToHumanReadable = (nanoseconds: number) => {
return results.reverse().join(' '); 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();
}
};
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