randydev commited on
Commit
0d6a55d
·
verified ·
1 Parent(s): 57676b8

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +5 -5
index.js CHANGED
@@ -3,7 +3,7 @@ const app = express()
3
  const port = 7860
4
  const axios = require('axios')
5
 
6
- const headers_gpt = {
7
  "Accept": "application/json",
8
  "Content-Type": "application/json",
9
  "Accept-Language": "en",
@@ -28,20 +28,20 @@ app.get('/api/test', async (req, res) => {
28
  }
29
  })
30
 
31
- /*
32
  app.post('/api/chatgpt-old', async (req, res) => {
33
  try {
34
  query = req.params.query
35
  const payload = {"prompt": query}
36
  const type_urls = "openai-gpt"
37
  const url = "https://${type_urls}.remixproject.org"
38
- await axios.post(url, payload, {headersGPT})
39
- res.json({message: "Hello world"})
 
 
40
  } catch (error) {
41
  res.status(401).json({error: error.message})
42
  }
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
+ const headers = {
7
  "Accept": "application/json",
8
  "Content-Type": "application/json",
9
  "Accept-Language": "en",
 
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.choice.[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}`)