Rooni commited on
Commit
2a4f441
·
verified ·
1 Parent(s): dd3b1f5

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +9 -2
server.js CHANGED
@@ -81,17 +81,24 @@ app.post('/gen', async (req, res) => {
81
  },
82
  });
83
 
 
 
 
 
 
 
84
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
85
- console.log(response);
86
 
87
  const content = JSON.parse(response.data);
88
  res.json({ content: content.candidates[0].content.parts.map(part => part.text).join('') });
89
 
90
  } else {
91
- const content = response;
92
  console.log(content);
93
  res.json({ content: '+ошибка+❌ Не удалось прочитать ответ.-ошибка-' });
94
  }
 
95
  } catch (error) {
96
  console.error(error);
97
  res.json({ content: '+ошибка+❌ Произошла ошибка сервера при генерации.-ошибка-' });
 
81
  },
82
  });
83
 
84
+ console.log(response.data);
85
+
86
+ const content = JSON.parse(response.data);
87
+ res.json({ content: content.candidates[0].content.parts.map(part => part.text).join('') });
88
+
89
+ /*
90
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
91
+ console.log(response.data);
92
 
93
  const content = JSON.parse(response.data);
94
  res.json({ content: content.candidates[0].content.parts.map(part => part.text).join('') });
95
 
96
  } else {
97
+ const content = response.data;
98
  console.log(content);
99
  res.json({ content: '+ошибка+❌ Не удалось прочитать ответ.-ошибка-' });
100
  }
101
+ */
102
  } catch (error) {
103
  console.error(error);
104
  res.json({ content: '+ошибка+❌ Произошла ошибка сервера при генерации.-ошибка-' });