update ai stuff

This commit is contained in:
overcuriousity
2025-07-16 21:14:50 +02:00
parent 073f52bada
commit 89f45b85be
6 changed files with 1014 additions and 18 deletions

View File

@@ -5,10 +5,8 @@ import { promises as fs } from 'fs';
import { load } from 'js-yaml';
import path from 'path';
export const prerender = false;
function getEnv(key: string): string {
const value = process.env[key];
if (!value) {
@@ -211,7 +209,7 @@ export const POST: APIRoute = async ({ request }) => {
'Authorization': `Bearer ${process.env.AI_API_KEY}`
},
body: JSON.stringify({
model: AI_MODEL, // or whatever model is available
model: 'gpt-4o-mini', // or whatever model is available
messages: [
{
role: 'system',
@@ -248,8 +246,7 @@ export const POST: APIRoute = async ({ request }) => {
// Parse AI JSON response
let recommendation;
try {
const cleanedContent = stripMarkdownJson(aiContent);
recommendation = JSON.parse(cleanedContent);
recommendation = JSON.parse(aiContent);
} catch (error) {
console.error('Failed to parse AI response:', aiContent);
return new Response(JSON.stringify({ error: 'Invalid AI response format' }), {