diff options
| author | Mert Demir <mertd@users.noreply.github.com> | 2024-02-05 02:23:11 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-04 12:23:11 -0500 |
| commit | fb49fb596a56955ca70eac9da47d2826299469e1 (patch) | |
| tree | 71dd092faf01d37b35a8015e3cfda494ddc7b99e /src/lib/env.ts | |
| parent | 10fd69404a69b15d5c0888d9382663f324455ec0 (diff) | |
Automatic category from expense title (#80)
* environment variable
* random category draft
* get category from ai
* input limit and documentation
* use watch
* use field.name
* prettier
* presigned upload, readme warning, category to string util
* prettier
* check whether feature is enabled
* use process.env
* improved prompt to return id only
* remove console.debug
* show loader
* share class name
* prettier
* use template literals
* rename format util
* prettier
Diffstat (limited to 'src/lib/env.ts')
| -rw-r--r-- | src/lib/env.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/env.ts b/src/lib/env.ts index f1d59db..927e756 100644 --- a/src/lib/env.ts +++ b/src/lib/env.ts @@ -19,6 +19,7 @@ const envSchema = z S3_UPLOAD_REGION: z.string().optional(), S3_UPLOAD_ENDPOINT: z.string().optional(), NEXT_PUBLIC_ENABLE_RECEIPT_EXTRACT: z.coerce.boolean().default(false), + NEXT_PUBLIC_ENABLE_CATEGORY_EXTRACT: z.coerce.boolean().default(false), OPENAI_API_KEY: z.string().optional(), }) .superRefine((env, ctx) => { @@ -36,11 +37,15 @@ const envSchema = z 'If NEXT_PUBLIC_ENABLE_EXPENSE_DOCUMENTS is specified, then S3_* must be specified too', }) } - if (env.NEXT_PUBLIC_ENABLE_RECEIPT_EXTRACT && !env.OPENAI_API_KEY) { + if ( + (env.NEXT_PUBLIC_ENABLE_RECEIPT_EXTRACT || + env.NEXT_PUBLIC_ENABLE_CATEGORY_EXTRACT) && + !env.OPENAI_API_KEY + ) { ctx.addIssue({ code: ZodIssueCode.custom, message: - 'If NEXT_PUBLIC_ENABLE_RECEIPT_EXTRACT is specified, then OPENAI_API_KEY must be specified too', + 'If NEXT_PUBLIC_ENABLE_RECEIPT_EXTRACT or NEXT_PUBLIC_ENABLE_CATEGORY_EXTRACT is specified, then OPENAI_API_KEY must be specified too', }) } }) |
