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
e34b4525
"docs/img/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "97829ccdf3387409e18e85361f6edaddb158e995"
Commit
e34b4525
authored
Dec 14, 2023
by
Timothy J. Baek
Browse files
feat: response notification
parent
ffaa1b17
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
33 deletions
+100
-33
src/lib/components/chat/SettingsModal.svelte
src/lib/components/chat/SettingsModal.svelte
+70
-33
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+15
-0
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+15
-0
No files found.
src/lib/components/chat/SettingsModal.svelte
View file @
e34b4525
...
@@ -49,8 +49,10 @@
...
@@ -49,8 +49,10 @@
let pullProgress = null;
let pullProgress = null;
// Addons
// Addons
let responseNotification = false;
let titleAutoGenerate = true;
let titleAutoGenerate = true;
let speechAutoSend = false;
let speechAutoSend = false;
let gravatarEmail = '';
let gravatarEmail = '';
let OPENAI_API_KEY = '';
let OPENAI_API_KEY = '';
...
@@ -108,6 +110,19 @@
...
@@ -108,6 +110,19 @@
saveSettings({ titleAutoGenerate: titleAutoGenerate });
saveSettings({ titleAutoGenerate: titleAutoGenerate });
};
};
const toggleResponseNotification = async () => {
const permission = await Notification.requestPermission();
if (permission === 'granted') {
responseNotification = !responseNotification;
saveSettings({ responseNotification: responseNotification });
} else {
toast.error(
'Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.'
);
}
};
const toggleAuthHeader = async () => {
const toggleAuthHeader = async () => {
authEnabled = !authEnabled;
authEnabled = !authEnabled;
};
};
...
@@ -802,44 +817,66 @@
...
@@ -802,44 +817,66 @@
>
>
<div class=" space-y-3">
<div class=" space-y-3">
<div>
<div>
<div class=" py-1 flex w-full justify-between">
<div class=" mb-1 text-sm font-medium">WebUI Add-ons</div>
<div class=" self-center text-sm font-medium">Title Auto Generation</div>
<button
<div>
class="p-1 px-3 text-xs flex rounded transition"
<div class=" py-0.5 flex w-full justify-between">
on:click={() => {
<div class=" self-center text-xs font-medium">Response Notification</div>
toggleTitleAutoGenerate();
}}
<button
type="button"
class="p-1 px-3 text-xs flex rounded transition"
>
on:click={() => {
{#if titleAutoGenerate === true}
toggleResponseNotification();
<span class="ml-2 self-center">On</span>
}}
{:else}
type="button"
<span class="ml-2 self-center">Off</span>
>
{/if}
{#if responseNotification === true}
</button>
<span class="ml-2 self-center">On</span>
{:else}
<span class="ml-2 self-center">Off</span>
{/if}
</button>
</div>
</div>
</div>
</div>
<hr class=" dark:border-gray-700" />
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs font-medium">Title Auto Generation</div>
<div>
<button
<div class=" py-1 flex w-full justify-between">
class="p-1 px-3 text-xs flex rounded transition"
<div class=" self-center text-sm font-medium">Voice Input Auto-Send</div>
on:click={() => {
toggleTitleAutoGenerate();
}}
type="button"
>
{#if titleAutoGenerate === true}
<span class="ml-2 self-center">On</span>
{:else}
<span class="ml-2 self-center">Off</span>
{/if}
</button>
</div>
</div>
<button
<div>
class="p-1 px-3 text-xs flex rounded transition"
<div class=" py-0.5 flex w-full justify-between">
on:click={() => {
<div class=" self-center text-xs font-medium">Voice Input Auto-Send</div>
toggleSpeechAutoSend();
}}
<button
type="button"
class="p-1 px-3 text-xs flex rounded transition"
>
on:click={() => {
{#if speechAutoSend === true}
toggleSpeechAutoSend();
<span class="ml-2 self-center">On</span>
}}
{:else}
type="button"
<span class="ml-2 self-center">Off</span>
>
{/if}
{#if speechAutoSend === true}
</button>
<span class="ml-2 self-center">On</span>
{:else}
<span class="ml-2 self-center">Off</span>
{/if}
</button>
</div>
</div>
</div>
</div>
</div>
...
...
src/routes/(app)/+page.svelte
View file @
e34b4525
...
@@ -222,6 +222,21 @@
...
@@ -222,6 +222,21 @@
eval_duration: data.eval_duration
eval_duration: data.eval_duration
};
};
messages = messages;
messages = messages;
if ($settings.responseNotification && !document.hasFocus()) {
const notification = new Notification(
selectedModelfile
? `${
selectedModelfile.title.charAt(0).toUpperCase() +
selectedModelfile.title.slice(1)
}`
: `Ollama - ${model}`,
{
body: responseMessage.content,
icon: selectedModelfile?.imageUrl ?? '/favicon.png'
}
);
}
}
}
}
}
}
}
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
e34b4525
...
@@ -234,6 +234,21 @@
...
@@ -234,6 +234,21 @@
eval_duration: data.eval_duration
eval_duration: data.eval_duration
};
};
messages = messages;
messages = messages;
if ($settings.responseNotification && !document.hasFocus()) {
const notification = new Notification(
selectedModelfile
? `${
selectedModelfile.title.charAt(0).toUpperCase() +
selectedModelfile.title.slice(1)
}`
: `Ollama - ${model}`,
{
body: responseMessage.content,
icon: selectedModelfile?.imageUrl ?? '/favicon.png'
}
);
}
}
}
}
}
}
}
...
...
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