Spaces:
Running
Running
Update routes/index.js
Browse files- routes/index.js +7 -2
routes/index.js
CHANGED
@@ -3,7 +3,12 @@ var router = express.Router();
|
|
3 |
var textToSpeech = require('../helpers/tts');
|
4 |
var callOpenAI = require('../helpers/callOpenAI'); // Import the helper function
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
try {
|
8 |
const ttsResult = await textToSpeech(req.body.text, req.body.language);
|
9 |
res.json(ttsResult);
|
@@ -13,7 +18,7 @@ router.post('/talk', async function(req, res, next) {
|
|
13 |
}
|
14 |
});
|
15 |
|
16 |
-
router.post('/chat', async function(req, res, next) {
|
17 |
try {
|
18 |
const userContent = req.body.text;
|
19 |
const openAIResponse = await callOpenAI(userContent);
|
|
|
3 |
var textToSpeech = require('../helpers/tts');
|
4 |
var callOpenAI = require('../helpers/callOpenAI'); // Import the helper function
|
5 |
|
6 |
+
function logRequestBody(req, res, next) {
|
7 |
+
console.log('Request body:', req.body);
|
8 |
+
next();
|
9 |
+
}
|
10 |
+
|
11 |
+
router.post('/talk', logRequestBody, async function(req, res, next) {
|
12 |
try {
|
13 |
const ttsResult = await textToSpeech(req.body.text, req.body.language);
|
14 |
res.json(ttsResult);
|
|
|
18 |
}
|
19 |
});
|
20 |
|
21 |
+
router.post('/chat', logRequestBody, async function(req, res, next) {
|
22 |
try {
|
23 |
const userContent = req.body.text;
|
24 |
const openAIResponse = await callOpenAI(userContent);
|