randydev commited on
Commit
17f2e27
·
verified ·
1 Parent(s): 16d958b

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +24 -23
index.js CHANGED
@@ -3,19 +3,6 @@ const app = express()
3
  const port = 7860
4
  const axios = require('axios')
5
 
6
- const headers = {
7
- "Accept": "application/json",
8
- "Content-Type": "application/json",
9
- "Accept-Language": "en",
10
- "Connection": "keep-alive",
11
- "Origin": "https://remix.ethereum.org/",
12
- "Referer": "https://remix.ethereum.org/",
13
- "Sec-Fetch-Dest": "empty",
14
- "Sec-Fetch-Mode": "cors",
15
- "Sec-Fetch-Site": "cross-site",
16
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"
17
- }
18
-
19
  app.get('/', (req, res) => {
20
  res.send('Hello World!')
21
  })
@@ -28,20 +15,34 @@ app.get('/api/test', async (req, res) => {
28
  }
29
  })
30
 
31
- app.post('/api/chatgpt-old', async (req, res) => {
32
  try {
33
- query = req.params.query
34
- const payload = {"prompt": query}
 
 
35
  const type_urls = "openai-gpt";
36
- const url = `https://${type_urls}.remixproject.org`;
37
- const response = await axios.post(url, payload, { headers })
38
- console.log('Response:', response.data)
39
- const output = response.data.choices[0].message.content
40
- res.json({message: output})
41
  } catch (error) {
42
- res.status(401).json({error: error.message})
43
  }
44
- })
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  app.listen(port, () => {
47
  console.log(`Example app listening on port ${port}`)
 
3
  const port = 7860
4
  const axios = require('axios')
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  app.get('/', (req, res) => {
7
  res.send('Hello World!')
8
  })
 
15
  }
16
  })
17
 
18
+ const AkenoXWeb = async (prompt) => {
19
  try {
20
+ const payload = {
21
+ "prompt": prompt,
22
+ "bid": "040d0481"
23
+ };
24
  const type_urls = "openai-gpt";
25
+ const url = "https://bot-management-4tozrh7z2a-ue.a.run.app/chat/web";
26
+ const response = await axios.post(url, payload);
27
+ console.log('Response:', response.data);
28
+ const output = response.data.answer;
29
+ return output;
30
  } catch (error) {
31
+ return "Error data" + error.message;
32
  }
33
+ };
34
+
35
+ app.post('/api/akenoweb', async (req, res) => {
36
+ try {
37
+ const query = req.params.query;
38
+ const output = await AkenoXWeb(query);
39
+ res.json({ message: output });
40
+ } catch (error) {
41
+ res.status(401).json({ error: error.message });
42
+ }
43
+ });
44
+
45
+ on Hugging face without semicolon works
46
 
47
  app.listen(port, () => {
48
  console.log(`Example app listening on port ${port}`)