smolSWE commited on
Commit
c3558ea
·
verified ·
1 Parent(s): d5c3978

Update server.ts

Browse files
Files changed (1) hide show
  1. server.ts +13 -11
server.ts CHANGED
@@ -1,7 +1,7 @@
1
  import * as express from "express";
2
 
3
  const PORT = 7860;
4
- const BOT_USERNAME = "@discussion-bot";
5
  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`;
@@ -34,17 +34,19 @@ app.post("/", async (req, res) => {
34
  event.scope === "discussion.comment" &&
35
  req.body.comment.content.includes(BOT_USERNAME)
36
  ) {
37
- const response = await fetch(INFERENCE_URL, {
38
- method: "POST",
39
- body: JSON.stringify({ inputs: PROMPT + req.body.comment.content }),
40
- });
41
- if (response.ok) {
42
- const output = await response.json();
43
- const continuationText = output[0].generated_text.replace(
44
- PROMPT + req.body.comment.content,
45
- ""
46
- );
47
 
 
 
48
  console.log(continuationText);
49
  /// Finally, let's post it as a comment in the same discussion
50
  const commentUrl = req.body.discussion.url.api + "/comment";
 
1
  import * as express from "express";
2
 
3
  const PORT = 7860;
4
+ const BOT_USERNAME = "@smolSWE";
5
  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`;
 
34
  event.scope === "discussion.comment" &&
35
  req.body.comment.content.includes(BOT_USERNAME)
36
  ) {
37
+ // const response = await fetch(INFERENCE_URL, {
38
+ // method: "POST",
39
+ // body: JSON.stringify({ inputs: PROMPT + req.body.comment.content }),
40
+ // });
41
+ // if (response.ok) {
42
+ // const output = await response.json();
43
+ // const continuationText = output[0].generated_text.replace(
44
+ // PROMPT + req.body.comment.content,
45
+ // ""
46
+ // );
47
 
48
+ const continuationText = `You asked for ${req.body.comment.content}`;
49
+
50
  console.log(continuationText);
51
  /// Finally, let's post it as a comment in the same discussion
52
  const commentUrl = req.body.discussion.url.api + "/comment";