From bcf5492901292214fabe7b4ab0a941a68af4db41 Mon Sep 17 00:00:00 2001 From: Kwanghyun On Date: Mon, 28 Oct 2024 15:16:06 +0900 Subject: [PATCH 1/2] Hotfix zod error --- src/types/settings.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/types/settings.ts b/src/types/settings.ts index d091bfe..4f959b5 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -24,12 +24,19 @@ const smartCopilotSettingsSchema = z.object({ chatModel: chatModelSchema.catch('claude-3-5-sonnet-latest'), applyModel: applyModelSchema.catch('gpt-4o-mini'), embeddingModel: embeddingModelSchema.catch('text-embedding-3-small'), - ragOptions: z.object({ - chunkSize: z.number().catch(1000), - thresholdTokens: z.number().catch(8192), - minSimilarity: z.number().catch(0.0), - limit: z.number().catch(10), - }), + ragOptions: z + .object({ + chunkSize: z.number().catch(1000), + thresholdTokens: z.number().catch(8192), + minSimilarity: z.number().catch(0.0), + limit: z.number().catch(10), + }) + .catch({ + chunkSize: 1000, + thresholdTokens: 8192, + minSimilarity: 0.0, + limit: 10, + }), }) export type SmartCopilotSettings = z.infer From c6294107edc575088aeb5916a975b4eea91d5576 Mon Sep 17 00:00:00 2001 From: Kwanghyun On Date: Mon, 28 Oct 2024 15:24:57 +0900 Subject: [PATCH 2/2] Add test for parseSmartCopilotSettingsSchema --- src/types/settings.test.ts | 22 ++++++++++++++++++++++ src/types/settings.ts | 1 + 2 files changed, 23 insertions(+) create mode 100644 src/types/settings.test.ts diff --git a/src/types/settings.test.ts b/src/types/settings.test.ts new file mode 100644 index 0000000..5790425 --- /dev/null +++ b/src/types/settings.test.ts @@ -0,0 +1,22 @@ +import { parseSmartCopilotSettings } from './settings' + +describe('parseSmartCopilotSettings', () => { + it('should return default values for empty input', () => { + const result = parseSmartCopilotSettings({}) + expect(result).toEqual({ + openAIApiKey: '', + groqApiKey: '', + anthropicApiKey: '', + ollamaBaseUrl: '', + chatModel: 'claude-3-5-sonnet-latest', + applyModel: 'gpt-4o-mini', + embeddingModel: 'text-embedding-3-small', + ragOptions: { + chunkSize: 1000, + thresholdTokens: 8192, + minSimilarity: 0.0, + limit: 10, + }, + }) + }) +}) diff --git a/src/types/settings.ts b/src/types/settings.ts index 4f959b5..b774af3 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -16,6 +16,7 @@ const embeddingModelSchema = z.enum( EMBEDDING_MODEL_OPTIONS.map((opt) => opt.value) as [string, ...string[]], ) +// Update settings.test.ts after changing this schema const smartCopilotSettingsSchema = z.object({ openAIApiKey: z.string().catch(''), groqApiKey: z.string().catch(''),