get correct text in json
This commit is contained in:
@@ -51,8 +51,10 @@ export async function POST(req) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.text();
|
const data = await response.json();
|
||||||
return new Response(JSON.stringify({ answer: data }), { status: 200 });
|
const answer = data?.choices?.[0]?.message?.content || "No answer found";
|
||||||
|
|
||||||
|
return new Response(JSON.stringify({ answer }), { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Backend error:", error);
|
console.error("Backend error:", error);
|
||||||
return new Response(
|
return new Response(
|
||||||
|
|||||||
Reference in New Issue
Block a user