Spaces:
Sleeping
Sleeping
Commit
·
60aea28
1
Parent(s):
a1ea666
Add persona schema validation to settings POST endpoint
Browse files
src/routes/settings/(nav)/+server.ts
CHANGED
|
@@ -3,6 +3,17 @@ import { z } from "zod";
|
|
| 3 |
import { authCondition } from "$lib/server/auth";
|
| 4 |
import { DEFAULT_SETTINGS, type SettingsEditable } from "$lib/types/Settings";
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
export async function POST({ request, locals }) {
|
| 7 |
const body = await request.json();
|
| 8 |
|
|
@@ -13,7 +24,8 @@ export async function POST({ request, locals }) {
|
|
| 13 |
.default(DEFAULT_SETTINGS.shareConversationsWithModelAuthors),
|
| 14 |
welcomeModalSeen: z.boolean().optional(),
|
| 15 |
activeModel: z.string().default(DEFAULT_SETTINGS.activeModel),
|
| 16 |
-
|
|
|
|
| 17 |
multimodalOverrides: z.record(z.boolean()).default({}),
|
| 18 |
disableStream: z.boolean().default(false),
|
| 19 |
directPaste: z.boolean().default(false),
|
|
|
|
| 3 |
import { authCondition } from "$lib/server/auth";
|
| 4 |
import { DEFAULT_SETTINGS, type SettingsEditable } from "$lib/types/Settings";
|
| 5 |
|
| 6 |
+
const personaSchema = z.object({
|
| 7 |
+
id: z.string().min(1),
|
| 8 |
+
name: z.string().min(1).max(100),
|
| 9 |
+
occupation: z.string().max(200).default(""),
|
| 10 |
+
stance: z.string().max(200).default(""),
|
| 11 |
+
prompt: z.string().max(10000).default(""),
|
| 12 |
+
isDefault: z.boolean(),
|
| 13 |
+
createdAt: z.coerce.date(),
|
| 14 |
+
updatedAt: z.coerce.date(),
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
export async function POST({ request, locals }) {
|
| 18 |
const body = await request.json();
|
| 19 |
|
|
|
|
| 24 |
.default(DEFAULT_SETTINGS.shareConversationsWithModelAuthors),
|
| 25 |
welcomeModalSeen: z.boolean().optional(),
|
| 26 |
activeModel: z.string().default(DEFAULT_SETTINGS.activeModel),
|
| 27 |
+
activePersona: z.string().default(DEFAULT_SETTINGS.activePersona),
|
| 28 |
+
personas: z.array(personaSchema).min(1).default(DEFAULT_SETTINGS.personas),
|
| 29 |
multimodalOverrides: z.record(z.boolean()).default({}),
|
| 30 |
disableStream: z.boolean().default(false),
|
| 31 |
directPaste: z.boolean().default(false),
|