Added support for ollama

pull/99/head
Lucas Bock 2 years ago
parent 9058da6ed9
commit 75c70cd71b

2
.gitignore vendored

@ -34,3 +34,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.env

@ -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",

Loading…
Cancel
Save