mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
BREAKING: postgres + saas
This commit is contained in:
16
ai/schema.ts
Normal file
16
ai/schema.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Field } from "@prisma/client"
|
||||
|
||||
export const fieldsToJsonSchema = (fields: Field[]) => {
|
||||
const fieldsWithPrompt = fields.filter((field) => field.llm_prompt)
|
||||
const schema = {
|
||||
type: "object",
|
||||
properties: fieldsWithPrompt.reduce((acc, field) => {
|
||||
acc[field.code] = { type: field.type, description: field.llm_prompt || "" }
|
||||
return acc
|
||||
}, {} as Record<string, { type: string; description: string }>),
|
||||
required: fieldsWithPrompt.map((field) => field.code),
|
||||
additionalProperties: false,
|
||||
}
|
||||
|
||||
return schema
|
||||
}
|
||||
Reference in New Issue
Block a user