fix for huggingface
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import { InferenceAPI } from '@huggingface/inference';
|
||||
|
||||
const hfAPI = new InferenceAPI({ apiKey: process.env.HUGGING_FACE_API_KEY });
|
||||
import { HuggingFaceInference } from "@langchain/community/llms/hf";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
if (req.method === 'POST') {
|
||||
try {
|
||||
const { query } = req.body;
|
||||
|
||||
const response = await hfAPI.query('m42-health/Llama3-Med42-8B', { inputs: { text: query } });
|
||||
const model = new HuggingFaceInference({
|
||||
model: 'm42-health/Llama3-Med42-8B',
|
||||
apiKey: process.env.HUGGING_FACE_API_KEY,
|
||||
});
|
||||
|
||||
res.status(200).json({ answer: response.data[0].generated_text });
|
||||
const response = await model.invoke(query);
|
||||
|
||||
res.status(200).json({ answer: response });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Error generating response' });
|
||||
|
||||
Reference in New Issue
Block a user