From 75c70cd71b4fe35bfc89499616dccfbaaa8e5ee2 Mon Sep 17 00:00:00 2001 From: Lucas Bock Date: Mon, 14 Oct 2024 07:32:47 -0500 Subject: [PATCH] Added support for ollama --- .gitignore | 2 ++ app/api/toHtml/route.ts | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fd3dbb5..b9f8d23 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +.env \ No newline at end of file diff --git a/app/api/toHtml/route.ts b/app/api/toHtml/route.ts index 7223ac1..bc053dc 100644 --- a/app/api/toHtml/route.ts +++ b/app/api/toHtml/route.ts @@ -6,12 +6,20 @@ const systemPrompt = `You are an expert tailwind developer. A user will provide if you need to insert an image, use placehold.co to create a placeholder image. Respond only with the html file.`; export async function POST(request: Request) { - const openai = new OpenAI(); + const apiKey = process.env.OPENAI_API_KEY; + const baseURL = process.env.OPENAI_BASE_URL; + const model = process.env.OPENAI_MODEL ?? "gpt-4o"; + const max_tokens = process.env.OPENAI_MAX_TOKENS + ? parseInt(process.env.OPENAI_MAX_TOKENS, 10) + : 4096; + + const openai = new OpenAI({ baseURL, apiKey }); + const { image } = await request.json(); const resp = await openai.chat.completions.create({ - model: "gpt-4o", - max_tokens: 4096, + model, + max_tokens, messages: [ { role: "system",