Voice Input Auto-Send
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
index 3df52bee..9cc3e55c 100644
--- a/src/routes/(app)/+page.svelte
+++ b/src/routes/(app)/+page.svelte
@@ -415,35 +415,39 @@
};
const generateChatTitle = async (_chatId, userPrompt) => {
- console.log('generateChatTitle');
+ if ($settings.titleAutoGenerate ?? true) {
+ console.log('generateChatTitle');
- const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/generate`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'text/event-stream',
- ...($settings.authHeader && { Authorization: $settings.authHeader }),
- ...($user && { Authorization: `Bearer ${localStorage.token}` })
- },
- body: JSON.stringify({
- model: selectedModels[0],
- prompt: `Generate a brief 3-5 word title for this question, excluding the term 'title.' Then, please reply with only the title: ${userPrompt}`,
- stream: false
+ const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/generate`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/event-stream',
+ ...($settings.authHeader && { Authorization: $settings.authHeader }),
+ ...($user && { Authorization: `Bearer ${localStorage.token}` })
+ },
+ body: JSON.stringify({
+ model: selectedModels[0],
+ prompt: `Generate a brief 3-5 word title for this question, excluding the term 'title.' Then, please reply with only the title: ${userPrompt}`,
+ stream: false
+ })
})
- })
- .then(async (res) => {
- if (!res.ok) throw await res.json();
- return res.json();
- })
- .catch((error) => {
- if ('detail' in error) {
- toast.error(error.detail);
- }
- console.log(error);
- return null;
- });
+ .then(async (res) => {
+ if (!res.ok) throw await res.json();
+ return res.json();
+ })
+ .catch((error) => {
+ if ('detail' in error) {
+ toast.error(error.detail);
+ }
+ console.log(error);
+ return null;
+ });
- if (res) {
- await setChatTitle(_chatId, res.response === '' ? 'New Chat' : res.response);
+ if (res) {
+ await setChatTitle(_chatId, res.response === '' ? 'New Chat' : res.response);
+ }
+ } else {
+ await setChatTitle(_chatId, `${userPrompt}`);
}
};
diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte
index 00070f90..d1b68e52 100644
--- a/src/routes/(app)/c/[id]/+page.svelte
+++ b/src/routes/(app)/c/[id]/+page.svelte
@@ -451,35 +451,39 @@
};
const generateChatTitle = async (_chatId, userPrompt) => {
- console.log('generateChatTitle');
+ if ($settings.titleAutoGenerate ?? true) {
+ console.log('generateChatTitle');
- const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/generate`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'text/event-stream',
- ...($settings.authHeader && { Authorization: $settings.authHeader }),
- ...($user && { Authorization: `Bearer ${localStorage.token}` })
- },
- body: JSON.stringify({
- model: selectedModels[0],
- prompt: `Generate a brief 3-5 word title for this question, excluding the term 'title.' Then, please reply with only the title: ${userPrompt}`,
- stream: false
+ const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/generate`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/event-stream',
+ ...($settings.authHeader && { Authorization: $settings.authHeader }),
+ ...($user && { Authorization: `Bearer ${localStorage.token}` })
+ },
+ body: JSON.stringify({
+ model: selectedModels[0],
+ prompt: `Generate a brief 3-5 word title for this question, excluding the term 'title.' Then, please reply with only the title: ${userPrompt}`,
+ stream: false
+ })
})
- })
- .then(async (res) => {
- if (!res.ok) throw await res.json();
- return res.json();
- })
- .catch((error) => {
- if ('detail' in error) {
- toast.error(error.detail);
- }
- console.log(error);
- return null;
- });
+ .then(async (res) => {
+ if (!res.ok) throw await res.json();
+ return res.json();
+ })
+ .catch((error) => {
+ if ('detail' in error) {
+ toast.error(error.detail);
+ }
+ console.log(error);
+ return null;
+ });
- if (res) {
- await setChatTitle(_chatId, res.response === '' ? 'New Chat' : res.response);
+ if (res) {
+ await setChatTitle(_chatId, res.response === '' ? 'New Chat' : res.response);
+ }
+ } else {
+ await setChatTitle(_chatId, `${userPrompt}`);
}
};