Rooni commited on
Commit
d661f99
·
verified ·
1 Parent(s): 0a4053b

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +4 -4
server.js CHANGED
@@ -82,11 +82,11 @@ app.post('/gen', async (req, res) => {
82
  });
83
 
84
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
85
- const content = response.data.choices[0].message.content.trim();
86
- console.log(content);
87
- res.json({ content });
88
  } else {
89
- const content = response.data;
90
  console.log(content);
91
  res.json({ content: '+ошибка+❌ Не удалось прочитать ответ.-ошибка-' });
92
  }
 
82
  });
83
 
84
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
85
+ const content = JSON.parse(response.data);
86
+ console.log(response.data);
87
+ res.json({ content.candidates[0].content.parts.map(part => part.text).join(''); });
88
  } else {
89
+ const content = response;
90
  console.log(content);
91
  res.json({ content: '+ошибка+❌ Не удалось прочитать ответ.-ошибка-' });
92
  }