Skip to content

Commit

Permalink
added route to express
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtxRod17 committed May 3, 2024
1 parent 963e795 commit 48f97c9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions backend/routes/langchainCallRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,29 @@ langchainCallRoute.post("/askhfsql", async (req, res) => {
}
});

//Endpoint for HuggingFaceChef
langchainCallRoute.post("/askhfchef", async (req, res) => {
//call fastapi from this endpoint
try {
//get user input
const userInput = req.body.data;

//make request to fastapi server
const fastResponse = await axios.post(
"http://langchain:8000/hfprocesschef",
{
human_input: userInput,
}
);

//response from fastapi
const dataFromFastapi = fastResponse.data;

res.json({ message: "Successful call to FastAPI", dataFromFastapi });
} catch (error) {
console.error("Error calling FastAPI", error);
res.status(500).json({ error: "Failed to call FastAPI" });
}
});

export default langchainCallRoute;

0 comments on commit 48f97c9

Please sign in to comment.