use different endpoint structure
This commit is contained in:
@@ -1,23 +1,19 @@
|
|||||||
import { HuggingFaceInference } from "@langchain/community/llms/hf";
|
import { HuggingFaceInference } from "@langchain/community/llms/hf";
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export async function POST(req, res) {
|
||||||
if (req.method === 'POST') {
|
try {
|
||||||
try {
|
const { query } = req.body;
|
||||||
const { query } = req.body;
|
|
||||||
|
|
||||||
const model = new HuggingFaceInference({
|
const model = new HuggingFaceInference({
|
||||||
model: 'm42-health/Llama3-Med42-8B',
|
model: 'm42-health/Llama3-Med42-8B',
|
||||||
apiKey: process.env.HUGGING_FACE_API_KEY,
|
apiKey: process.env.HUGGING_FACE_API_KEY,
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await model.invoke(query);
|
const response = await model.invoke(query);
|
||||||
|
|
||||||
res.status(200).json({ answer: response });
|
res.status(200).json({ answer: response });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
res.status(500).json({ error: 'Error generating response' });
|
res.status(500).json({ error: 'Error generating response' });
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res.status(405).json({ error: 'Method Not Allowed' });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user