<commit_before>"use strict";

const express = require('express');
const apiai = require("apiai");
const http = require('http');
const {async, await} = require('asyncawait');
const bodyParser = require('body-parser');
const actions = require('./actions');
var models = require('./models');
const app = express();
const server = http.createServer(app);
const env = process.env.NODE_ENV || "DEV";
const {keys} = require('./config')[env];
const PORT = process.env.PORT || 3000;
const AI = apiai(keys.apiai.client);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.get('/', (req, res) => {
    const request = AI.textRequest(req.query.q, { sessionId: req.query.s });

    request.on('response', async(response => {
        console.log(JSON.stringify(response, undefined, 2));

        const fulfillment = response.result.fulfillment.speech;
        if(fulfillment) return res.send(fulfillment);

        const action = response.result.metadata.intentName;
        const params = response.result.parameters;

        const data = await(actions[action](params));
        res.json(data);
    }));

    request.on('error', error => {
        console.log(error);
        res.status(500).send('ERROR!');
    });

    request.end();
});

// models.sequelize.sync({force: true}).then(() => {
models.sequelize.sync().then(() => {
  server.listen(PORT, () => {
    console.log(`AsliBot server listening on port ${PORT} in ${env} mode`);
  })<commit_msg>fulfillment resp updated<commit_after>"use strict";

const express = require('express');
const apiai = require("apiai");
const http = require('http');
const {async, await} = require('asyncawait');
const bodyParser = require('body-parser');
const actions = require('./actions');
var models = require('./models');
const app = express();
const server = http.createServer(app);
const env = process.env.NODE_ENV || "DEV";
const {keys} = require('./config')[env];
const PORT = process.env.PORT || 3000;
const AI = apiai(keys.apiai.client);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.get('/', (req, res) => {
    const request = AI.textRequest(req.query.q, { sessionId: req.query.s });

    request.on('response', async(response => {
        console.log(JSON.stringify(response, undefined, 2));

        const fulfillment = response.result.fulfillment.speech;
        if(fulfillment) return res.json({ error: false, data: fulfillment });

        const action = response.result.metadata.intentName;
        const params = response.result.parameters;

        const data = await(actions[action](params));
        res.json(data);
    }));

    request.on('error', error => {
        console.log(error);
        res.status(500).send('ERROR!');
    });

    request.end();
});

// models.sequelize.sync({force: true}).then(() => {
models.sequelize.sync().then(() => {
  server.listen(PORT, () => {
    console.log(`AsliBot server listening on port ${PORT} in ${env} mode`);
  })
{'fraction_non_alphanumeric': 0.18525963149078728, 'fraction_numerical': 0.005360134003350084, 'mean_word_length': 3.8790849673202614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3027793', 'n_tokens_mistral': 920, 'n_tokens_neox': 896, 'n_words': 196}