feat: remove search rerank
This commit is contained in:
@@ -22,21 +22,16 @@ export default defineEventHandler(async (event) => {
|
||||
rename: {
|
||||
enabled: false,
|
||||
modelId: null,
|
||||
},
|
||||
rerank: {
|
||||
enabled: false,
|
||||
modelId: null,
|
||||
}
|
||||
};
|
||||
|
||||
if (existing) {
|
||||
const missingSystemAssistants = Object.keys(defaultSystemAssistants).filter(key => !(key in existing!.systemAssistants));
|
||||
if (missingSystemAssistants.length > 0) {
|
||||
if (!("rename" in existing.systemAssistants) || "rerank" in existing.systemAssistants) {
|
||||
const [updated] = await db.update(settings)
|
||||
.set({
|
||||
systemAssistants: {
|
||||
...defaultSystemAssistants,
|
||||
...existing.systemAssistants,
|
||||
rename: existing.systemAssistants.rename ?? defaultSystemAssistants.rename,
|
||||
},
|
||||
})
|
||||
.where(eq(settings.id, existing.id)).returning();
|
||||
|
||||
@@ -12,7 +12,12 @@ const appearanceSchema = z.object({
|
||||
});
|
||||
|
||||
const updateSettingsSchema = z.object({
|
||||
systemAssistants: z.any().optional(),
|
||||
systemAssistants: z.object({
|
||||
rename: z.object({
|
||||
enabled: z.boolean(),
|
||||
modelId: z.string().nullable(),
|
||||
}).partial().optional(),
|
||||
}).optional(),
|
||||
appearance: appearanceSchema.optional(),
|
||||
});
|
||||
|
||||
@@ -53,28 +58,22 @@ export default defineEventHandler(async (event) => {
|
||||
return { ...base, ...incoming };
|
||||
};
|
||||
|
||||
const mergeSystemAssistants = (
|
||||
existingSA: Record<string, unknown> | null,
|
||||
incoming: typeof updates.systemAssistants,
|
||||
): Record<string, unknown> => {
|
||||
const base = existingSA || {};
|
||||
if (!incoming) return base;
|
||||
return { ...base, ...incoming };
|
||||
const newSystemAssistants = {
|
||||
rename: {
|
||||
enabled: updates.systemAssistants?.rename?.enabled ?? existing.systemAssistants.rename?.enabled ?? false,
|
||||
modelId: updates.systemAssistants?.rename?.modelId !== undefined
|
||||
? updates.systemAssistants.rename.modelId
|
||||
: existing.systemAssistants.rename?.modelId ?? null,
|
||||
},
|
||||
};
|
||||
|
||||
const newAppearance = mergeAppearance(
|
||||
existing.appearance as Record<string, unknown> | null,
|
||||
updates.appearance,
|
||||
);
|
||||
const newSystemAssistants = mergeSystemAssistants(
|
||||
existing.systemAssistants as Record<string, unknown> | null,
|
||||
updates.systemAssistants,
|
||||
);
|
||||
|
||||
await db.update(settings)
|
||||
.set({
|
||||
appearance: newAppearance,
|
||||
// @ts-ignore - I dont have the energy to type this correctly right now
|
||||
systemAssistants: newSystemAssistants,
|
||||
})
|
||||
.where(and(eq(settings.id, existingId)));
|
||||
|
||||
Reference in New Issue
Block a user