From 2ef069b17fceafb6a22fe4216513ee86b1aca80d Mon Sep 17 00:00:00 2001 From: KartikGS Date: Mon, 19 Feb 2024 16:15:53 +0530 Subject: [PATCH 1/4] Custom instruction anchor in settings --- src/routes/settings/+layout.svelte | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/routes/settings/+layout.svelte b/src/routes/settings/+layout.svelte index dbc2bd1f420..8906e47b26d 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}

From e76995d66bd33eeeda13ba18d5cf5921982a5c95 Mon Sep 17 00:00:00 2001 From: KartikGS Date: Fri, 23 Feb 2024 12:20:26 +0530 Subject: [PATCH 2/4] persistant custom instruction --- src/lib/stores/settings.ts | 1 + src/lib/types/Settings.ts | 3 +++ src/routes/+layout.server.ts | 1 + src/routes/settings/+server.ts | 1 + src/routes/settings/custom/+page.svelte | 34 +++++++++++++++++++++++++ src/routes/settings/custom/+page.ts | 8 ++++++ 6 files changed, 48 insertions(+) create mode 100644 src/routes/settings/custom/+page.svelte create mode 100644 src/routes/settings/custom/+page.ts diff --git a/src/lib/stores/settings.ts b/src/lib/stores/settings.ts index 4839c4fa8e7..a29087f30c8 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; }; export function useSettingsStore() { 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 ba55c921f26..05a14d0fe66 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -139,6 +139,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { DEFAULT_SETTINGS.shareConversationsWithModelAuthors, customPrompts: settings?.customPrompts ?? {}, assistants: settings?.assistants?.map((el) => el.toString()) ?? [], + customInstruction: settings?.customInstruction ?? "", }, models: models.map((model) => ({ id: model.id, 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..6f05a5808f5 --- /dev/null +++ b/src/routes/settings/custom/+page.svelte @@ -0,0 +1,34 @@ + + +
+
+
+

Custom Instructions

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