Spaces:
Build error
Build error
Better logs
Browse files
server.ts
CHANGED
@@ -6,6 +6,14 @@ const INFERENCE_URL =
|
|
6 |
"https://api-inference.huggingface.co/models/bigscience/bloom";
|
7 |
const PROMPT = `Pretend that you are a bot that replies to discussions about machine learning, and reply to the following comment:\n`;
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
const app = express();
|
10 |
// parse HTTP request bodies as json
|
11 |
app.use(express.json());
|
@@ -16,6 +24,7 @@ app.get("/", (req, res) => {
|
|
16 |
|
17 |
app.post("/", async (req, res) => {
|
18 |
if (req.header("X-Webhook-Secret") !== process.env.WEBHOOK_SECRET) {
|
|
|
19 |
return res.status(400).json({ error: "incorrect secret" });
|
20 |
}
|
21 |
console.log(req.body);
|
|
|
6 |
"https://api-inference.huggingface.co/models/bigscience/bloom";
|
7 |
const PROMPT = `Pretend that you are a bot that replies to discussions about machine learning, and reply to the following comment:\n`;
|
8 |
|
9 |
+
if (!process.env.WEBHOOK_SECRET || !process.env.HF_TOKEN) {
|
10 |
+
console.error(
|
11 |
+
"This app needs those env variables to be defined",
|
12 |
+
"WEBHOOK_SECRET, HF_TOKEN"
|
13 |
+
);
|
14 |
+
process.exit();
|
15 |
+
}
|
16 |
+
|
17 |
const app = express();
|
18 |
// parse HTTP request bodies as json
|
19 |
app.use(express.json());
|
|
|
24 |
|
25 |
app.post("/", async (req, res) => {
|
26 |
if (req.header("X-Webhook-Secret") !== process.env.WEBHOOK_SECRET) {
|
27 |
+
console.error("incorrect secret");
|
28 |
return res.status(400).json({ error: "incorrect secret" });
|
29 |
}
|
30 |
console.log(req.body);
|