Skip to content

Commit

Permalink
refactor(intent): update intent using node v20
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed Feb 22, 2024
1 parent 5079500 commit 129c216
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 180 deletions.
5 changes: 2 additions & 3 deletions intent/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ module.exports = {
],
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
require('@babel/plugin-transform-modules-commonjs'),
require('@babel/plugin-transform-runtime'),
],
}
18 changes: 18 additions & 0 deletions intent/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const path = require('path')

module.exports = {
rootDir: "tests",
transform: {
"^.+\\.jsx?$": [
"babel-jest",
{ "configFile": path.resolve(__dirname, "babel.config.js") },
],
},
transformIgnorePatterns: [
"/node_modules/(?!@botonic).+\\.(js|jsx|ts|tsx)$"
],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(scss|css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
}
89 changes: 40 additions & 49 deletions intent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,52 @@
"version": "1.0.0",
"scripts": {
"build": "webpack --env target=all --mode=production",
"start": "webpack serve --env target=dev --mode=development",
"test": "jest",
"train:ner": "ts-node src/nlp/tasks/ner/train.ts",
"train:intent-classification": "ts-node src/nlp/tasks/intent-classification/train.ts"
},
"jest": {
"rootDir": "tests",
"transformIgnorePatterns": [
"/node_modules/(?!@botonic).+\\.(js|jsx|ts|tsx|mjs)$"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(scss|css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
"start": "webpack-dev-server --env target=dev --mode=development",
"deploy": "botonic deploy -c build",
"test": "jest"
},
"dependencies": {
"@botonic/plugin-dialogflow": "~0.21.0",
"@babel/runtime": "^7.12.5",
"@botonic/react": "~0.21.0"
"@botonic/plugin-dialogflow": "0.25.0-alpha.2",
"@babel/runtime": "^7.23.9",
"@botonic/react": "0.25.0-alpha.5"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-react": "^7.12.10",
"@hot-loader/react-dom": "^17.0.1",
"analytics-node": "^3.4.0-beta.3",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"chokidar": "^3.4.3",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.0.1",
"@babel/core": "^7.23.9",
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-react": "^7.23.3",
"@hot-loader/react-dom": "^16.14.0",
"analytics-node": "^3.5.0",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"chokidar": "^3.6.0",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.10.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.0.0-alpha.17",
"imagemin-gifsicle": "^6.0.0",
"imagemin-jpegtran": "^6.0.0",
"imagemin-optipng": "^7.0.0",
"imagemin-svgo": "^7.0.0",
"imagemin-webpack": "^5.0.0",
"jest": "^26.6.3",
"node-sass": "^8.0.0",
"html-webpack-plugin": "^5.6.0",
"image-minimizer-webpack-plugin": "^4.0.0",
"imagemin": "^8.0.1",
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^7.0.0",
"imagemin-optipng": "^8.0.0",
"imagemin-svgo": "^10.0.1",
"jest": "^29.7.0",
"null-loader": "^4.0.1",
"process": "^0.11.10",
"react-hot-loader": "^4.13.0",
"sass": "^1.30.0",
"sass-loader": "^10.1.0",
"style-loader": "^2.0.0",
"terser": "^5.5.1",
"terser-webpack-plugin": "^5.0.3",
"ts-node": "^10.4.0",
"typescript": "^4.4.4",
"webpack": "^5.10.3",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "4.13.3"
"react-hot-loader": "4.12.21",
"sass": "^1.71.1",
"sass-loader": "^14.1.1",
"style-loader": "^3.3.4",
"svgo": "^3.2.0",
"terser": "^5.27.2",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "5.0.2"
},
"engines": {
"node": ">=20.0.0"
}
}

Empty file removed intent/src/nlp/data/en/.gitkeep
Empty file.
Empty file.
68 changes: 0 additions & 68 deletions intent/src/nlp/tasks/intent-classification/train.ts

This file was deleted.

121 changes: 110 additions & 11 deletions intent/src/plugins.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,119 @@
import * as pluginDialogflow from '@botonic/plugin-dialogflow'

export const plugins = [
{
id: 'dialogflow',
resolve: require('@botonic/plugin-dialogflow'),
resolve: pluginDialogflow,
// Copy-past here the generated JSON: https://dialogflow.com/docs/reference/v2-auth-setup
options: {
credentials: {
type: 'service_account',
project_id: 'YOUR_PROJECT_ID',
private_key_id: 'YOUR_PRIVATE_KEY_ID',
private_key: 'YOUR_PRIVATE_KEY',
client_email: 'YOUR_CLIENT_EMAIL',
client_id: 'CLIENT_ID',
auth_uri: 'AUTH_URI',
token_uri: 'TOKEN_URI',
auth_provider_x509_cert_url: 'AUT_PROVIDER_X509_CERT_URL',
client_x509_cert_url: 'CLIENT_X509_CERT_URL',

"id": "f6ceb22d-0351-4fd6-a6b6-97d707d7e4b8",
"name": "Default Welcome Intent",
"auto": true,
"condition": "",
"conditionalFollowupEvents": [],
"conditionalResponses": [],
"context": [],
"contexts": [],
"endInteraction": false,
"events": [
{
"name": "WELCOME"
}
],
"fallbackIntent": false,
"liveAgentHandoff": false,
"parentId": null,
"followUpIntents": [],
"priority": 500000,
"responses": [
{
"action": "input.welcome",
"affectedContexts": [],
"parameters": [],
"defaultResponsePlatforms": {},
"messages": [
{
"type": "message",
"condition": "",
"speech": [
"¡Hola!",
"¡Hey!",
"¡Buenos días!"
]
}
],
"resetContexts": false
}
],
"rootParentId": null,
"templates": [],
"userSays": [
{
"isTemplate": false,
"data": [
{
"text": "hola",
"userDefined": false
}
],
"count": 0,
"id": "968a548d-bc43-4922-b0f0-b4d95e4479b4",
"updated": null
},
{
"isTemplate": false,
"data": [
{
"text": "hey",
"userDefined": false
}
],
"count": 0,
"id": "8e6201b2-5115-4503-b2b9-b64a57701507",
"updated": null
},
{
"isTemplate": false,
"data": [
{
"text": "saludos",
"userDefined": false
}
],
"count": 0,
"id": "5094725c-196e-4f52-9eed-254cf0dcfc40",
"updated": null
},
{
"isTemplate": false,
"data": [
{
"text": "hey ho",
"userDefined": false
}
],
"count": 0,
"id": "df1cc2ca-9f39-45d9-b56c-9049c6577475",
"updated": null
},
{
"isTemplate": false,
"data": [
{
"text": "chao",
"userDefined": false
}
],
"count": 0,
"id": "68adecfd-5fdd-497e-94b4-51456f10a520",
"updated": null
}
],
"webhookForSlotFilling": false,
"webhookUsed": false

}
},
},
Expand Down
15 changes: 7 additions & 8 deletions intent/tests/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import { routes } from '../src/routes'

const app = new NodeApp({ routes, locales, ...config })

const i = new BotonicInputTester(app)
const o = new BotonicOutputTester(app)
const input = new BotonicInputTester(app)
const output = new BotonicOutputTester(app)

test('TEST: (404) NOT FOUND', async () => {
await expect(i.text('whatever')).resolves.toBe(
o.text(
// replace with 'Try typing "hello" to start the bot.' after configuring dialogflow
`Enter the generated JSON key for dialogflowV2 in plugins.js to test the bot.`
)
)
const response = await input.text('whatever')
expect(response).toBe(output.text(
// replace with 'Try typing "hello" to start the bot.' after configuring dialogflow
`Enter the generated JSON key for dialogflowV2 in plugins.js to test the bot.`
))
})
Loading

0 comments on commit 129c216

Please sign in to comment.