Skip to content

Commit

Permalink
Merge pull request #11 from Neo-Zenith/wy-dev
Browse files Browse the repository at this point in the history
Wy dev
  • Loading branch information
Neo-Zenith authored Jan 20, 2024
2 parents 1b9266e + 9e57c10 commit 542ace5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
3 changes: 2 additions & 1 deletion express/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.env
20 changes: 18 additions & 2 deletions express/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.3.2",
"express": "^4.18.2",
"nodemon": "^3.0.3",
"socket.io": "^4.7.4"
Expand Down
32 changes: 32 additions & 0 deletions express/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const server = require("http").createServer(app);
// const helmet = require("helmet");
const cors = require("cors");
// const authRouters = require("./routers/authRouter");
require('dotenv').config()

const io = new Server(server, {
cors: {
Expand All @@ -21,10 +22,41 @@ app.use(
);
app.use(express.json());

async function queryXLNET(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/xlnet/xlnet-base-cased",
{
headers: { Authorization: process.env.HUGGING_FACE_TOKEN },
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
return result;
}



app.get("/", (req, res) => {
return res.json("hi");
});

app.get("/xlnet", async (req, res) => {
try {
const response = await queryXLNET({
"inputs": "Can you please let us know more details about your "
});
var ans = response[0]?.generated_text || '';
return res.json(ans);
} catch (error) {
console.error(error);
return res.status(500).json({ error: "Internal Server Error" });
}
});




app.get("/output", (req, res) => {
io.emit("new-output", "hello");
return res.json("successs");
Expand Down

0 comments on commit 542ace5

Please sign in to comment.