diff --git a/src/lib/stores/settings.ts b/src/lib/stores/settings.ts index b002c05336c..a1f2ee0886b 100644 --- a/src/lib/stores/settings.ts +++ b/src/lib/stores/settings.ts @@ -15,6 +15,7 @@ type SettingsStore = { customPrompts: Record; recentlySaved: boolean; assistants: Array; + customInstruction: string; }; type SettingsStoreWritable = Writable & { diff --git a/src/lib/types/Settings.ts b/src/lib/types/Settings.ts index 5a6804e05a8..0d179e95ed9 100644 --- a/src/lib/types/Settings.ts +++ b/src/lib/types/Settings.ts @@ -21,6 +21,8 @@ export interface Settings extends Timestamps { customPrompts?: Record; assistants?: Assistant["_id"][]; + + customInstruction?: string; } // TODO: move this to a constant file along with other constants @@ -30,4 +32,5 @@ export const DEFAULT_SETTINGS = { hideEmojiOnSidebar: false, customPrompts: {}, assistants: [], + customInstruction: "", }; diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 07cecca3ffa..19c8d904301 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -151,6 +151,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { DEFAULT_SETTINGS.shareConversationsWithModelAuthors, customPrompts: settings?.customPrompts ?? {}, assistants: userAssistants, + customInstruction: settings?.customInstruction ?? "", }, models: models.map((model) => ({ id: model.id, diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d0410802aa4..6640de5481b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -34,6 +34,9 @@ model = data.models[0].id; } } + let customPreprompt = $settings.customPrompts[$settings.activeModel] + ? $settings.customInstruction + "\n" + $settings.customPrompts[$settings.activeModel] + : undefined; const res = await fetch(`${base}/conversation`, { method: "POST", headers: { @@ -41,7 +44,7 @@ }, body: JSON.stringify({ model, - preprompt: $settings.customPrompts[$settings.activeModel], + preprompt: customPreprompt, assistantId: data.assistant?._id, }), }); diff --git a/src/routes/settings/+layout.svelte b/src/routes/settings/+layout.svelte index 82044d8feff..48b8850e9bd 100644 --- a/src/routes/settings/+layout.svelte +++ b/src/routes/settings/+layout.svelte @@ -10,6 +10,7 @@ import CarbonCheckmark from "~icons/carbon/checkmark"; import CarbonAdd from "~icons/carbon/add"; + import LicenseIcon from "~icons/carbon/license"; import UserIcon from "~icons/carbon/user"; import { fade, fly } from "svelte/transition"; export let data; @@ -76,6 +77,14 @@ {/if} {/each} + + +
Custom Instructions
+
{#if data.enableAssistants}

diff --git a/src/routes/settings/+server.ts b/src/routes/settings/+server.ts index 81289bacba2..2b9545adfd7 100644 --- a/src/routes/settings/+server.ts +++ b/src/routes/settings/+server.ts @@ -15,6 +15,7 @@ export async function POST({ request, locals }) { ethicsModalAccepted: z.boolean().optional(), activeModel: z.string().default(DEFAULT_SETTINGS.activeModel), customPrompts: z.record(z.string()).default({}), + customInstruction: z.string().default(""), }) .parse(body); diff --git a/src/routes/settings/custom/+page.svelte b/src/routes/settings/custom/+page.svelte new file mode 100644 index 00000000000..52d44e25a29 --- /dev/null +++ b/src/routes/settings/custom/+page.svelte @@ -0,0 +1,32 @@ + + +
+
+
+

Custom Instructions

+ {#if hasCustomInstruction} + + {/if} +
+