"vscode:/vscode.git/clone" did not exist on "2eb8c3456fd3748253e73c3c5def0dd467b08463"
Unverified Commit 0ed54055 authored by Ankur's avatar Ankur Committed by GitHub
Browse files

Merge branch 'dev' into main

parents 6d99ef8b c6317640
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -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();
}
};
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
</script> </script>
<div class=" hidden lg:flex fixed bottom-0 right-0 px-3 py-3 z-10"> <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 <button
id="show-shortcuts-button" id="show-shortcuts-button"
bind:this={showShortcutsButtonElement} bind:this={showShortcutsButtonElement}
...@@ -201,11 +201,11 @@ ...@@ -201,11 +201,11 @@
> >
{#if loaded} {#if loaded}
{#if !['user', 'admin'].includes($user.role)} {#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 <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="max-w-md">
<div class="text-center dark:text-white text-2xl font-medium z-50"> <div class="text-center dark:text-white text-2xl font-medium z-50">
Account Activation Pending<br /> Contact Admin for WebUI Access Account Activation Pending<br /> Contact Admin for WebUI Access
......
...@@ -134,6 +134,14 @@ ...@@ -134,6 +134,14 @@
selectedModels = ['']; selectedModels = [''];
} }
if ($page.url.searchParams.get('q')) {
prompt = $page.url.searchParams.get('q') ?? '';
if (prompt) {
await tick();
submitPrompt(prompt);
}
}
selectedModels = selectedModels.map((modelId) => selectedModels = selectedModels.map((modelId) =>
$models.map((m) => m.id).includes(modelId) ? modelId : '' $models.map((m) => m.id).includes(modelId) ? modelId : ''
); );
...@@ -366,7 +374,8 @@ ...@@ -366,7 +374,8 @@
}, },
format: $settings.requestFormat ?? undefined, format: $settings.requestFormat ?? undefined,
keep_alive: $settings.keepAlive ?? undefined, keep_alive: $settings.keepAlive ?? undefined,
docs: docs.length > 0 ? docs : undefined docs: docs.length > 0 ? docs : undefined,
citations: docs.length > 0
}); });
if (res && res.ok) { if (res && res.ok) {
...@@ -401,6 +410,11 @@ ...@@ -401,6 +410,11 @@
console.log(line); console.log(line);
let data = JSON.parse(line); let data = JSON.parse(line);
if ('citations' in data) {
responseMessage.citations = data.citations;
continue;
}
if ('detail' in data) { if ('detail' in data) {
throw data; throw data;
} }
...@@ -598,7 +612,8 @@ ...@@ -598,7 +612,8 @@
num_ctx: $settings?.options?.num_ctx ?? undefined, num_ctx: $settings?.options?.num_ctx ?? undefined,
frequency_penalty: $settings?.options?.repeat_penalty ?? undefined, frequency_penalty: $settings?.options?.repeat_penalty ?? undefined,
max_tokens: $settings?.options?.num_predict ?? undefined, max_tokens: $settings?.options?.num_predict ?? undefined,
docs: docs.length > 0 ? docs : undefined docs: docs.length > 0 ? docs : undefined,
citations: docs.length > 0
}, },
model?.source?.toLowerCase() === 'litellm' model?.source?.toLowerCase() === 'litellm'
? `${LITELLM_API_BASE_URL}/v1` ? `${LITELLM_API_BASE_URL}/v1`
...@@ -614,7 +629,7 @@ ...@@ -614,7 +629,7 @@
const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks); const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks);
for await (const update of textStream) { for await (const update of textStream) {
const { value, done } = update; const { value, done, citations } = update;
if (done || stopResponseFlag || _chatId !== $chatId) { if (done || stopResponseFlag || _chatId !== $chatId) {
responseMessage.done = true; responseMessage.done = true;
messages = messages; messages = messages;
...@@ -626,6 +641,11 @@ ...@@ -626,6 +641,11 @@
break; break;
} }
if (citations) {
responseMessage.citations = citations;
continue;
}
if (responseMessage.content == '' && value == '\n') { if (responseMessage.content == '' && value == '\n') {
continue; continue;
} else { } else {
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
<div class=" flex flex-col justify-center"> <div class=" flex flex-col justify-center">
<div class=" px-6 pt-4"> <div class=" px-6 pt-4">
<div class=" flex justify-between items-center"> <div class=" flex justify-between items-center">
<div class="flex items-center text-2xl font-semibold">Dashboard</div> <div class="flex items-center text-2xl font-semibold">{$i18n.t('Dashboard')}</div>
<div> <div>
<Tooltip content={$i18n.t('Admin Settings')}> <Tooltip content={$i18n.t('Admin Settings')}>
<button <button
...@@ -141,7 +141,9 @@ ...@@ -141,7 +141,9 @@
</div> </div>
<div class="px-6 flex text-sm gap-2.5"> <div class="px-6 flex text-sm gap-2.5">
<div class="py-3 border-b font-medium text-gray-100 cursor-pointer">Overview</div> <div class="py-3 border-b font-medium text-gray-100 cursor-pointer">
{$i18n.t('Overview')}
</div>
<!-- <div class="py-3 text-gray-300 cursor-pointer">Users</div> --> <!-- <div class="py-3 text-gray-300 cursor-pointer">Users</div> -->
</div> </div>
...@@ -268,7 +270,7 @@ ...@@ -268,7 +270,7 @@
<td class="px-3 py-2 text-right"> <td class="px-3 py-2 text-right">
<div class="flex justify-end w-full"> <div class="flex justify-end w-full">
{#if user.role !== 'admin'} {#if user.role !== 'admin'}
<Tooltip content="Chats"> <Tooltip content={$i18n.t('Chats')}>
<button <button
class="self-center w-fit text-sm px-2 py-2 hover:bg-black/5 dark:hover:bg-white/5 rounded-xl" class="self-center w-fit text-sm px-2 py-2 hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
on:click={async () => { on:click={async () => {
......
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