-
+ {#if selectedModelfile && selectedModelfile.imageUrl}
+
+ {:else}
+
+ {/if}
-
- How can I help you today?
+
+ {#if selectedModelfile}
+ {selectedModelfile.desc}
+ {:else}
+ How can I help you today?
+ {/if}
{:else}
@@ -332,6 +343,12 @@
alt="User profile"
/>
{/if}
+ {:else if selectedModelfile}
+
{:else}
{#if message.role === 'user'}
You
+ {:else if selectedModelfile}
+
+ {selectedModelfile.title}
+
{:else}
Ollama
{message.model ? ` ${message.model}` : ''}
{/if}
-
{message.content}
+
{message.content}
{#if message.parentId !== null && message.parentId in history.messages && (history.messages[message.parentId]?.childrenIds.length ?? 0) > 1}
diff --git a/src/lib/components/chat/Settings/Advanced.svelte b/src/lib/components/chat/Settings/Advanced.svelte
new file mode 100644
index 000000000..a188f107a
--- /dev/null
+++ b/src/lib/components/chat/Settings/Advanced.svelte
@@ -0,0 +1,510 @@
+
+
+
+
+
+
+
+
+
+
Temperature
+
+
{
+ options.temperature = options.temperature === '' ? 0.8 : '';
+ }}
+ >
+ {#if options.temperature === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.temperature !== ''}
+
+ {/if}
+
+
+
+
+
Mirostat
+
+
{
+ options.mirostat = options.mirostat === '' ? 0 : '';
+ }}
+ >
+ {#if options.mirostat === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.mirostat !== ''}
+
+ {/if}
+
+
+
+
+
Mirostat Eta
+
+
{
+ options.mirostat_eta = options.mirostat_eta === '' ? 0.1 : '';
+ }}
+ >
+ {#if options.mirostat_eta === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.mirostat_eta !== ''}
+
+ {/if}
+
+
+
+
+
Mirostat Tau
+
+
{
+ options.mirostat_tau = options.mirostat_tau === '' ? 5.0 : '';
+ }}
+ >
+ {#if options.mirostat_tau === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.mirostat_tau !== ''}
+
+ {/if}
+
+
+
+
+
Top K
+
+
{
+ options.top_k = options.top_k === '' ? 40 : '';
+ }}
+ >
+ {#if options.top_k === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.top_k !== ''}
+
+ {/if}
+
+
+
+
+
Top P
+
+
{
+ options.top_p = options.top_p === '' ? 0.9 : '';
+ }}
+ >
+ {#if options.top_p === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.top_p !== ''}
+
+ {/if}
+
+
+
+
+
Repeat Penalty
+
+
{
+ options.repeat_penalty = options.repeat_penalty === '' ? 1.1 : '';
+ }}
+ >
+ {#if options.repeat_penalty === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.repeat_penalty !== ''}
+
+ {/if}
+
+
+
+
+
Repeat Last N
+
+
{
+ options.repeat_last_n = options.repeat_last_n === '' ? 64 : '';
+ }}
+ >
+ {#if options.repeat_last_n === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.repeat_last_n !== ''}
+
+ {/if}
+
+
+
+
+
Tfs Z
+
+
{
+ options.tfs_z = options.tfs_z === '' ? 1 : '';
+ }}
+ >
+ {#if options.tfs_z === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.tfs_z !== ''}
+
+ {/if}
+
+
+
+
+
Context Length
+
+
{
+ options.num_ctx = options.num_ctx === '' ? 2048 : '';
+ }}
+ >
+ {#if options.num_ctx === ''}
+ Default
+ {:else}
+ Custom
+ {/if}
+
+
+
+ {#if options.num_ctx !== ''}
+
+ {/if}
+
+
diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte
index 31da70fea..a0d538aa4 100644
--- a/src/lib/components/chat/SettingsModal.svelte
+++ b/src/lib/components/chat/SettingsModal.svelte
@@ -6,6 +6,7 @@
import { onMount } from 'svelte';
import { config, models, settings, user } from '$lib/stores';
import { splitStream, getGravatarURL } from '$lib/utils';
+ import Advanced from './Settings/Advanced.svelte';
export let show = false;
@@ -25,12 +26,21 @@
// Advanced
let requestFormat = '';
- let seed = 0;
- let temperature = '';
- let repeat_penalty = '';
- let top_k = '';
- let top_p = '';
- let num_ctx = '';
+ let options = {
+ // Advanced
+ seed: 0,
+ temperature: '',
+ repeat_penalty: '',
+ repeat_last_n: '',
+ mirostat: '',
+ mirostat_eta: '',
+ mirostat_tau: '',
+ top_k: '',
+ top_p: '',
+ stop: '',
+ tfs_z: '',
+ num_ctx: ''
+ };
// Models
let modelTag = '';
@@ -218,28 +228,6 @@
models.set(await getModels());
};
- $: if (show) {
- let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
- console.log(settings);
-
- theme = localStorage.theme ?? 'dark';
- API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL;
- system = settings.system ?? '';
-
- requestFormat = settings.requestFormat ?? '';
- seed = settings.seed ?? 0;
- temperature = settings.temperature ?? '';
- repeat_penalty = settings.repeat_penalty ?? '';
- top_k = settings.top_k ?? '';
- top_p = settings.top_p ?? '';
- num_ctx = settings.num_ctx ?? '';
-
- titleAutoGenerate = settings.titleAutoGenerate ?? true;
- speechAutoSend = settings.speechAutoSend ?? false;
- gravatarEmail = settings.gravatarEmail ?? '';
- OPENAI_API_KEY = settings.OPENAI_API_KEY ?? '';
- }
-
const getModels = async (url = '', type = 'all') => {
let models = [];
const res = await fetch(`${url ? url : $settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/tags`, {
@@ -306,6 +294,26 @@
onMount(() => {
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
+ console.log(settings);
+
+ theme = localStorage.theme ?? 'dark';
+ API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL;
+ system = settings.system ?? '';
+
+ requestFormat = settings.requestFormat ?? '';
+
+ options.seed = settings.seed ?? 0;
+ options.temperature = settings.temperature ?? '';
+ options.repeat_penalty = settings.repeat_penalty ?? '';
+ options.top_k = settings.top_k ?? '';
+ options.top_p = settings.top_p ?? '';
+ options.num_ctx = settings.num_ctx ?? '';
+ options = { ...options, ...settings.options };
+
+ titleAutoGenerate = settings.titleAutoGenerate ?? true;
+ speechAutoSend = settings.speechAutoSend ?? false;
+ gravatarEmail = settings.gravatarEmail ?? '';
+ OPENAI_API_KEY = settings.OPENAI_API_KEY ?? '';
authEnabled = settings.authHeader !== undefined ? true : false;
if (authEnabled) {
@@ -497,7 +505,7 @@
About
-
+
{#if selectedTab === 'general'}
{:else if selectedTab === 'advanced'}
-
-
-
-
-
-
-
Temperature
-
-
{
- temperature = temperature === '' ? 0.8 : '';
- }}
- >
- {#if temperature === ''}
- Default
- {:else}
- Custom
- {/if}
-
-
-
- {#if temperature !== ''}
-
- {/if}
-
-
-
-
-
Repeat Penalty
-
-
{
- repeat_penalty = repeat_penalty === '' ? 1.1 : '';
- }}
- >
- {#if repeat_penalty === ''}
- Default
- {:else}
- Custom
- {/if}
-
-
-
- {#if repeat_penalty !== ''}
-
- {/if}
-
-
-
-
-
Top K
-
-
{
- top_k = top_k === '' ? 40 : '';
- }}
- >
- {#if top_k === ''}
- Default
- {:else}
- Custom
- {/if}
-
-
-
- {#if top_k !== ''}
-
- {/if}
-
-
-
-
-
Top P
-
-
{
- top_p = top_p === '' ? 0.9 : '';
- }}
- >
- {#if top_p === ''}
- Default
- {:else}
- Custom
- {/if}
-
-
-
- {#if top_p !== ''}
-
- {/if}
-
-
-
-
-
Context Length
-
-
{
- num_ctx = num_ctx === '' ? 2048 : '';
- }}
- >
- {#if num_ctx === ''}
- Default
- {:else}
- Custom
- {/if}
-
-
-
- {#if num_ctx !== ''}
-
- {/if}
-
+
+
{
saveSettings({
- seed: (seed !== 0 ? seed : undefined) ?? undefined,
- temperature: temperature !== '' ? temperature : undefined,
- repeat_penalty: repeat_penalty !== '' ? repeat_penalty : undefined,
- top_k: top_k !== '' ? top_k : undefined,
- top_p: top_p !== '' ? top_p : undefined,
- num_ctx: num_ctx !== '' ? num_ctx : undefined
+ options: {
+ seed: (options.seed !== 0 ? options.seed : undefined) ?? undefined,
+ stop: options.stop !== '' ? options.stop : undefined,
+ temperature: options.temperature !== '' ? options.temperature : undefined,
+ repeat_penalty:
+ options.repeat_penalty !== '' ? options.repeat_penalty : undefined,
+ repeat_last_n:
+ options.repeat_last_n !== '' ? options.repeat_last_n : undefined,
+ mirostat: options.mirostat !== '' ? options.mirostat : undefined,
+ mirostat_eta: options.mirostat_eta !== '' ? options.mirostat_eta : undefined,
+ mirostat_tau: options.mirostat_tau !== '' ? options.mirostat_tau : undefined,
+ top_k: options.top_k !== '' ? options.top_k : undefined,
+ top_p: options.top_p !== '' ? options.top_p : undefined,
+ tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
+ num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined
+ }
});
show = false;
}}
@@ -943,7 +739,7 @@
{pullProgress ?? 0}%
-
diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte
index 656d3f451..bb54dbc1a 100644
--- a/src/lib/components/layout/Sidebar.svelte
+++ b/src/lib/components/layout/Sidebar.svelte
@@ -24,7 +24,7 @@
let showDropdown = false;
- let showDeleteHistoryConfirm = false;
+ let showDeleteHistoryConfirm = false;
onMount(async () => {
if (window.innerWidth > 1280) {
@@ -121,11 +121,11 @@
-
+
@@ -449,91 +449,92 @@
Export
- {#if showDeleteHistoryConfirm}
-
-
-
-
-
{
- deleteChatHistory();
- showDeleteHistoryConfirm = false;
- }}
- >
-
-
-
-
-
{
- showDeleteHistoryConfirm = false;
- }}
- >
-
-
-
-
-
-
- {:else}
-
{
- showDeleteHistoryConfirm = true;
- }}>
-
- Clear conversations
-
- {/if}
+ {#if showDeleteHistoryConfirm}
+
+
+
+
+
{
+ deleteChatHistory();
+ showDeleteHistoryConfirm = false;
+ }}
+ >
+
+
+
+
+
{
+ showDeleteHistoryConfirm = false;
+ }}
+ >
+
+
+
+
+
+
+ {:else}
+
{
+ showDeleteHistoryConfirm = true;
+ }}
+ >
+
+ Clear conversations
+
+ {/if}
{#if $user !== undefined}
{
- const _db = await openDB('Chats', 1, {
+ const DB = await openDB('Chats', 1, {
upgrade(db) {
const store = db.createObjectStore('chats', {
keyPath: 'id',
@@ -89,7 +99,7 @@
});
return {
- db: _db,
+ db: DB,
getChatById: async function (id) {
return await this.db.get('chats', id);
},
@@ -162,6 +172,14 @@
let _db = await getDB();
await db.set(_db);
+ await modelfiles.set(
+ JSON.parse(localStorage.getItem('modelfiles') ?? JSON.stringify($modelfiles))
+ );
+
+ modelfiles.subscribe(async () => {
+ await models.set(await getModels());
+ });
+
await tick();
loaded = true;
});
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
index 753e9f64d..f8ea33075 100644
--- a/src/routes/(app)/+page.svelte
+++ b/src/routes/(app)/+page.svelte
@@ -7,17 +7,24 @@
import { splitStream } from '$lib/utils';
import { goto } from '$app/navigation';
- import { config, user, settings, db, chats, chatId } from '$lib/stores';
+ import { config, modelfiles, user, settings, db, chats, chatId } from '$lib/stores';
import MessageInput from '$lib/components/chat/MessageInput.svelte';
import Messages from '$lib/components/chat/Messages.svelte';
import ModelSelector from '$lib/components/chat/ModelSelector.svelte';
import Navbar from '$lib/components/layout/Navbar.svelte';
+ import { page } from '$app/stores';
let stopResponseFlag = false;
let autoScroll = true;
let selectedModels = [''];
+ let selectedModelfile = null;
+ $: selectedModelfile =
+ selectedModels.length === 1 &&
+ $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0]).length > 0
+ ? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
+ : null;
let title = '';
let prompt = '';
@@ -64,7 +71,9 @@
messages: {},
currentId: null
};
- selectedModels = $settings.models ?? [''];
+ selectedModels = $page.url.searchParams.get('models')
+ ? $page.url.searchParams.get('models')?.split(',')
+ : $settings.models ?? [''];
};
//////////////////////////
@@ -126,7 +135,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
format: $settings.requestFormat ?? undefined,
context:
@@ -198,7 +208,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
messages: messages,
history: history
@@ -266,7 +277,7 @@
.map((message) => ({ role: message.role, content: message.content })),
temperature: $settings.temperature ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined,
+ num_ctx: $settings.num_ctx ?? undefined,
frequency_penalty: $settings.repeat_penalty ?? undefined
})
});
@@ -327,7 +338,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
messages: messages,
history: history
@@ -391,7 +403,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
messages: messages,
history: history
@@ -483,9 +496,42 @@
-
+
-
+
diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte
index e6539e8d9..c8ab7882b 100644
--- a/src/routes/(app)/c/[id]/+page.svelte
+++ b/src/routes/(app)/c/[id]/+page.svelte
@@ -6,7 +6,7 @@
import { onMount, tick } from 'svelte';
import { convertMessagesToHistory, splitStream } from '$lib/utils';
import { goto } from '$app/navigation';
- import { config, user, settings, db, chats, chatId } from '$lib/stores';
+ import { config, modelfiles, user, settings, db, chats, chatId } from '$lib/stores';
import MessageInput from '$lib/components/chat/MessageInput.svelte';
import Messages from '$lib/components/chat/Messages.svelte';
@@ -20,6 +20,12 @@
// let chatId = $page.params.id;
let selectedModels = [''];
+ let selectedModelfile = null;
+ $: selectedModelfile =
+ selectedModels.length === 1 &&
+ $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0]).length > 0
+ ? $modelfiles.filter((modelfile) => modelfile.tagName === selectedModels[0])[0]
+ : null;
let title = '';
let prompt = '';
@@ -161,7 +167,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
format: $settings.requestFormat ?? undefined,
context:
@@ -233,7 +240,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
messages: messages,
history: history
@@ -301,7 +309,7 @@
.map((message) => ({ role: message.role, content: message.content })),
temperature: $settings.temperature ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined,
+ num_ctx: $settings.num_ctx ?? undefined,
frequency_penalty: $settings.repeat_penalty ?? undefined
})
});
@@ -362,7 +370,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
messages: messages,
history: history
@@ -424,7 +433,8 @@
repeat_penalty: $settings.repeat_penalty ?? undefined,
top_k: $settings.top_k ?? undefined,
top_p: $settings.top_p ?? undefined,
- num_ctx: $settings.num_ctx ?? undefined
+ num_ctx: $settings.num_ctx ?? undefined,
+ ...($settings.options ?? {})
},
messages: messages,
history: history
@@ -517,10 +527,42 @@