refactor: simplify parse ingredients code
This commit is contained in:
@@ -3,7 +3,7 @@ import { zodResponseFormat } from "https://deno.land/x/openai@v4.69.0/helpers/zo
|
||||
import { OPENAI_API_KEY } from "@lib/env.ts";
|
||||
import { hashString } from "@lib/helpers.ts";
|
||||
import { createCache } from "@lib/cache.ts";
|
||||
import recipeSchema from "@lib/recipeSchema.ts";
|
||||
import recipeSchema, { recipeResponseSchema } from "@lib/recipeSchema.ts";
|
||||
|
||||
const openAI = OPENAI_API_KEY && new OpenAI({ apiKey: OPENAI_API_KEY });
|
||||
|
||||
@@ -223,7 +223,7 @@ export async function extractRecipe(content: string) {
|
||||
},
|
||||
{ role: "user", content },
|
||||
],
|
||||
response_format: zodResponseFormat(recipeSchema, "recipe-v2"),
|
||||
response_format: zodResponseFormat(recipeResponseSchema, "recipe-v2"),
|
||||
});
|
||||
|
||||
return recipeSchema.parse(completion.choices[0].message.parsed);
|
||||
|
||||
Reference in New Issue
Block a user