aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils.ts
diff options
context:
space:
mode:
authorMert Demir <mertd@users.noreply.github.com>2024-02-05 02:23:11 +0900
committerGitHub <noreply@github.com>2024-02-04 12:23:11 -0500
commitfb49fb596a56955ca70eac9da47d2826299469e1 (patch)
tree71dd092faf01d37b35a8015e3cfda494ddc7b99e /src/lib/utils.ts
parent10fd69404a69b15d5c0888d9382663f324455ec0 (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/utils.ts')
-rw-r--r--src/lib/utils.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index d0b32e2..39477d1 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -1,3 +1,4 @@
+import { Category } from '@prisma/client'
import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
@@ -15,3 +16,7 @@ export function formatExpenseDate(date: Date) {
timeZone: 'UTC',
})
}
+
+export function formatCategoryForAIPrompt(category: Category) {
+ return `"${category.grouping}/${category.name}" (ID: ${category.id})`
+}