fix endpoint
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
import { HuggingFaceInference } from "@langchain/community/llms/hf";
|
||||
|
||||
export async function POST(req, res) {
|
||||
export async function POST(req) {
|
||||
try {
|
||||
const { query } = req.body;
|
||||
const body = await req.json();
|
||||
const { query } = body;
|
||||
|
||||
const model = new HuggingFaceInference({
|
||||
model: 'm42-health/Llama3-Med42-8B',
|
||||
model: "m42-health/Llama3-Med42-8B",
|
||||
apiKey: process.env.HUGGING_FACE_API_KEY,
|
||||
});
|
||||
|
||||
const response = await model.invoke(query);
|
||||
|
||||
res.status(200).json({ answer: response });
|
||||
return new Response(JSON.stringify({ answer: response }), {
|
||||
status: 200,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Error generating response' });
|
||||
console.error("Backend error:", error);
|
||||
return new Response(JSON.stringify({ error: "Error generating response" }), {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user