Compare commits

...

543 Commits

Author SHA1 Message Date
louistiti 754bd7380f build(bridge/python): 1.2.0 2023-11-14 22:38:34 +08:00
louistiti d32cda3663 build(bridge/nodejs): 1.1.0 2023-11-14 22:35:27 +08:00
louistiti c8d2e8c985 chore: bump to 1.0.0-beta.10+dev 2023-11-12 22:22:56 +08:00
louistiti 2a15434919 Merge branch 'feat-improve-ner-types' into develop 2023-11-12 18:16:37 +08:00
louistiti b2c375861b feat: identify entities from utterance samples for a better prioritization of classifications 2023-11-12 18:14:16 +08:00
Théo LUDWIG ae6fec335d fix(skill/date_time): add follow up utterance samples 2023-07-24 23:00:30 +02:00
louistiti 16302ec6e4 Merge branch 'develop' into feat-improve-ner-types 2023-07-23 11:26:38 +08:00
Louis Grenard 4d03e1bb4e docs(README): add knowledge base LLM scenario 2023-07-23 11:15:23 +08:00
Théo LUDWIG 69ce669b4c feat(tcp server): remove unnecessary data from entity + detect most populated city 2023-07-02 11:09:22 +02:00
Théo LUDWIG c512b422e7 feat(web app): add "Show more" when answer is "too big" 2023-07-01 23:33:41 +02:00
Théo LUDWIG 2ad6541c3e feat(skill/help): helps you get started with Leon 2023-07-01 23:28:55 +02:00
Théo LUDWIG 379326d7c1 feat(bridge/nodejs): simplify leon.setAnswerData 2023-07-01 23:24:29 +02:00
Théo LUDWIG 1359f5d210 feat(bridge/python): simplify leon.set_answer_data 2023-07-01 23:23:34 +02:00
Théo LUDWIG 64858ec6fe feat(tcp server): add Country information to City 2023-07-01 19:01:57 +02:00
Théo LUDWIG 166175192d feat(tcp server): better detect cities thanks to alternate names 2023-07-01 19:00:34 +02:00
Théo LUDWIG 97de1d1c3f fix(skill/date_time): correct time zone with toLocaleString method 2023-07-01 18:24:19 +02:00
louistiti 563792bd0a fix(tcp server): use root path for the time_zones.txt file 2023-06-30 22:35:58 +08:00
Théo LUDWIG 076db4c3eb fix(skill/date_time): determine correctly isDaylightSavingTime 2023-06-30 15:11:17 +02:00
Théo LUDWIG 02e1de8ffa fix: precise units used in time zone data 2023-06-29 23:14:14 +02:00
Théo LUDWIG cc01bd18b2 feat(skill/date_time): time zone 2023-06-29 23:03:03 +02:00
Théo LUDWIG 2478adbaa2 feat(server): add spacy data in entity resolution 2023-06-29 22:33:25 +02:00
Théo LUDWIG 45b177d0fb feat(tcp server): add support for time zone and more city/country data 2023-06-29 22:32:12 +02:00
Théo LUDWIG c0deafcd69 feat(server): improve NER types 2023-06-29 00:04:37 +02:00
louistiti eea6b0392d feat(skill/date_time): add new utterance samples 2023-06-29 00:17:29 +08:00
louistiti 9845612c68 Merge branch 'feat/skill-utilities-date-time' into develop 2023-06-28 23:39:25 +08:00
louistiti d46ec1d3d5 Merge branch 'feat/skill-leon-age' into develop 2023-06-28 23:39:15 +08:00
louistiti f1a65f53bc feat(skill/age): add new utterance samples 2023-06-28 23:39:07 +08:00
Théo LUDWIG 1410b72362 chore(skill/date_time): add test folder 2023-06-27 18:35:03 +02:00
Théo LUDWIG e9245b522f fix(skill/date_time): separate current date and current time 2023-06-25 22:46:10 +02:00
Théo LUDWIG 636eb0f139 feat(skill/date_time): days countdown 2023-06-25 12:27:30 +02:00
Théo LUDWIG 8645ef01fd fix: improve types for Node.js skill SDK 2023-06-25 12:08:36 +02:00
Théo LUDWIG 18867bde89 fix(server): improve json schema description for skill config 2023-06-25 12:07:41 +02:00
Théo LUDWIG d061a6c4bf feat(skill/date_time): get current week number of the year 2023-06-24 19:57:47 +02:00
Théo LUDWIG e2ec76275a feat(skill/date_time): get current date and time 2023-06-24 19:30:55 +02:00
Théo LUDWIG 767bace201 feat(skill/age): ask Leon his age 2023-06-24 13:23:19 +02:00
louistiti e70d0a0029 feat(web app): add init messages 2023-05-30 23:52:35 +08:00
louistiti 595fe78679 Merge branch 'python-sdk' into develop 2023-05-29 22:55:36 +08:00
louistiti 69cb6a610f build(bridge/nodejs): bump to 1.0.0 2023-05-29 22:01:32 +08:00
louistiti 10a03d90e3 build(bridge/python): bump to 1.1.0 2023-05-29 22:01:06 +08:00
louistiti 251950384e refactor(server): rename obj to skillAnswer 2023-05-28 12:53:44 +08:00
louistiti 8c91d245e8 refactor(server): remove speech prop from skill output backward compatibility 2023-05-28 12:49:56 +08:00
louistiti df343ce94f fix(skill/akinator): typo ShowNextActionSuggestions to showNextActionSuggestions 2023-05-28 10:12:40 +08:00
louistiti 7c73f435af fix(skill/akinator): disable urllib3 cert warning 2023-05-28 10:07:23 +08:00
louistiti b5ef7242af fix(skill/have_i_been_pwned): use current_entities instead of entities 2023-05-28 09:23:50 +08:00
Divlo 16e1f7a34a chore: remove dead code 2023-05-28 01:32:57 +02:00
Divlo e42a54d593 refactor(skill/akinator): usage of new SDK 2023-05-28 01:10:03 +02:00
Divlo cd3bcd5d6e refactor(server): leon over http with /api/utterance 2023-05-28 00:31:40 +02:00
Divlo 2ea6237b1f chore: remove /api/downloads 2023-05-27 23:53:20 +02:00
Divlo 9782526c42 chore: remove legacy Python bridge/utils 2023-05-27 23:48:39 +02:00
Divlo 3bf7150387 refactor(skill/have_i_been_pwned): usage of new SDK 2023-05-27 23:34:15 +02:00
Divlo c00c85fd4f fix(bridge): better types and network error 2023-05-27 20:29:01 +02:00
Divlo a76d05f68a refactor(skill/product_hunt_trends): usage of new SDK 2023-05-27 20:21:03 +02:00
Divlo f17a4d3a2a refactor(skill/github_trends): usage of new SDK 2023-05-27 18:06:31 +02:00
Divlo 850ea46ec6 style(skill/mbti): add missing space for consistency (oops) 2023-05-27 12:54:16 +02:00
Divlo a540307241 refactor(skill/mbti): usage of new SDK 2023-05-27 12:43:19 +02:00
Divlo e440e4f715 refactor(skill/speed_test): usage of new SDK 2023-05-27 12:00:13 +02:00
louistiti d1fe81ddc6 refactor: modify settings method from isAlreadySet to isSettingSet 2023-05-27 09:47:09 +08:00
louistiti 3648fef5fb refactor(bridge/python): add key to settings.isAlreadySet 2023-05-27 09:00:00 +08:00
louistiti 1f9137bb20 refactor(bridge/nodejs): add key to setting.isAlreadySet 2023-05-27 08:47:24 +08:00
louistiti 2e6abef507 chore: lint 2023-05-27 08:06:11 +08:00
louistiti a55fbcd532 fix: ignore error if skill.json isn't found when getting skill info 2023-05-27 08:05:22 +08:00
Divlo 924317c614 refactor(skill/is_it_down): usage of new SDK 2023-05-27 00:14:51 +02:00
Divlo 0c44916aa2 chore(bridge): add comments (jsdoc/docstring) for settings 2023-05-26 23:50:36 +02:00
Divlo 2a0cc0644e chore: remove youtube_downloader skill 2023-05-26 23:34:37 +02:00
Divlo 4f5b385fd7 chore: rename config.json to settings.json 2023-05-26 23:31:25 +02:00
Divlo 30e405bbe3 feat(bridge/python): add Settings module 2023-05-26 23:03:02 +02:00
Divlo 8c105a043d feat(bridge/nodejs): add Settings module 2023-05-26 23:01:54 +02:00
Divlo 99b5e7ab6d chore: remove synchronization capability 2023-05-26 22:58:26 +02:00
Divlo b9dbc5012c Revert "chore: add __init__.py files to avoid mypy linting error"
This reverts commit 0b16eebfbd.
2023-05-26 10:12:43 +02:00
Divlo 0b16eebfbd chore: add __init__.py files to avoid mypy linting error
Ref: https://github.com/python/mypy/issues/8686#issuecomment-1178977365
2023-05-25 22:56:38 +02:00
Divlo c078505846 refactor(skill/todo_list): usage of new SDK 2023-05-25 22:47:58 +02:00
Divlo 421232a6dc refactor(skills): usage of datetime ISO 8601 string format instead of timestamp 2023-05-25 19:05:51 +02:00
louistiti c62368ddad chore: comments and French punctuation 2023-05-25 08:34:20 +08:00
Divlo f956e1abc6 fix(bridge): memory path always defined 2023-05-25 01:04:28 +02:00
Divlo dc88ac244d perf(skill/guess_the_number): only store one game at a time to avoid increasing the size of memory unnecessarily 2023-05-25 00:38:34 +02:00
Divlo 4cd01a4baf refactor(skill/random_number): usage of new SDK 2023-05-25 00:12:59 +02:00
Divlo 06cda4a1f0 fix(bridge/nodejs): allow memory that stores null value 2023-05-25 00:04:25 +02:00
Divlo dc7615723d fix(bridge/python): allow memory that stores null value 2023-05-24 23:57:44 +02:00
Divlo 14275be5f7 refactor(skill/introduction): usage of new SDK 2023-05-24 23:57:18 +02:00
Divlo 158df2f0f1 refactor(skill/greeting): usage of new SDK 2023-05-24 23:57:05 +02:00
Divlo 6bed516f89 refactor(skill/rochambeau): usage of new SDK 2023-05-24 23:22:43 +02:00
Divlo 7e72928ad6 refactor(skill/guess_the_number): usage of new SDK 2023-05-24 23:10:14 +02:00
louistiti 4a7e77141e refactor: remove Python shebangs 2023-05-24 20:32:43 +08:00
louistiti 25ab60e5a2 feat: add Leon user agent from bridges 2023-05-24 19:53:34 +08:00
Divlo f8e6012cbe fix(bridge/python): add types 2023-05-23 19:50:19 +02:00
louistiti 1c5d2874b0 refactor(bridge/python): add memory comments 2023-05-23 21:37:12 +08:00
louistiti 3449c14d47 feat(bridge/python): functional memory 2023-05-23 21:27:35 +08:00
louistiti 51f57e3255 feat(bridge/python): memory write method 2023-05-23 20:10:48 +08:00
louistiti 7fd4be1248 feat(bridge/python): memory read method 2023-05-23 20:09:09 +08:00
louistiti 3b77d64d4f feat(bridge/python): memory clear method 2023-05-23 20:06:35 +08:00
louistiti ab7e2a9b10 refactor(bridge/nodejs): remove Aurora index file 2023-05-22 22:54:00 +08:00
louistiti b2e4ebf1be feat(bridge/python): support widget answer 2023-05-22 22:17:53 +08:00
louistiti 3c9a210081 feat(bridge/python): leon.answer usage 2023-05-22 21:14:52 +08:00
louistiti 7a9068283b refactor(bridge/python): new bridge main file 2023-05-22 20:32:36 +08:00
louistiti 66dc0aab0f feat(skill/timekeeper): boilerplate 2023-05-22 20:18:13 +08:00
Divlo 91e48af263 feat(bridge/python): add Network module (WIP) 2023-05-21 23:20:58 +02:00
louistiti 3a230633d8 feat(bridge/python): memory kick off 2023-05-21 19:12:30 +08:00
louistiti 6c3a03d16a feat(bridge/python): add widget class 2023-05-21 19:03:54 +08:00
louistiti 8a60b3d0d3 Merge branch 'python-sdk-fixes' into python-sdk 2023-05-21 18:51:42 +08:00
Divlo cb3d3bf5a8 fix(bridge/nodejs): add lang to action params 2023-05-20 20:34:12 +02:00
Divlo f3257ad7b0 style(bridge/python): format with autopep8 2023-05-20 20:33:37 +02:00
Divlo cb29848f45 fix(bridge/python): better typings 2023-05-20 19:49:56 +02:00
Divlo ebaa3c4f9b fix(bridge/python): inconsistent indentation TabError 2023-05-20 19:49:07 +02:00
louistiti de17719537 feat(bridge/python): typing (WIP) 2023-05-20 23:28:44 +08:00
louistiti 47d5a48ac9 fix(bridge/python): import INTENT_OBJECT to leon 2023-05-20 23:17:42 +08:00
louistiti e8ceed62eb feat(bridge/python): leon.answer 2023-05-20 23:16:50 +08:00
louistiti bbc1f8a79c feat(bridge/python): leon.set_answer_data 2023-05-20 23:09:45 +08:00
louistiti 289efb5610 feat(bridge/python): leon.get_src_config 2023-05-20 22:49:17 +08:00
louistiti 05a4b2c773 feat(bridge/python): Leon singleton 2023-05-20 22:42:30 +08:00
louistiti a32ad86342 feat(bridge/python): add constants 2023-05-20 22:40:38 +08:00
louistiti a2eacc3930 fix(server): add lang back to the intent object till Python bridge is updated 2023-05-19 22:09:01 +08:00
louistiti a8c079fd5c feat: provide built-in context data to skills 2023-05-19 21:47:23 +08:00
louistiti b389bdd8c6 feat(server): provide sentiment analysis to NLU result 2023-05-19 21:40:24 +08:00
louistiti 750d1de8b4 chore: merge branch 'skill-text-n-speech-difference' into develop 2023-05-18 21:14:09 +08:00
louistiti d295105fa6 chore: disable import/order ESLint rule for skills 2023-05-18 21:06:04 +08:00
louistiti e2899c8d9a refactor(skill/good_bye): rollback as speech/text answer is only supported in logic skills 2023-05-18 20:38:26 +08:00
louistiti 7f9b60a6cd feat(server): differentiate skill text answer from speech answer (WIP) 2023-05-18 00:00:40 +08:00
louistiti 9e77953976 refactor(bridge/nodejs): use AnswerConfig type from core schema 2023-05-17 22:21:11 +08:00
louistiti cb6462b749 feat: define new skill answer format 2023-05-17 18:31:39 +08:00
Louis Grenard 07a3b1701d docs: update README.md 2023-05-16 23:14:02 +08:00
Louis Grenard f6300a3fb8 docs: update README.md 2023-05-16 23:14:02 +08:00
louistiti 46299ef4eb Merge branch 'skill-widget-ideas' into develop 2023-05-16 23:08:00 +08:00
louistiti 259dc53213 Merge branch 'skill-widget-ideas' into develop 2023-05-16 23:08:00 +08:00
louistiti 51152a0fe3 refactor(bridge/nodejs): protected memory constructor 2023-05-16 23:07:12 +08:00
louistiti 01305af669 refactor(bridge/nodejs): protected memory constructor 2023-05-16 23:07:12 +08:00
Divlo 5539130dd9 fix: typo missing "GB" for Free RAM 2023-05-15 23:42:27 +02:00
Divlo efd1061f30 fix: typo missing "GB" for Free RAM 2023-05-15 23:42:27 +02:00
Divlo f6a501d4e1 fix(bridge/nodejs): improve Memory types with external skill memory 2023-05-15 22:58:40 +02:00
Divlo 839c7bfc3c fix(bridge/nodejs): improve Memory types with external skill memory 2023-05-15 22:58:40 +02:00
Divlo d3ba85cb36 feat(bridge/nodejs): add Widget abstract class 2023-05-15 21:18:54 +02:00
Divlo 623039415a feat(bridge/nodejs): add Widget abstract class 2023-05-15 21:18:54 +02:00
louistiti 7a75c985e0 Merge branch 'skill-widget-poc' into develop 2023-05-15 21:31:02 +08:00
louistiti 0f2a579a66 refactor(web app): remove original app rendering 2023-05-15 21:30:42 +08:00
louistiti 63573083fa feat(web app): render widget 2023-05-15 21:25:20 +08:00
louistiti 34aa188643 feat: skill -> core -> client widget support 2023-05-15 01:13:18 +08:00
louistiti 76dfe72f5f feat(web app): kick off Aurora structure 2023-05-15 00:00:21 +08:00
louistiti 7a31158497 feat(web app): set up React 2023-05-14 23:43:42 +08:00
louistiti 96145bb2f7 feat(web app): add vite React plugin 2023-05-14 23:23:17 +08:00
louistiti 17cb808aab chore: install required npm deps 2023-05-14 23:22:01 +08:00
louistiti b757d2d4ae chore: upgrade vite to latest 2023-05-14 23:20:41 +08:00
louistiti ce001c2e65 feat(bridge/nodejs): support read memory from other skills 2023-05-14 21:00:52 +08:00
louistiti a3b8c40714 refactor(scripts): unify skills setup over one iteration only 2023-05-14 12:10:55 +08:00
louistiti 0283878a90 refactor(bridge/nodejs): force run to be the skill action entry point 2023-05-14 09:15:05 +08:00
louistiti 3ed19bd6d0 Merge branch 'nodejs-bridge-memory' into develop 2023-05-14 08:58:28 +08:00
louistiti c163f5971c feat(bridge/nodejs): sync return new memory value on write 2023-05-14 08:58:19 +08:00
louistiti 6a01e1e743 Merge branch 'nodejs-bridge-improvements' into nodejs-bridge-memory 2023-05-14 08:52:03 +08:00
louistiti b06eab9107 style(bridge/nodejs): memory exception/error renaming 2023-05-14 08:51:52 +08:00
Divlo 12ce47b937 fix(bridge/nodejs): usage of getleon.ai to try network available 2023-05-14 00:39:56 +02:00
Divlo c8fc0068d1 feat(bridge/nodejs): improvements to memory 2023-05-14 00:39:30 +02:00
louistiti e32bf370db Merge branch 'nodejs-bridge-memory' into develop 2023-05-14 00:11:10 +08:00
louistiti 9ef4f234b8 Merge branch 'develop' into nodejs-bridge-memory 2023-05-14 00:08:18 +08:00
louistiti 6d2292f508 fix(server): pre-check add process.cwd() to all constant paths 2023-05-14 00:06:43 +08:00
louistiti b897ae160f feat(bridge/nodejs): simple get / set memory 2023-05-13 23:52:54 +08:00
louistiti a51d92bf08 refactor(bridge/nodejs): remove Prisma 2023-05-13 19:04:54 +08:00
louistiti 6d495cf43c refactor(scripts): explicit Node.js bridge npm packages install 2023-05-13 00:30:15 +08:00
louistiti d6933a9e35 refactor(bridge/nodejs): remove lowdb and tiny custom ORM in favor of Prisma 2023-05-13 00:26:51 +08:00
louistiti 127a10f8ed feat(scripts): install Node.js bridge npm packages on setup 2023-05-12 23:54:57 +08:00
louistiti ef223a2901 feat(bridge/nodejs): make use of Prisma from skill action (PoC) 2023-05-11 23:39:17 +08:00
louistiti 9a06c64a5d feat(bridge/nodejs): Prisma SQLite setup 2023-05-11 23:26:42 +08:00
louistiti ad5edb5ad5 feat(bridge/nodejs): support nested props find in memory 2023-05-11 22:30:22 +08:00
louistiti ee0b080522 feat(bridge/nodejs): support updateOne memory method 2023-05-11 21:50:29 +08:00
louistiti be04b10645 feat(bridge/nodejs): support findMany memory method 2023-05-11 21:41:51 +08:00
louistiti ab62a65e57 feat(bridge/nodejs): support findOne memory method 2023-05-11 21:40:22 +08:00
louistiti 99ac5f18c8 feat(bridge/nodejs): give public access to Low instance 2023-05-11 21:21:26 +08:00
louistiti 87a7077854 refactor(bridge/nodejs): rename create with createOne 2023-05-11 21:04:18 +08:00
louistiti af2a124165 refactor(bridge/nodejs): rename insert to create 2023-05-11 20:59:26 +08:00
louistiti 8e55c481d4 feat(bridge/nodejs): support insertMany memory method 2023-05-11 20:51:19 +08:00
louistiti d7b814761f feat(bridge/nodejs): tiny ORM kick off 2023-05-11 20:49:40 +08:00
louistiti 4dde49e545 feat(bridge/nodejs): memory database pattern (WIP) 2023-05-10 23:29:41 +08:00
Divlo 34b29d0e61 fix(bridge/nodejs): memory ESM dynamic imports 2023-05-10 00:45:21 +02:00
louistiti 954126315f refactor(bridge/nodejs): TSConfig ESM NCC 2023-05-09 21:48:07 +08:00
louistiti e240a2db3c feat(bridge/nodejs): memory ESM debugging (WIP) 2023-05-09 21:39:18 +08:00
louistiti 4abb68c1b3 Merge branch 'nodejs-bridge' into develop 2023-05-08 22:05:42 +08:00
louistiti 3ea1a3666b feat(bridge/nodejs): add isNetworkAvailable network method 2023-05-08 22:03:30 +08:00
louistiti d3e0810298 fix(bridge/nodejs): temporize data buffer on output 2023-05-08 22:01:46 +08:00
louistiti ef6d46cf8e refactor(scripts): remove cmd output on install Node.js skills packages 2023-05-08 21:57:41 +08:00
louistiti e65ecd5b67 fix(scripts): install Node.js skills packages timestamp comparison 2023-05-08 21:45:06 +08:00
louistiti 5946a00427 feat(scripts): skill package install/uninstall package script 2023-05-08 21:35:14 +08:00
louistiti 6b239ae38b style(scripts): fix linting 2023-05-08 21:24:26 +08:00
louistiti 224158812f feat(scripts): install Node.js skills packages 2023-05-08 21:23:33 +08:00
Divlo ee9794cd9f Revert "feat(bridge/nodejs): add leon.getVersions"
This reverts commit ec819e1765.
2023-05-08 10:58:31 +02:00
Divlo ad497d36c3 style: fix linting 2023-05-07 21:44:55 +02:00
Divlo 5eb62ddcf5 chore: add leon-nodejs-bridge as local dependency 2023-05-07 21:43:03 +02:00
Divlo ec819e1765 feat(bridge/nodejs): add leon.getVersions 2023-05-07 21:38:09 +02:00
louistiti 2c2f49290a Merge branch 'nodejs-bridge' into develop 2023-05-07 21:28:28 +08:00
louistiti f936652007 Merge branch 'nodejs-bridge-improvements' into nodejs-bridge 2023-05-07 21:26:12 +08:00
Divlo 950985ca86 feat(bridge/nodejs): finish network implementation 2023-05-07 15:07:20 +02:00
louistiti 8147d8423b feat(scripts): add Node.js bridge on check script 2023-05-07 20:09:37 +08:00
louistiti 3f556494c2 Merge branch 'nodejs-bridge-improvements' into nodejs-bridge 2023-05-07 19:07:05 +08:00
Divlo 426c816ca4 build(bridge/nodejs): avoid installing dependencies each time we build 2023-05-07 01:14:44 +02:00
louistiti dd0eab51b6 Merge branch 'HEAD' into nodejs-bridge 2023-05-06 22:47:36 +08:00
Divlo 07e253f663 build(bridge/nodejs): usage of ncc 2023-05-06 15:38:49 +02:00
Divlo de08807f1a feat(bridge/nodejs): add Network module (WIP) 2023-05-06 14:21:24 +02:00
Divlo 2cb030f47b fix(bridge/nodejs): usage of types from server/core/brain/types 2023-05-06 14:03:56 +02:00
Divlo 673cf0426f fix(bridge/nodejs): build error 2023-05-06 13:55:43 +02:00
louistiti e89b5b0ea3 refactor(bridge/nodejs): isolate types from bridge 2023-05-06 18:26:22 +08:00
Divlo 6b76e6a102 fix(bridge/nodejs): stricter leon.getSRCConfig types 2023-05-05 20:24:01 +02:00
Divlo 1625aaf3cd fix(bridge/nodejs): typings improvements 2023-05-05 20:00:51 +02:00
louistiti b65cfb70d6 feat(bridge/nodejs): final answer bridge 2023-05-05 21:21:27 +08:00
louistiti 89a6c04a1e refactor(bridge/nodejs): new answer types (WIP) 2023-05-05 00:34:16 +08:00
louistiti e42655a5ff refactor(server): remove skill answer type complexity 2023-05-04 22:34:29 +08:00
louistiti c9678fe34f refactor(bridge/python): flush standard output every time 2023-05-04 21:40:11 +08:00
louistiti 8349e41205 feat(bridge/nodejs): answers 2023-05-03 23:28:12 +08:00
louistiti 759e67ac40 fix(bridge/nodejs): SDK mapping 2023-05-03 16:02:57 +08:00
louistiti fc1fa56eab Merge branch 'develop' into nodejs-bridge 2023-05-03 14:54:51 +08:00
louistiti 8f5bd3a9a5 feat: add free RAM check 2023-05-03 14:54:23 +08:00
louistiti a836a7cc8c feat(bridge/nodejs): resolve SDK mapping 2023-05-03 09:27:23 +08:00
louistiti 2df22770e0 refactor(bridge/nodejs): SDK mapping 2023-05-03 08:39:06 +08:00
louistiti 9b839d3e66 feat(bridge/nodejs): first draft 2023-05-02 23:53:41 +08:00
louistiti 2e3796642d refactor(server): send heartbeat every 6 hours instead 2023-05-02 16:43:04 +08:00
louistiti b027905ed0 refactor(bridge/nodejs): package.json new dist entry point path 2023-05-01 23:01:46 +08:00
louistiti 4c9dfe667b build(bridge/nodejs): bump 0.0.1-alpha.0 2023-05-01 22:49:32 +08:00
louistiti ed215feb81 refactor(scripts): Node.js bridge bin dist 2023-05-01 22:48:31 +08:00
louistiti cd82a3a11b chore: bump to 1.0.0-beta.9+dev 2023-05-01 10:23:19 +08:00
louistiti b7a4f69565 build: release 1.0.0-beta.8 2023-05-01 10:09:29 +08:00
louistiti 7b8a324658 fix(server): catch error on start for telemetry client 2023-05-01 01:54:19 +08:00
louistiti 59cfded2bb feat(server): send Node.js bridge version to telemetry 2023-05-01 01:26:28 +08:00
louistiti 8dc8c05d7d refactor(scripts): add bin level for Node.js bridge 2023-05-01 01:13:19 +08:00
louistiti 0e4ec4fb97 refactor(scripts): exclude current Node.js bridge archive from new archive 2023-05-01 00:49:35 +08:00
louistiti bb00677568 feat(scripts): add build for Node.js bridge 2023-05-01 00:36:03 +08:00
louistiti 308b63f576 fix(scripts): tmp setup Node.js bridge removal 2023-04-30 23:49:21 +08:00
louistiti 40819e8e17 feat(bridge/nodejs): release process 2023-04-30 23:39:39 +08:00
louistiti 0fba50905f feat(bridge/nodejs): entry point build 2023-04-30 21:36:07 +08:00
louistiti 419bfe3d78 refactor(scripts): commit-msg scopes 2023-04-30 20:35:56 +08:00
louistiti 1847248f12 feat: add instanceID on check script 2023-04-30 10:45:51 +08:00
louistiti eed4a9597c refactor(server): get Node.js version from process.versions.node 2023-04-30 10:32:01 +08:00
louistiti c3452d2170 feat(server): add minimum RAM requirement on pre-check 2023-04-30 10:31:18 +08:00
louistiti 0a14567776 refactor: round up total RAM on check script 2023-04-30 10:13:41 +08:00
louistiti 71573b78d1 refactor: instance ID log on postinstall 2023-04-29 21:04:29 +08:00
louistiti 722dba875b feat: do not download binaries if the latest version is already installed 2023-04-29 20:58:10 +08:00
louistiti 593419639e refactor: naming 2023-04-27 20:24:16 +08:00
louistiti 8b2f06e305 feat(server): bootstrap Node.js bridge entry point 2023-04-27 20:16:08 +08:00
louistiti 12e4b7bccf ci: use ubuntu-20.04 for the draft-release job 2023-04-26 23:00:01 +08:00
louistiti 63a6c2d161 ci: force ubuntu-20.04 and npm install as there is no package-lock.json anymore 2023-04-26 22:49:54 +08:00
louistiti f0e898e3c0 ci: remove npm caching 2023-04-26 22:45:34 +08:00
louistiti 10bb4af4dc build: bump Python bridge to 1.0.1 2023-04-26 22:35:48 +08:00
louistiti 1af3fc2011 style: better info message on prompt false for pre release binaries 2023-04-26 22:34:47 +08:00
louistiti 781cb072a3 fix: use version.py to prompt version bump confirmation on pre-release binaries 2023-04-26 22:33:10 +08:00
louistiti 73fe21f02e Merge branch 'fix-python-bridge-requests-certs' into develop 2023-04-26 22:24:44 +08:00
louistiti 0947bd7877 fix(server): close error log file handler 2023-04-26 21:31:12 +08:00
Divlo 07d2a41ecb fix(python bridge): include requests.certs file 2023-04-23 22:32:43 +02:00
louistiti 9a66b677e0 feat(server): sanitize current OS profile session name on telemetry error 2023-04-23 22:14:06 +08:00
louistiti fe580cfb92 feat: sanitize current OS profile session name for better privacy 2023-04-23 22:12:19 +08:00
louistiti 075f4458a0 feat(server): support isGitpod telemetry 2023-04-22 23:51:08 +08:00
louistiti 094b1218e6 refactor(server): replace HAS_LOGGER by IS_TELEMETRY_ENABLED for the Telemetry service 2023-04-18 20:09:42 +08:00
louistiti b16475766a fix(server): create errors.log if it does not exist before parsing logs 2023-04-18 09:21:05 +08:00
louistiti e5fdeba50b fix(server): ensure the errors.log file exist before reporting errors 2023-04-18 09:05:35 +08:00
louistiti 12b0fe6525 Merge branch 'telemetry' into develop 2023-04-16 16:46:58 +08:00
louistiti 302e1e11e0 feat(server): switch telemetry to production mode 2023-04-16 16:46:51 +08:00
louistiti 8d5bca0d2b refactor(server): handle telemetry on NLU edge cases 2023-04-16 15:36:59 +08:00
louistiti 994cca7bf4 refactor: do not call any core singletons during setup 2023-04-15 00:32:28 +08:00
louistiti a03afa78be refactor(server): telemetry utterance less parameters 2023-04-13 22:44:28 +08:00
louistiti a1f93a6922 fix(server): await for logical skill execution 2023-04-13 22:20:06 +08:00
louistiti 2678f6f04a feat(server): add isProduction data to telemetry 2023-04-13 00:41:02 +08:00
louistiti 03acb35e84 feat(server): complete telemetry client 2023-04-13 00:11:23 +08:00
louistiti 337854ab02 feat: kick off telemetry client 2023-04-12 00:25:40 +08:00
louistiti 19c569b76a Merge branch 'develop' into telemetry 2023-04-11 22:39:50 +08:00
louistiti 5b4cd9da81 Merge branch 'feat/better-json-schemas-developer-experience' into develop 2023-04-11 20:20:07 +08:00
louistiti 40069ab5f0 feat(server): kick off telemetry 2023-04-10 22:35:37 +08:00
Divlo 8c89cbf43c Merge branch 'develop' into feat/better-json-schemas-developer-experience 2023-04-05 00:13:34 +02:00
louistiti 5061cac591 Merge branch 'http-server-refactoring' into develop 2023-04-04 23:09:49 +08:00
louistiti f660506d98 chore(server): add TODO for HTTP API skills routes 2023-04-04 23:08:54 +08:00
louistiti 25f81d3c3c Merge branch 'refactor/fastify-api' into http-server-refactoring 2023-04-04 23:03:03 +08:00
Divlo d261967920 refactor(server): http-server with over http enabled 2023-04-03 20:58:02 +02:00
Divlo 907fb1a129 Merge branch 'http-server-refactoring' into refactor/fastify-api 2023-04-03 19:19:21 +02:00
Divlo 7d63108e8d fix(server): async hooks http-server 2023-04-03 19:12:54 +02:00
louistiti 274d7d52fd refactor(server): remove legacy server/src/tts/tts.js 2023-04-03 23:26:52 +08:00
louistiti d815ab8bff refactor(server): socket server interfaces 2023-04-03 23:24:54 +08:00
louistiti 35da3a388a refactor(server): socket server typing 2023-04-03 23:22:07 +08:00
Divlo a29296c612 refactor(server): api and plugins for http-server 2023-04-03 17:20:00 +02:00
louistiti b93180a822 fix(server): ASR not getting ready 2023-04-03 23:04:18 +08:00
louistiti 9fa0c2e1ba chore: re-enable linter on commit 2023-04-03 22:29:21 +08:00
louistiti 2115054de6 Merge branch 'refactor/fs-promises' into http-server-refactoring 2023-04-03 21:59:20 +08:00
louistiti f167f64cfb fix: simultaneous skills execution; Akinator new step 0 2023-04-03 21:55:36 +08:00
Divlo abc6b21df2 fix: make cleanActiveContext synchronous 2023-04-03 08:33:45 +02:00
Divlo bd66bb5cb7 refactor: usage of fs.promises 2023-04-02 20:34:50 +02:00
Divlo c49f931da4 style: fix linting 2023-04-02 19:18:15 +02:00
louistiti 070f0e1469 refactor(server): change HTTP server props accessiblity 2023-04-02 19:11:37 +08:00
louistiti bf4806c987 refactor(server): finish NLU typing 2023-04-02 18:42:00 +08:00
louistiti 37e5ca0e87 refactor(server): simpler error handler from the NLU action execution 2023-04-02 18:04:25 +08:00
louistiti a6011e3cc6 refactor(server): NLP.js process raw type 2023-04-02 18:00:10 +08:00
louistiti 44882129a7 refactor(server): NLU default values 2023-04-02 16:56:53 +08:00
louistiti 8282c37a5a refactor(server): slot filling 2023-03-27 22:23:10 +08:00
louistiti 26ff4520c8 refactor(server): action loop 2023-03-27 22:09:32 +08:00
louistiti e2f0df2cb6 refactor(server): unify join path 2023-03-27 21:51:40 +08:00
louistiti 7259ceda59 refactor(server): unify skill config getter 2023-03-27 21:42:33 +08:00
louistiti 7f99372130 Merge branch 'develop' into http-server-refactoring 2023-03-26 18:52:19 +08:00
Louis Grenard 0cbd438a34 docs: question LLMs to large language models 2023-03-26 10:23:11 +08:00
Louis Grenard 71b30a7f97 docs: add current state to the README 2023-03-26 10:21:22 +08:00
louistiti bfdc60fa65 refactor(server): slot filling 2023-03-22 23:54:58 +08:00
louistiti 99af936803 refactor(server): action loop 2023-03-22 23:34:39 +08:00
louistiti d41e960373 refactor(server): brain types 2023-03-22 22:31:42 +08:00
louistiti ae04ba369c refactor(server): NLP conversation 2023-03-22 22:19:29 +08:00
louistiti afff309d43 refactor(server): skillConfigPath naming unification 2023-03-22 22:08:35 +08:00
louistiti 16c25c9036 chore: upgrade async to latest 2023-03-20 23:46:27 +08:00
louistiti cd551197ea chore: upgrade Fastify to latest 2023-03-20 23:37:55 +08:00
louistiti f6077d58f1 chore: upgrade to TypeScript 5+ 2023-03-20 23:35:07 +08:00
louistiti eb026cb74a refactor(server): move some NER methods from NLU to NER 2023-03-20 23:15:26 +08:00
louistiti 7d6698df17 refactor(server): NLU method accessibility 2023-03-20 22:45:11 +08:00
louistiti a215fc8770 refactor(server): default NLU result 2023-03-20 22:35:44 +08:00
louistiti a8e3fb8b87 refactor(server): NER 2023-03-20 22:04:04 +08:00
louistiti 6820501da6 refactor(server): remove JavaScript NER and NLU 2023-03-20 21:22:33 +08:00
louistiti b51bf4b1c2 refactor(server): model loader error handling 2023-03-20 20:52:42 +08:00
louistiti 5369da1734 refactor(server): models loader 2023-03-18 10:47:44 +08:00
louistiti d5d8d56124 refactor(server): brain done 2023-03-15 22:30:22 +08:00
louistiti fbcc089e2b refactor(server): brain options 2023-03-07 23:22:35 +08:00
louistiti 76dacb4f5e refactor(server): brain logic action skill execution 2023-03-07 22:20:40 +08:00
louistiti 24ec0f0927 refactor(server): start brain refactoring 2023-03-05 23:07:34 +08:00
louistiti b8aac89c4d refactor(server): brain NLU result renaming 2023-03-04 06:48:04 +08:00
louistiti 72a4f787a3 refactor(server): brain typing done 2023-02-25 09:32:11 +08:00
louistiti 137032b1c0 refactor(server): fix brain answers types 2023-02-25 08:46:23 +08:00
louistiti 5011d906e7 chore: more comment and remove socket server legacy comments 2023-02-21 00:15:42 +08:00
louistiti 35d171e421 chore: comment for what to do next 2023-02-21 00:11:32 +08:00
louistiti 20e7a98241 refactor(server): continue brain typing 2023-02-21 00:00:14 +08:00
louistiti abf811f2e4 refactor(server): handle skill result in brain 2023-02-20 22:58:15 +08:00
louistiti 4d7c49e1ee refactor(server): load models and init core instances only once 2023-02-20 21:56:22 +08:00
louistiti e182da0048 refactor(server): remove unecessary socket connections 2023-02-20 20:26:38 +08:00
louistiti f81255aa20 refactor(server): better STT/TTS logs 2023-02-20 20:31:42 +08:00
louistiti 7aaca4dfc8 refactor(server): only keep types file at the first-node level 2023-02-20 00:30:17 +08:00
louistiti 4a74ee030a refactor(server): BrainProcessResult action; nextAction type to skill config schema action [string] 2023-02-20 00:09:38 +08:00
louistiti 7c76e538ab refactor(server): define BrainProcessResult and refactor schema types naming 2023-02-20 00:07:42 +08:00
louistiti 87ed70d313 refactor(server): define NLUSlot 2023-02-19 23:15:34 +08:00
louistiti 98bb70bee6 refactor(server): define SkillOutputType 2023-02-19 20:56:35 +08:00
louistiti a77f0e2473 refactor(server): implement all NER entity types 2023-02-19 20:48:48 +08:00
louistiti 03b128a544 chore: new ESLint rules for TypeScript 2023-02-19 00:02:15 +08:00
louistiti 9c6a60f92c refactor(server): set SkillConfig actions type in brain 2023-02-18 23:49:10 +08:00
louistiti 311923255e fix(server): fail when first execute a dialog action 2023-02-18 19:51:56 +08:00
louistiti cb77b4fc95 refactor(server): get correct audio duration from TTS 2023-02-18 19:16:26 +08:00
louistiti 4883d7723b refactor(server): synthesizers and parsers debug (tmp) 2023-02-13 23:57:29 +08:00
louistiti eb72a61bad refactor(server): brain tmp 2023-02-12 23:21:19 +08:00
louistiti 6dfeb6480f chore: add save-exact npm option to install exact packages version 2023-02-11 19:35:15 +08:00
louistiti 51f9a29679 chore: lock all deps 2023-02-11 11:36:08 +08:00
louistiti d51bf36566 refactor(server): NLU and brain kick off (tmp) 2023-02-10 22:18:56 +08:00
louistiti 9c9f944350 refactor(server): switch from brain instance within NLU to singleton brain 2023-02-09 21:15:49 +08:00
louistiti 7b557da549 refactor(server): NLP.js TS declarations + NLU kick off 2023-02-09 21:01:33 +08:00
louistiti 849749b900 refactor(server): add lang to TTS init 2023-02-07 22:41:02 +08:00
louistiti 528da32d03 refactor(server): STT parser abstract class 2023-02-07 22:36:59 +08:00
louistiti 9ef7476267 refactor(server): Watson synthesizer + synthesizer abstract class 2023-02-07 22:21:42 +08:00
louistiti 0f897942fa refactor(server): remove already-refactored synthesizers 2023-02-07 21:55:14 +08:00
louistiti 885f3738fc refactor(server): TTS Google Cloud synthesizer 2023-02-07 21:35:27 +08:00
louistiti ab0d88accf refactor(server): add STT parser parent class 2023-02-07 21:30:47 +08:00
louistiti 1146322196 refactor(server): TTS Flite synthesizer + synthesizer parent class 2023-02-07 21:26:14 +08:00
louistiti 157e28a063 Merge remote-tracking branch 'origin/develop' into http-server-refactoring 2023-02-03 00:18:56 +08:00
louistiti c8bc9ecbb0 refactor(server): HTTP server; brain entries; STT parsers; TTS synthesizers (WIP) 2023-02-03 00:14:23 +08:00
Louis Grenard 18ba094647 docs: add sponsor to README.md 2023-01-31 23:22:31 +08:00
Divlo 31e44cde37 fix(server): improve schemas by adding descriptions 2023-01-06 22:20:55 +01:00
Divlo 248dbb84f0 chore: add $schema property to all JSON files 2023-01-06 21:48:35 +01:00
Divlo 609fb676e4 feat(server): pre-check validate $schema property 2023-01-06 21:48:14 +01:00
Divlo 5d866664b2 fix(server): remove additionalProperties in schemas to allow $schema property 2023-01-06 21:18:27 +01:00
Divlo ba09ef10b1 feat: add generate:json-schemas script 2023-01-06 21:18:19 +01:00
louistiti 19ce6eb9c2 refactor(server): socket server and brain (WIP) 2022-11-20 23:21:06 +08:00
louistiti 934689ecf7 chore: merge branch 'develop' into http-server-refactoring 2022-11-19 21:15:35 +08:00
louistiti 2f56a14d68 chore: delete package-lock.json file due to @ffmpeg-installer/ffmpeg optionalDependencies binaries 2022-11-19 21:14:36 +08:00
louistiti cc05ce3d76 chore: format pre-check 2022-11-19 21:13:00 +08:00
louistiti 5959b43e0a chore: upgrade TypeScript to latest 2022-11-19 21:12:43 +08:00
louistiti b9a6ee08fe refactor(server): split socket server (WIP) 2022-11-19 20:57:45 +08:00
louistiti b1739bbe6b Merge branch 'develop' into http-server-refactoring 2022-11-14 23:57:41 +08:00
louistiti cad6d7f725 Merge branch 'feat/add-typebox-ajv' into develop 2022-11-14 23:56:08 +08:00
louistiti a08ddb2e26 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-14 23:56:03 +08:00
louistiti c7aa84f9c4 docs: remove sponsor 2022-11-14 23:50:58 +08:00
louistiti ec10030951 refactor: modify voice config samples default values 2022-11-14 23:49:44 +08:00
louistiti b298667e3d Merge branch 'docs/fix-contributing-python-environment' into develop 2022-11-14 23:41:13 +08:00
louistiti 69e90c3b5f refactor(server): HTTP server and structure (wip) 2022-11-14 00:49:24 +08:00
Divlo 2ada7f2efa docs: make clear that commands should be run on Ubuntu in CONTRIBUTING to set up the Python Environment 2022-11-13 13:41:51 +01:00
Divlo 28c15885fd fix: improve error display in pre-check 2022-11-13 13:36:54 +01:00
Divlo 194a9b1bbb fix: add http_api property to skill config schema
http_api is used by `skills/news/github_trends/config/en.json`.
2022-11-13 13:08:32 +01:00
Divlo 4ce9676319 fix: include voice configuration sample schemas 2022-11-13 13:02:51 +01:00
Divlo fb75b40fb6 feat: validate JSON Schemas with AJV 2022-11-13 13:00:15 +01:00
Divlo d973ab4318 chore: delete schemas.ts files outside server 2022-11-13 12:48:43 +01:00
Divlo f8b08f38b1 fix: stricter JSON Schemas
- Type.Strict()
- Type.Object({ additionalProperties: false })
- Type.String({ format: 'email' | 'uri' })
2022-11-13 12:46:31 +01:00
louistiti b3b10e326f refactor(server): prepare upcoming core singletons registration 2022-11-13 01:12:20 +08:00
louistiti efe865a4c5 refactor(server): reorganize TCP client accessors 2022-11-13 00:40:14 +08:00
louistiti a37ac96411 refactor(server): protect TCP client from mutability 2022-11-13 00:16:53 +08:00
louistiti 8a16a3d97e refactor(server): LEON_NODE_ENV constant 2022-11-12 23:20:48 +08:00
louistiti 3d9d9496b7 fix(server): reset connection state and connection counter 2022-11-12 23:09:22 +08:00
louistiti 862112ed5f refactor(server): TCP client connect method 2022-11-12 22:51:47 +08:00
louistiti ea76739d88 refactor(server): TCP client to singleton 2022-11-12 22:31:49 +08:00
louistiti c53feba8f5 chore: latest package-lock.json 2022-11-12 10:00:22 +08:00
louistiti 62d511f967 chore: merge 2022-11-12 09:48:14 +08:00
louistiti 664359158e chore: merge 2022-11-12 09:46:50 +08:00
louistiti 8ecde83b89 refactor(server): TCP client to TypeScript 2022-11-11 23:32:33 +08:00
louistiti 420f87daca docs: add contributing guide for the Python bridge and TCP server 2022-11-11 22:54:28 +08:00
louistiti c722050aec refactor: add types to schemas object on pre-checking 2022-11-11 22:27:47 +08:00
louistiti c434b550a5 Merge branch 'feat/add-typebox-ajv' into develop 2022-11-11 21:50:55 +08:00
louistiti 06a2adf62b feat: add pre-checking for all JSON configs 2022-11-11 21:43:24 +08:00
louistiti bb0cf69659 feat: add pre-checking for all JSON configs 2022-11-11 11:43:24 +08:00
louistiti e50fadd142 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-08 20:59:25 +08:00
louistiti 327cbff184 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-08 20:59:25 +08:00
louistiti 62853a340f feat: add total RAM data to the checking script 2022-11-08 20:10:46 +08:00
louistiti 86852a8cac feat: add total RAM data to the checking script 2022-11-08 20:10:46 +08:00
louistiti efc94a2ac3 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-06 23:13:49 +08:00
louistiti fd4f429b86 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-06 23:13:49 +08:00
louistiti f5404920fa Merge branch 'develop' into feat/add-typebox-ajv 2022-11-06 23:13:49 +08:00
louistiti a0d8c7251c refactor: add full intent object path on skill execution during checking 2022-11-06 22:25:39 +08:00
louistiti 303ebea3f3 refactor: add full intent object path on skill execution during checking 2022-11-06 22:25:39 +08:00
louistiti c38012afcf refactor: add full intent object path on skill execution during checking 2022-11-06 22:25:39 +08:00
louistiti becac3b0f6 fix(server): Python bridge fails to execute on Windows intent object absolute path because of whitespace 2022-11-06 22:18:09 +08:00
louistiti 0245712e24 fix(server): Python bridge fails to execute on Windows intent object absolute path because of whitespace 2022-11-06 22:18:09 +08:00
louistiti 4b003a852e fix(server): Python bridge fails to execute on Windows intent object absolute path because of whitespace 2022-11-06 22:18:09 +08:00
louistiti ddf389ffd1 chore: add Python bridge npm script 2022-11-06 21:57:04 +08:00
louistiti 1d59b0a774 chore: add Python bridge npm script 2022-11-06 21:57:04 +08:00
louistiti 74582899a2 chore: add Python bridge npm script 2022-11-06 21:57:04 +08:00
louistiti 8a91dcb85d refactor(web app): minor style improvements 2022-11-05 23:33:15 +08:00
louistiti 8fbc4bb23f refactor(web app): minor style improvements 2022-11-05 23:33:15 +08:00
louistiti 61d31d9b52 refactor(web app): minor style improvements 2022-11-05 23:33:15 +08:00
louistiti a81e536fd5 refactor(web app): adapt new Vite config 2022-11-05 23:17:18 +08:00
louistiti 25fdaeeab2 refactor(web app): adapt new Vite config 2022-11-05 23:17:18 +08:00
louistiti c4885cb324 refactor(web app): adapt new Vite config 2022-11-05 23:17:18 +08:00
Divlo 71e0f1933c refactor: domain, skill-config and skill in skills/schemas.ts 2022-11-01 21:51:19 +01:00
Divlo 65246dc7cd refactor: domain, skill-config and skill in skills/schemas.ts 2022-11-01 21:51:19 +01:00
Divlo 32fd041495 refactor: domain, skill-config and skill in skills/schemas.ts 2022-11-01 21:51:19 +01:00
louistiti 6c292994fd feat: add data schemas 2022-11-02 00:21:14 +08:00
louistiti 6e8c326a9c feat: add data schemas 2022-11-02 00:21:14 +08:00
louistiti a4e9b1e1cc feat: add data schemas 2022-11-02 00:21:14 +08:00
louistiti 29d7f16b2c feat: add voice configuration schemas 2022-11-01 22:09:52 +08:00
louistiti e3c0a180af feat: add voice configuration schemas 2022-11-01 22:09:52 +08:00
louistiti 360c4d4f6f feat: add voice configuration schemas 2022-11-01 22:09:52 +08:00
louistiti 1a580d1051 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-01 21:45:50 +08:00
louistiti f13df6ab76 Merge branch 'develop' into feat/add-typebox-ajv 2022-11-01 21:45:50 +08:00
louistiti 239472b61e Merge branch 'develop' into feat/add-typebox-ajv 2022-11-01 21:45:50 +08:00
Louis Grenard 83c501dc8d docs: add new sponsor 2022-11-01 21:44:44 +08:00
Louis Grenard 67d07ed7e6 docs: add new sponsor 2022-11-01 21:44:44 +08:00
Louis Grenard 18a728ff4b docs: add new sponsor 2022-10-30 22:23:40 +08:00
Louis Grenard b77e3a99e9 docs: add new sponsor 2022-10-30 22:23:40 +08:00
louistiti daba510755 feat: add distro level info in check report 2022-10-29 11:48:16 +08:00
louistiti dcc04de6bc feat: add distro level info in check report 2022-10-29 11:48:16 +08:00
louistiti 38693e42ef Merge branch 'fix/docker-issues-with-ssl' into develop 2022-10-23 22:55:04 +08:00
louistiti ceaff26d2d Merge branch 'fix/docker-issues-with-ssl' into develop 2022-10-23 22:55:04 +08:00
Divlo db373b66a6 fix(docker): issues with SSL 2022-10-23 12:37:36 +02:00
Divlo fb03359400 fix(docker): issues with SSL 2022-10-23 12:37:36 +02:00
Divlo d8e40c9cce refactor(server): replace unknown return type with TypeBox schema types 2022-10-23 11:09:07 +02:00
Divlo ecca030ab9 refactor(server): replace unknown return type with TypeBox schema types 2022-10-23 11:09:07 +02:00
Divlo 35322b39e3 refactor(server): replace unknown return type with TypeBox schema types 2022-10-23 11:09:07 +02:00
Divlo be079b87c8 feat(server): add JSON models with TypeBox
Later, we will be able to validate JSON files thanks to AJV.
2022-10-23 11:05:55 +02:00
Divlo 2a7b2f45d6 feat(server): add JSON models with TypeBox
Later, we will be able to validate JSON files thanks to AJV.
2022-10-23 11:05:55 +02:00
Divlo 2a48bc6343 feat(server): add JSON models with TypeBox
Later, we will be able to validate JSON files thanks to AJV.
2022-10-23 11:05:55 +02:00
louistiti 5acd22a885 Merge branch 'python-bridge-tcp-server-binaries' into develop 2022-10-23 12:01:21 +08:00
louistiti 632a048c6b Merge branch 'python-bridge-tcp-server-binaries' into develop 2022-10-23 12:01:21 +08:00
louistiti e1e4910399 fix(docker): based on Ubuntu image 2022-10-23 11:46:15 +08:00
louistiti 5bd67be2e5 fix(docker): based on Ubuntu image 2022-10-23 11:46:15 +08:00
louistiti 482f7bfbb8 chore(docker): .dockerignore path 2022-10-23 10:58:25 +08:00
louistiti 2d6f16a311 chore(docker): .dockerignore path 2022-10-23 10:58:25 +08:00
louistiti 3f8027af2a refactor: from superagent to axios 2022-10-23 10:55:03 +08:00
louistiti da063b73bc refactor: from superagent to axios 2022-10-23 10:55:03 +08:00
louistiti 3f97a12153 fix(python bridge): remove unecessary sqlite3 import 2022-10-23 10:07:14 +08:00
louistiti 6bee56580b fix(python bridge): remove unecessary sqlite3 import 2022-10-23 10:07:14 +08:00
louistiti ad1708abbb feat: ignore given warnings for TCP server binary on check script 2022-10-23 01:58:13 +08:00
louistiti bd1671c440 feat: ignore given warnings for TCP server binary on check script 2022-10-23 01:58:13 +08:00
louistiti e527110b9c feat: add binaries download progress 2022-10-23 01:00:55 +08:00
louistiti 0cf39c181f feat: add binaries download progress 2022-10-23 01:00:55 +08:00
louistiti c0886c086f Merge branch 'feat/download-unzip-python-bridge-tcp-server-binaries' into python-bridge-tcp-server-binaries 2022-10-22 23:23:08 +08:00
louistiti e459c1011c Merge branch 'feat/download-unzip-python-bridge-tcp-server-binaries' into python-bridge-tcp-server-binaries 2022-10-22 23:23:08 +08:00
louistiti 9928509171 refactor: minor setup-python-binaries renaming 2022-10-22 23:22:50 +08:00
louistiti 16444ae79f refactor: minor setup-python-binaries renaming 2022-10-22 23:22:50 +08:00
louistiti 75a351e77d chore: fix typo in report logs 2022-10-22 17:50:35 +08:00
louistiti 5c02e906fa chore: fix typo in report logs 2022-10-22 17:50:35 +08:00
louistiti b74e7beb29 ci: pre-release TCP server workflow 2022-10-22 15:14:17 +08:00
louistiti 03b0d08ae0 ci: pre-release TCP server workflow 2022-10-22 15:14:17 +08:00
louistiti 2183ffa4f0 refactor: send check report to the production URL 2022-10-19 23:28:33 +08:00
louistiti 6dbdfe7ba5 refactor: send check report to the production URL 2022-10-19 23:28:33 +08:00
Divlo 8ab9c2e4df feat: download and unzip TCP Server + Python Bridge on postinstall 2022-10-19 13:23:28 +02:00
Divlo c912b637ee feat: download and unzip TCP Server + Python Bridge on postinstall 2022-10-19 13:23:28 +02:00
louistiti fcce24d68c feat: send report to Pastebin and generate URL 2022-10-19 01:17:57 +08:00
louistiti 4df23cfe45 feat: send report to Pastebin and generate URL 2022-10-19 01:17:57 +08:00
louistiti 76e700e9ce feat: provide Python bridge and TCP server version in report 2022-10-19 00:40:34 +08:00
louistiti 65592b9af5 feat: provide Python bridge and TCP server version in report 2022-10-19 00:40:34 +08:00
louistiti 2463759717 refactor: check script according to binaries changes 2022-10-19 00:22:37 +08:00
louistiti 8f9937ddee refactor: check script according to binaries changes 2022-10-19 00:22:37 +08:00
louistiti 02c28b85f6 refactor: remove unnecessary checks 2022-10-16 23:25:58 +08:00
louistiti 5042bcc95d refactor: remove unnecessary checks 2022-10-16 23:25:58 +08:00
louistiti cc6503e6f7 ci: remove tests for Ubuntu AArch64 2022-10-16 01:14:45 +08:00
louistiti 8de9d84f1f ci: test Ubuntu AArch64 2022-10-15 23:36:34 +08:00
louistiti 29c582c89e ci: build on Ubuntu AArch64 2022-10-15 23:24:45 +08:00
louistiti bc53a36cd8 ci: split macOS ARM64 build into isolated job 2022-10-15 22:25:05 +08:00
louistiti 84cdc7fa60 ci: add macOS ARM64 self-hosted runner 2022-10-15 22:09:12 +08:00
louistiti 1dc0451f0f refactor: remove setuptools and wheel force install for macOS ARM64 arch 2022-10-15 21:38:22 +08:00
louistiti 1beebcccd2 refactor: remove Rust compiler version number from TCP server setup 2022-10-15 21:11:29 +08:00
louistiti b6b42c422c feat: install additional resources for macOS ARM64 arch 2022-10-15 21:03:44 +08:00
louistiti bda75915b2 chore: ignore Fleet folder 2022-10-15 20:46:57 +08:00
Divlo b099d53871 fix(docker): install Python binaries from postinstall script 2022-10-13 22:59:39 +02:00
Divlo c6ad1968e7 fix(docker): install Python binaries from postinstall script 2022-10-13 22:59:39 +02:00
louistiti bc37bd1687 ci: try pre-release with all OSes 2022-10-13 01:42:36 +08:00
louistiti 7161cd5996 ci: remove the lock file for Windows 2022-10-13 01:29:37 +08:00
louistiti 23b7d5b49e ci: remove skip lock for Windows 2022-10-13 01:22:40 +08:00
louistiti 599f9561e4 ci: add PIP_NO_BINARY 2022-10-13 01:11:12 +08:00
louistiti bd45220c66 ci: set up MSBuild if Windows 2022-10-13 01:03:14 +08:00
louistiti 53757651c8 ci: make use of Pipenv 2022.7.24 and skip lock on Windows 2022-10-13 00:53:58 +08:00
louistiti bd1bde0814 ci: try with --deploy flag to install Python deps 2022-10-13 00:10:45 +08:00
louistiti ad044814a5 Merge branch 'develop' into python-bridge-tcp-server-binaries 2022-10-12 23:53:16 +08:00
louistiti aede3cbf52 ci: try Windows Pipenv deps install 2022-10-12 23:50:46 +08:00
louistiti 79115d1b25 ci: try to build on Windows without catching exceptions 2022-10-12 23:37:23 +08:00
louistiti 404a1d5b3f Merge branch 'develop' into python-bridge-tcp-server-binaries 2022-10-12 23:11:07 +08:00
louistiti 8a191b9c91 ci: tru the Windows runner without the rm command 2022-10-11 00:47:45 +08:00
louistiti 56a9a796bd ci: remove Pipfile.lock on Windows 2022-10-11 00:43:31 +08:00
louistiti 5bc0a7f97b ci: upgrade Pip to latest and try Windows runner 2022-10-11 00:36:27 +08:00
louistiti 7fe7b2feaa ci: test to upload artifact with default name 2022-10-11 00:03:36 +08:00
louistiti ee0134598c ci: upload artifacts then download and pre-release 2022-10-10 09:11:56 +08:00
louistiti b19e5ad0cb ci: remove Windows 2022-10-10 09:02:03 +08:00
louistiti de442741e5 ci: remove Pipenv cache from pre-release binaries workflows 2022-10-10 00:14:37 +08:00
louistiti f43e17aad4 ci: install Pipenv on pre-release binaries workflows 2022-10-10 00:04:28 +08:00
louistiti ddbe4f0fd1 ci: checkout repo first on pre-release binaries workflows 2022-10-10 00:01:24 +08:00
louistiti f17a601d8e refactor: exit pre-release binaries script 2022-10-09 23:58:59 +08:00
louistiti 5bace9545a ci: add environment variables to locate virtual env 2022-10-09 23:58:05 +08:00
louistiti f170a1dd8e Merge remote-tracking branch 'origin/develop' into python-bridge-tcp-server-binaries 2022-10-09 23:53:49 +08:00
louistiti 91eac5c875 refactor: pre-release binaries script give only workflow name 2022-10-09 23:53:40 +08:00
louistiti 518889b459 fix: rename GitHub workflows from the pre-release-binaries script 2022-10-09 23:39:22 +08:00
louistiti cc8a32d17d ci: pre-release TCP server 2022-10-09 22:03:26 +08:00
louistiti a00b01c041 ci: pre-release Python bridge 2022-10-09 22:00:56 +08:00
louistiti 7db5c064d9 refactor: rename GitHub workflows release script as pre-release 2022-10-09 21:27:12 +08:00
louistiti ed8390a36c feat: trigger GitHub workflows script done 2022-10-09 21:16:42 +08:00
louistiti 1d45c2e715 feat(tcp server): versioning 2022-10-09 00:31:52 +08:00
louistiti 784f86f6f3 feat(python bridge): versioning 2022-10-09 00:29:30 +08:00
louistiti 9d865291f0 feat(server): add warning hint on macOS TCP server cold start 2022-10-07 19:18:36 +08:00
louistiti bc7dd0f836 fix: comply macOS x86_64 and macOS arm64 to Python sysconfig.get_platform() 2022-10-07 18:25:51 +08:00
louistiti 8d64ad9650 refactor: remove LC_ALL and LANG env vars 2022-10-07 18:23:10 +08:00
louistiti b3fdde9d83 chore: explicit exclusion of TCP server and Python bridge on TypeScript watcher 2022-10-07 15:47:55 +08:00
louistiti ea6fc4108a perf(tcp server): option to download spaCy models through mirror in China 2022-10-07 15:31:37 +08:00
louistiti 40958f2fb4 fix(tcp server): handle Windows child process does not throw exception 2022-10-07 14:10:32 +08:00
louistiti 8e0d18a596 perf(tcp server): do not download Python deps but spaCy models when necessary 2022-10-07 13:44:48 +08:00
louistiti 861d773cdd feat: on Python dev env setup, provide Windows hint related to Microsoft C++ Build Tools 2022-10-07 13:24:58 +08:00
louistiti 6bd9f0ef9d fix: always make use of latest Python build deps 2022-10-07 13:16:35 +08:00
louistiti d69157439c feat: add hint on failed build 2022-10-07 12:07:48 +08:00
louistiti 1a3d4f2204 feat: map Python bridge and TCP server binaries to runtime code 2022-10-07 11:53:43 +08:00
louistiti b59f6a7264 perf(tcp server): optimize spaCy models checking 2022-10-07 11:26:39 +08:00
louistiti bf902fd2d9 feat: universal build binaries script 2022-10-07 10:41:04 +08:00
louistiti a8272e1bf9 feat: pack TCP server and optimize setup scripts 2022-10-07 02:37:43 +08:00
louistiti b96070085b feat(tcp server): set up script 2022-10-06 23:20:30 +08:00
louistiti 48688dc6e6 chore: upgrade archiver to latest 2022-10-06 19:48:17 +08:00
louistiti 9dd9b010ed feat(python bridge): pack build 2022-10-06 19:45:35 +08:00
louistiti 0888ae5033 feat(python bridge): build script 2022-10-06 19:01:50 +08:00
louistiti 2d7be3348a feat(python bridge): set up script 2022-10-06 16:27:20 +08:00
louistiti bee3fbb9e2 refactor(tcp server): move tokenizers private libraries to lib location 2022-10-06 08:34:30 +08:00
louistiti 55db68400d fix(tcp server): include private libraries of the tokenizers package 2022-10-06 01:25:26 +08:00
louistiti 7d2432c56c feat(tcp server): include tokenizers files on build 2022-10-06 01:11:52 +08:00
louistiti 48731e8ddf chore(tcp server): upgrade to latest setuptools version 2022-10-06 00:59:20 +08:00
louistiti 4d0a97f9c2 refactor(tcp server): remove cx_Freeze from Pipfile to install it individually during the dev phase 2022-10-06 00:13:54 +08:00
louistiti 133310bd7d fix: remove requests.certs import from the TCP server and Python bridge setups 2022-10-05 01:31:46 +08:00
louistiti 69bf9cebb3 fix: upgrade cx_Freeze to 6.11.1 with --no-binary to avoid OpenSSL conflict with urllib3 2022-10-04 23:57:18 +08:00
louistiti 91e39a0a37 chore: add TCP server and Python bridge as high-level nodes 2022-10-04 17:16:41 +08:00
louistiti 586ca11106 feat: isolate TCP server 2022-10-04 17:10:14 +08:00
louistiti 20b967b4ea chore: transparent distribution structure 2022-10-04 14:30:10 +08:00
louistiti dd9d024975 feat: Python bridge binary build with cx_Freeze 2022-10-04 14:19:56 +08:00
louistiti 8d1ab6973a feat: Python bridge build on macOS x86_64 arch 2022-10-02 15:43:48 +08:00
363 changed files with 12204 additions and 34394 deletions
+9 -2
View File
@@ -1,2 +1,9 @@
node_modules/
bridges/python/src/.venv/*
__pycache__/
**/dist/*
**/build/
**/node_modules/
**/tmp/*
**/src/.venv/*
logs/*
*.pyc
.DS_Store
-1
View File
@@ -12,5 +12,4 @@ end_of_line = lf
insert_final_newline = true
[*.py]
indent_style = tab
indent_size = 4
+2 -2
View File
@@ -31,8 +31,8 @@ LEON_HTTP_API_KEY=
# Language used for the HTTP API
LEON_HTTP_API_LANG=en-US
# Enable/disable collaborative logger
LEON_LOGGER=true
# Enable/disable telemetry
LEON_TELEMETRY=true
# Python TCP server
LEON_PY_TCP_SERVER_HOST=0.0.0.0
+22 -1
View File
@@ -26,14 +26,29 @@
"plugins": ["@typescript-eslint", "unicorn", "import"],
"ignorePatterns": "*.spec.js",
"rules": {
"@typescript-eslint/no-non-null-assertion": ["off"],
"no-async-promise-executor": ["off"],
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"prefer-destructuring": ["error"],
"comma-dangle": ["error", "never"],
"semi": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"@typescript-eslint/explicit-function-return-type": "off",
"unicorn/prefer-node-protocol": "error",
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/consistent-type-definitions": "error",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/order": [
@@ -52,6 +67,12 @@
]
},
"overrides": [
{
"files": ["skills/**/*.ts"],
"rules": {
"import/order": "off"
}
},
{
"files": ["*.ts"],
"rules": {
+78 -4
View File
@@ -51,7 +51,7 @@ Choose the setup method you want to go for.
### Single-Click
Gitpod will automatically setup an environment and run an instance for you.
Gitpod will automatically set up an environment and run an instance for you.
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/leon-ai/leon)
@@ -123,11 +123,14 @@ Types define which kind of changes you made to the project.
Scopes define high-level nodes of Leon.
- web app
- bridge/python
- bridge/nodejs
- docker
- hotword
- scripts
- server
- tcp server
- python bridge
- hotword
- web app
- skill/skill_name
### Examples
@@ -149,6 +152,77 @@ By sponsoring the project you make the project sustainable and faster to develop
The focus is not only limited to the activity you see on GitHub but also a lot of thinking about the direction of the project. Which is naturally related to the overall design, architecture, vision, learning process and so on...
## Contributing to the Python Bridge or TCP HttpServer
Leon makes use of two binaries, the Python bridge and the TCP server. These binaries are compiled from Python sources.
The Python bridge is used to communicate between the core and skills made with Python.
The TCP server is used to communicate between the core and third-party nodes, such as spaCy.
### Set Up the Python Environment
To contribute to these parts, you need to set up a Python environment running with a specific Python version and a specific Pipenv version.
It is recommended to use Pyenv to manage your Python versions.
If you are on GNU/Linux Ubuntu, you can run the following to install Pyenv, otherwise, please refer to the [Pyenv documentation to install it](https://github.com/pyenv/pyenv#installation):
```bash
# Update registry
sudo apt-get update
# Install Pyenv deps
sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
# Install Pyenv
curl https://pyenv.run | bash
# Add output lines to .bashrc
# Restart shell
exec "$SHELL"
```
Once Pyenv installed, run:
```bash
# Install Python
pyenv install 3.9.10 --force
pyenv global 3.9.10
# Install Pipenv
pip install pipenv==2022.7.24
```
Your Python environment should be ready now. So now you can set up the respective environments according to what you are going to contribute to and build them:
```bash
# Set up the Python bridge environment
npm run setup:python-bridge
# Set up the TCP server environment
npm run setup:tcp-server
# If you are in China, you can run this to download models faster:
npm run setup:tcp-server cn
# Once your code changes are done, you can build via:
# Build the Python bridge
npm run build:python-bridge
# Build the TCP server
npm run build:tcp-server
# Run the Python bridge
./bridges/python/dist/{OS-CPU_ARCH}/leon-python-bridge server/src/intent-object.sample.json
# Run the TCP server
./tcp_server/dist/{OS-CPU_ARCH}/leon-tcp-server en
```
## Spread the Word
Use [#LeonAI](<https://twitter.com/search?f=live&q=%23LeonAI%20(from%3Agrenlouis%20OR%20from%3Alouistiti_fr)&src=typed_query>) if you tweet about Leon and/or mention [@grenlouis](https://twitter.com/grenlouis).
@@ -0,0 +1,76 @@
name: Pre-release Node.js bridge
on: workflow_dispatch
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Set Node.js bridge version
working-directory: bridges/nodejs/src
run: |
echo "NODEJS_BRIDGE_VERSION=$(node --require fs --eval "const fs = require('node:fs'); const [, VERSION] = fs.readFileSync('version.ts', 'utf8').split(\"'\"); console.log(VERSION)")" >> $GITHUB_ENV
- name: Display Node.js bridge version
run: |
echo "Node.js bridge version: ${{ env.NODEJS_BRIDGE_VERSION }}"
- name: Install core
run: npm install
- name: Build Node.js bridge
run: npm run build:nodejs-bridge
- name: Upload Node.js bridge
uses: actions/upload-artifact@v3
with:
path: bridges/nodejs/dist/*.zip
draft-release:
name: Draft-release
needs: [build]
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Set Node.js bridge version
working-directory: bridges/nodejs/src
run: |
echo "NODEJS_BRIDGE_VERSION=$(node --require fs --eval "const fs = require('node:fs'); const [, VERSION] = fs.readFileSync('version.ts', 'utf8').split(\"'\"); console.log(VERSION)")" >> $GITHUB_ENV
- name: Download Node.js bridge
uses: actions/download-artifact@v3
with:
path: bridges/nodejs/dist
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: nodejs-bridge_v${{ env.NODEJS_BRIDGE_VERSION }}
draft: true
prerelease: false
title: Node.js Bridge ${{ env.NODEJS_BRIDGE_VERSION }}
files: bridges/nodejs/dist/artifact/*.zip
@@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
@@ -33,7 +33,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- name: Set Python bridge version
working-directory: bridges/python/src
@@ -45,7 +44,7 @@ jobs:
echo "Python bridge version: ${{ env.PYTHON_BRIDGE_VERSION }}"
- name: Install core
run: npm ci
run: npm install
- name: Set up Python bridge
run: npm run setup:python-bridge
@@ -61,7 +60,7 @@ jobs:
draft-release:
name: Draft-release
needs: [build]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Clone repository
+41 -11
View File
@@ -7,12 +7,13 @@ env:
PIPENV_VENV_IN_PROJECT: true
jobs:
pre-release:
name: Pre-release
build:
name: Build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
@@ -24,32 +25,62 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9.10
# cache: pipenv
- name: Install Pipenv
run: pip install --upgrade pip && pip install pipenv
run: pip install --upgrade pip && pip install pipenv==2022.7.24
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- name: Set TCP server version
working-directory: ./tcp_server/src
working-directory: tcp_server/src
run: |
echo "TCP_SERVER_VERSION=$(python -c "from version import __version__; print(__version__)")" >> $GITHUB_ENV
- name: Display TCP server version
run: |
echo "TCP server version: ${{ env.TCP_SERVER_VERSION }}"
- name: Install core
run: npm ci
run: npm install
- name: Setup TCP server
- name: Set up TCP server
run: npm run setup:tcp-server
- name: Build TCP server
run: npm run build:tcp-server
- name: Upload TCP server
uses: actions/upload-artifact@v3
with:
path: tcp_server/dist/*.zip
draft-release:
name: Draft-release
needs: [build]
runs-on: ubuntu-20.04
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.9.10
- name: Set TCP server version
working-directory: tcp_server/src
run: |
echo "TCP_SERVER_VERSION=$(python -c "from version import __version__; print(__version__)")" >> $GITHUB_ENV
- name: Download TCP server
uses: actions/download-artifact@v3
with:
path: tcp_server/dist
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -57,5 +88,4 @@ jobs:
draft: true
prerelease: false
title: TCP Server ${{ env.TCP_SERVER_VERSION }}
files: |
tcp_server/dist/*.zip
files: tcp_server/dist/artifact/*.zip
+6 -4
View File
@@ -8,27 +8,29 @@ __pycache__/
test/coverage/
**/tmp/*
**/src/.venv/*
downloads/*
logs/*
core/config/**/*.json
bin/coqui/*
bin/flite/*
package-lock.json
*.pyc
.DS_Store
*.sublime-workspace
npm-debug.log
debug.log
.env
.last-skill-npm-install
leon.json
bridges/python/src/Pipfile.lock
tcp_server/src/Pipfile.lock
!tcp_server/**/.gitkeep
!bridges/python/**/.gitkeep
!bridges/nodejs/**/.gitkeep
!**/*.sample*
packages/**/config/config.json
skills/**/src/config.json
packages/**/data/db/*.json
skills/**/src/settings.json
skills/**/memory/*.json
core/data/models/*.nlp
package.json.backup
.python-version
schemas/**/*.json
+2
View File
@@ -1 +1,3 @@
engine-strict=true
package-lock=false
save-exact=true
+4
View File
@@ -1,3 +1,7 @@
# [1.0.0-beta.8](https://github.com/leon-ai/leon/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-05-01) / Binaries and TypeScript Rewrite
_Please refer to [our latest blog post](https://blog.getleon.ai/binaries-and-typescript-rewrite-1-0-0-beta-8/) for more information on the new release of our dear Leon._
# [1.0.0-beta.7](https://github.com/leon-ai/leon/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2022-08-24) / A Much Better NLP
_Please [read this blog post](https://blog.getleon.ai/a-much-better-nlp-and-future-1-0-0-beta-7/) to know more about all the new features and the exciting future of Leon._
+22 -31
View File
@@ -1,4 +1,4 @@
FROM ubuntu:latest
FROM ubuntu:20.04
ENV IS_DOCKER true
# Replace shell with bash so we can source files
@@ -15,18 +15,23 @@ RUN apt-get update && apt-get install --yes -q --no-install-recommends \
curl \
git \
wget \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
llvm \
libncurses5-dev \
xz-utils \
tk-dev libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev
libssl-dev \
openssl \
libz-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
llvm \
libncurses5-dev \
xz-utils \
tk-dev libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev \
libgdbm-dev \
libnss3-dev \
libc6-dev
# Run the container as an unprivileged user
RUN groupadd docker && useradd -g docker -s /bin/bash -m docker
@@ -34,28 +39,14 @@ USER docker
WORKDIR /home/docker
# Install Node.js with nvm
ENV NVM_DIR /home/docker/nvm
ENV NODE_VERSION v16.17.0
ENV NVM_DIR /home/docker/.nvm
ENV NODE_VERSION v16.18.0
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION"
ENV NODE_PATH $NVM_DIR/versions/node/$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
# Install Python with pyenv
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="/home/docker/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
ENV PYTHON_VERSION=3.9.10
RUN pyenv install ${PYTHON_VERSION}
RUN pyenv global ${PYTHON_VERSION}
# Install Pipenv
ENV PYTHON_BIN_PATH /home/docker/.local/bin
ENV PATH="${PYTHON_BIN_PATH}:${PATH}"
RUN python -m pip install --user --force-reinstall pipenv virtualenv
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
# Install Leon
WORKDIR /home/docker/leon
+56 -23
View File
@@ -28,14 +28,47 @@ _<p align="center">Your open-source personal assistant.</p>_
<a href="https://blog.getleon.ai/the-story-behind-leon/">Story</a>
</p>
<br>
<h2 align="center">📢 Notice 📢</h2>
<p align="center">
<a href="https://blog.getleon.ai/a-much-better-nlp-and-future-1-0-0-beta-7/"><img width="400" src="https://blog.getleon.ai/static/a62ac28a01cb6898e299dced40875a68/c1b63/beta-7.png" /></a>
<br>
Many exciting things are coming up, hence no new documentation and test are going to be written until the official release of Leon. Feel free to <a href="https://discord.gg/MNQqqKg"><b>join us on Discord</b></a> to know more and to read the <a href="https://blog.getleon.ai/a-much-better-nlp-and-future-1-0-0-beta-7/"><b>"A Much Better NLP and Future" blog post</b></a>.
</p>
<br><br>
---
## Current State
### Why is there a small amount of contributors?
I'm taking a lot of time to work on the new core of Leon due to personal reasons. I can only work on it after work and on weekends. Hence, **I'm blocking any potential contribution as the whole core of Leon is coming with many breaking changes**. Many of you are willing to contribute in Leon (create new skills, help to improve the core, translations and so on...), a big thanks to every one of you!
While I would love to devote more time to Leon, I'm currently unable to do so because I have bills to pay. I have some ideas about how to monetize Leon in the future (Leon's core will always remain open source), but before to get there there is still a long way to go.
Until then, any financial support by [sponsoring Leon](http://sponsor.getleon.ai) is much appreciated 🙂
### How about large language models and Leon?
Since AI gained in popularity and large language models are getting more and more traction, many of you joined our community. A huge welcome to all of you! 🤗
At the moment, Leon's NLU will remain intents first with his own model without relying on an LLM. It is important that Leon can run 100% offline and I'm confident that with the downsizing techniques such as quantization Leon will sooner or later work with LLMs at his core and still be able to run on edge.
Here is how LLMs may help Leon in the future:
- Intent fallback: when an utterance cannot match an intent, then rely on an LLM to provide results.
- New named entity recognition engine: provide a better solution to extract entities from utterances such as fruits, numbers, cities, durations, persons, etc.
- Skill features: let skills leverage LLMs to provide out-of-the-box NLP features such as summarization, knowledge base, translation, sentiment analysis and so on...
- Skill building: LLMs can help to develop skills such as paraphrasing utterance samples, translate answers, convert code from our Python bridge to the upcoming JavaScript bridge and vice versa, etc.
- More...
### What's Next?
Once the new core released, we'll work on the community aspect of Leon. For example, better organize [our Discord](https://discord.gg/MNQqqKg), planify regular calls, work on skills together, etc. It is very important for Leon to have a real community. At that moment, the skills platform will already be online, so it'll be easier to sync our progress and publish new skills.
- Feel free to check out the Git development branches and our [next major milestones](https://blog.getleon.ai/a-much-better-nlp-and-future-1-0-0-beta-7/#whats-next).
- And the [detailed roadmap](http://roadmap.getleon.ai).
- Many exciting things are coming up, hence no new documentation and test are going to be written until the official release of Leon.
---
## Latest Release
Check out the [latest release blog post](https://blog.getleon.ai/binaries-and-typescript-rewrite-1-0-0-beta-8/).
<a href="https://blog.getleon.ai/binaries-and-typescript-rewrite-1-0-0-beta-8/"><img width="400" src="https://blog.getleon.ai/static/a0d1cbafd1968e7531dc17e229f8cc61/aa440/beta-8.png" /></a>
---
@@ -68,8 +101,8 @@ If you want to, Leon can communicate with you by being **offline to protect your
> - Skills
> - The web app
> - The hotword node
> - The TCP server (for inter-process communication between Leon and third-party processes such as spaCy)
> - The Python bridge (the connector between Python core and skills)
> - The TCP server (for inter-process communication between Leon and third-party nodes such as spaCy)
> - The Python bridge (the connector between the core and skills made with Python)
### What is Leon able to do?
@@ -81,7 +114,7 @@ Sounds good to you? Then let's get started!
## ☁️ Try with a Single-Click
Gitpod will automatically setup an environment and run an instance for you.
Gitpod will automatically set up an environment and run an instance for you.
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/leon-ai/leon)
@@ -172,6 +205,13 @@ You'll find a write-up on this [blog post](https://blog.getleon.ai/the-story-beh
<table>
<tbody>
<tr>
<td align="center" valign="middle" width="128">
<a href="https://github.com/Appwrite">
<img src="https://github.com/Appwrite.png?size=128" />
Appwrite
</a><br>
<sub><sup>250 USD / month</sup></sub>
</td>
<td align="center" valign="middle" width="128">
<img src="https://getleon.ai/img/anonymous.svg" width="128" />
Anonymous
@@ -179,21 +219,14 @@ You'll find a write-up on this [blog post](https://blog.getleon.ai/the-story-beh
<sub><sup>100 USD / month</sup></sub>
</td>
<td align="center" valign="middle" width="128">
<a href="https://github.com/phareal">
<img src="https://github.com/phareal.png?size=128" />
phareal
</a><br>
<sub><sup>30 USD / month</sup></sub>
</td>
<td align="center" valign="middle" width="128">
<a href="https://github.com/KeithIMyers">
<img src="https://github.com/KeithIMyers.png?size=128" />
Keith Myers
<a href="https://github.com/herbundkraut">
<img src="https://github.com/herbundkraut.png?size=128" />
herbundkraut
</a><br>
<sub><sup>10 USD / month</sup></sub>
</td>
<td align="center" valign="middle" width="128">
<a href="http://sponsor.getleon.ai/">
<a href="http://sponsor.getleon.ai/">
You?
</a>
</td>
@@ -220,7 +253,7 @@ The focus is not only limited to the activity you see on GitHub but also a lot o
</a>
&nbsp; &nbsp; &nbsp;
<a href="https://www.aoz.studio">
<img src="https://user-images.githubusercontent.com/1731544/153794939-c42f1b10-a15d-4e82-b448-dc95bfe85b1c.png" alt="AOZ Studio" width="64" />
<img src="https://getleon.ai/_next/image?url=%2Fimg%2Fthanks%2Faoz-studio.png&w=384&q=75" alt="AOZ Studio" width="128" />
</a>
## 📝 License
+19 -5
View File
@@ -125,8 +125,10 @@ table {
}
:root {
--black-color: #151718;
--black-color: #000;
--light-black-color: #222426;
--white-color: #fff;
--grey-color: #323739;
}
a {
@@ -193,7 +195,7 @@ input {
color: var(--white-color);
width: 100%;
border: none;
border-bottom: 2px solid var(--white-color);
border-bottom: 2px solid var(--grey-color);
background: none;
font-weight: 400;
font-size: 4em;
@@ -222,7 +224,7 @@ small {
top: 10%;
height: 50%;
overflow-y: auto;
border: 2px solid var(--white-color);
border: 2px solid var(--grey-color);
border-radius: 12px;
}
#feed::-webkit-scrollbar {
@@ -285,6 +287,17 @@ small {
.bubble-container.leon {
text-align: left;
}
.show-more {
margin: 3px;
text-decoration: underline;
}
.show-more:hover {
cursor: pointer;
text-decoration: none;
}
.show-all {
max-height: 100% !important;
}
.bubble {
padding: 6px 12px;
@@ -295,6 +308,7 @@ small {
text-align: left;
opacity: 0;
animation: fadeIn 0.2s ease-in forwards;
overflow: hidden;
}
#feed .me .bubble {
background-color: #1c75db;
@@ -302,8 +316,8 @@ small {
right: 0;
}
#feed .leon .bubble {
background-color: #eee;
color: var(--black-color);
background-color: var(--light-black-color);
color: var(--white-color);
}
@keyframes fadeIn {
100% {
+1
View File
@@ -9,6 +9,7 @@
</head>
<body class="settingup">
<main>
<div id="root"></div>
<div id="feed">
<p id="no-bubble" class="hide">
You can start to interact with Leon, don't be shy.
+9
View File
@@ -0,0 +1,9 @@
function App() {
return (
<>
<p>Hello from React</p>
</>
)
}
export default App
+9
View File
@@ -0,0 +1,9 @@
import type React from 'react'
interface Props {
children: React.ReactNode
}
export function Button({ children }: Props) {
return <button>{children}</button>
}
+22
View File
@@ -1,3 +1,5 @@
const MAXIMUM_HEIGHT_TO_SHOW_SEE_MORE = 340
export default class Chatbot {
constructor() {
this.et = new EventTarget()
@@ -60,6 +62,9 @@ export default class Chatbot {
}
loadFeed() {
/**
* TODO: widget: load widget from local storage
*/
return new Promise((resolve) => {
if (this.parsedBubbles === null || this.parsedBubbles.length === 0) {
this.noBubbleMessage.classList.remove('hide')
@@ -92,6 +97,23 @@ export default class Chatbot {
this.feed.appendChild(container).appendChild(bubble)
if (container.clientHeight > MAXIMUM_HEIGHT_TO_SHOW_SEE_MORE) {
bubble.style.maxHeight = `${MAXIMUM_HEIGHT_TO_SHOW_SEE_MORE}px`
const showMore = document.createElement('p')
const showMoreText = 'Show more'
showMore.className = 'show-more'
showMore.innerHTML = showMoreText
container.appendChild(showMore)
showMore.addEventListener('click', () => {
bubble.classList.toggle('show-all')
showMore.innerHTML =
showMore.innerHTML === showMoreText ? 'Show less' : showMoreText
})
}
if (save) {
this.saveBubble(who, string)
}
+51 -5
View File
@@ -1,6 +1,10 @@
import { io } from 'socket.io-client'
import React from 'react'
import { createRoot } from 'react-dom/client'
import { Button } from './aurora/button'
import Chatbot from './chatbot'
import { INIT_MESSAGES } from './constants'
export default class Client {
constructor(client, serverUrl, input, res) {
@@ -31,6 +35,24 @@ export default class Client {
return this._recorder
}
async sendInitMessages() {
for (let i = 0; i < INIT_MESSAGES.length; i++) {
const messages = INIT_MESSAGES[i]
const message = messages[Math.floor(Math.random() * messages.length)]
const sendingDelay = Math.floor(Math.random() * 2000) + 1000
const typingFactorDelay = Math.floor(Math.random() * 4) + 2
setTimeout(() => {
this.chatbot.isTyping('leon', true)
}, sendingDelay / typingFactorDelay)
await new Promise((resolve) => setTimeout(resolve, sendingDelay))
this.chatbot.receivedFrom('leon', message)
this.chatbot.isTyping('leon', false)
}
}
init(loader) {
this.chatbot.init()
@@ -40,6 +62,10 @@ export default class Client {
this.socket.on('ready', () => {
loader.stop()
if (this.chatbot.parsedBubbles?.length === 0) {
this.sendInitMessages()
}
})
this.socket.on('answer', (data) => {
@@ -63,6 +89,30 @@ export default class Client {
cb('string-received')
})
this.socket.on('widget', (data) => {
/**
* TODO: widget: widget handler to core/skill; dynamic component rendering
*/
console.log('data', data)
const container = document.createElement('div')
container.className = 'widget'
this.chatbot.feed.appendChild(container)
const root = createRoot(container)
// TODO: widget: pass props and dynamic component loading according to type
const widgets = {
Button: (options) => {
return Button({
children: options.text
})
}
}
root.render(widgets[data.type](data.options))
})
this.socket.on('audio-forwarded', (data, cb) => {
const ctx = new AudioContext()
const source = ctx.createBufferSource()
@@ -100,7 +150,7 @@ export default class Client {
}
}
}
}, 1000)
}, 1_000)
}, data.duration + 500)
}
})
@@ -108,10 +158,6 @@ export default class Client {
cb('audio-received')
})
this.socket.on('download', (data) => {
window.location = `${this.serverUrl}/api/v1/downloads?domain=${data.domain}&skill=${data.skill}`
})
if (this.history !== null) {
this.parsedHistory = JSON.parse(this.history)
}
+21
View File
@@ -0,0 +1,21 @@
export const INIT_MESSAGES = [
[
`Hello there! Glad to e-meet meet you, I'm Leon, your open-source personal assistant. While I'm still learning and improving, I promise to do my best to be helpful.`
],
[
`<ul>
<li>We've got lots in the works. Check out <a href="http://roadmap.getleon.ai/" target="_blank">our roadmap</a>.</li>
<li>Stay updated on our progress by checking out our <a href="https://blog.getleon.ai/" target="_blank">blog</a>.</li>
<li>You can also get updates straight to your inbox <a href="https://newsletter.getleon.ai/subscription/form" target="_blank">here</a>.</li>
`
],
[
`Come hang out with us <a href="https://discord.gg/MNQqqKg" target="_blank">on Discord</a>! Once we release our official version, our community will be working together to build new skills for me. You won't want to miss out on the fun!`
],
[
`At the moment, I'm not using a large language model, but we're planning to incorporate some in the future to improve my abilities. You can <a href="https://github.com/leon-ai/leon#how-about-large-language-models-and-leon" target="_blank">learn more about our plans here</a>.`
],
[
`Just so you know, my creator is working tirelessly to improve my skills and features, dedicating 75% of his free time to the project on top of his full-time job. If you'd like to help speed up my development, you can sponsor his work by clicking on this link: <strong><a href='http://sponsor.getleon.ai/' target='_blank'>sponsor.getleon.ai</a></strong>. Your support would mean a lot to us. Thank you for choosing me as your assistant!`
]
]
+96 -96
View File
@@ -1,4 +1,4 @@
import request from 'superagent'
import axios from 'axios'
import Loader from './loader'
import Client from './client'
@@ -11,126 +11,107 @@ const config = {
server_host: import.meta.env.VITE_LEON_HOST,
server_port: import.meta.env.VITE_LEON_PORT,
min_decibels: -40, // Noise detection sensitivity
max_blank_time: 1000 // Maximum time to consider a blank (ms)
max_blank_time: 1_000 // Maximum time to consider a blank (ms)
}
const serverUrl =
import.meta.env.VITE_LEON_NODE_ENV === 'production'
? ''
: `${config.server_host}:${config.server_port}`
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('DOMContentLoaded', async () => {
const loader = new Loader()
loader.start()
request.get(`${serverUrl}/api/v1/info`).end((err, res) => {
if (err || !res.ok) {
console.error(err.response.error.message)
} else {
const input = document.querySelector('#utterance')
const mic = document.querySelector('#mic-button')
const v = document.querySelector('#version small')
const client = new Client(config.app, serverUrl, input, res.body)
let rec = {}
let chunks = []
try {
const response = await axios.get(`${serverUrl}/api/v1/info`)
const input = document.querySelector('#utterance')
const mic = document.querySelector('#mic-button')
const v = document.querySelector('#version small')
const client = new Client(config.app, serverUrl, input, response.data)
let rec = {}
let chunks = []
v.innerHTML += client.info.version
v.innerHTML += client.info.version
client.init(loader)
client.init(loader)
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices
.getUserMedia({ audio: true })
.then((stream) => {
if (MediaRecorder) {
rec = new Recorder(stream, mic, client.info)
client.recorder = rec
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices
.getUserMedia({ audio: true })
.then((stream) => {
if (MediaRecorder) {
rec = new Recorder(stream, mic, client.info)
client.recorder = rec
rec.ondataavailable((e) => {
chunks.push(e.data)
})
rec.ondataavailable((e) => {
chunks.push(e.data)
})
rec.onstart(() => {
/* */
})
rec.onstart(() => {
/* */
})
rec.onstop(() => {
const blob = new Blob(chunks)
chunks = []
rec.enabled = false
rec.onstop(() => {
const blob = new Blob(chunks)
chunks = []
rec.enabled = false
// Ensure there are some data
if (blob.size >= 1000) {
client.socket.emit('recognize', blob)
}
})
// Ensure there are some data
if (blob.size >= 1_000) {
client.socket.emit('recognize', blob)
}
})
listener.listening(
stream,
config.min_decibels,
config.max_blank_time,
() => {
// Noise detected
rec.noiseDetected = true
},
() => {
// Noise ended
listener.listening(
stream,
config.min_decibels,
config.max_blank_time,
() => {
// Noise detected
rec.noiseDetected = true
},
() => {
// Noise ended
rec.noiseDetected = false
if (rec.enabled && !rec.hotwordTriggered) {
rec.stop()
rec.enabled = false
rec.hotwordTriggered = false
rec.countSilenceAfterTalk = 0
}
}
)
client.socket.on('enable-record', () => {
rec.hotwordTriggered = true
rec.start()
setTimeout(() => {
rec.noiseDetected = false
if (rec.enabled && !rec.hotwordTriggered) {
rec.stop()
rec.enabled = false
rec.hotwordTriggered = false
}, config.max_blank_time)
rec.enabled = true
})
} else {
console.error('MediaRecorder is not supported on your browser.')
}
})
.catch((err) => {
console.error(
'MediaDevices.getUserMedia() threw the following error:',
err
rec.countSilenceAfterTalk = 0
}
}
)
})
} else {
console.error(
'MediaDevices.getUserMedia() is not supported on your browser.'
)
}
document.addEventListener('keydown', (e) => {
onkeydowndocument(e, () => {
if (rec.enabled === false) {
input.value = ''
rec.start()
rec.enabled = true
client.socket.on('enable-record', () => {
rec.hotwordTriggered = true
rec.start()
setTimeout(() => {
rec.hotwordTriggered = false
}, config.max_blank_time)
rec.enabled = true
})
} else {
rec.stop()
rec.enabled = false
console.error('MediaRecorder is not supported on your browser.')
}
})
})
input.addEventListener('keydown', (e) => {
onkeydowninput(e, client)
})
mic.addEventListener('click', (e) => {
e.preventDefault()
.catch((err) => {
console.error(
'MediaDevices.getUserMedia() threw the following error:',
err
)
})
} else {
console.error(
'MediaDevices.getUserMedia() is not supported on your browser.'
)
}
document.addEventListener('keydown', (e) => {
onkeydowndocument(e, () => {
if (rec.enabled === false) {
input.value = ''
rec.start()
rec.enabled = true
} else {
@@ -138,6 +119,25 @@ document.addEventListener('DOMContentLoaded', () => {
rec.enabled = false
}
})
}
})
})
input.addEventListener('keydown', (e) => {
onkeydowninput(e, client)
})
mic.addEventListener('click', (e) => {
e.preventDefault()
if (rec.enabled === false) {
rec.start()
rec.enabled = true
} else {
rec.stop()
rec.enabled = false
}
})
} catch (e) {
alert(`Error: ${e.message}; ${JSON.stringify(e.response?.data)}`)
console.error(e)
}
})
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"useDefineForClassFields": true,
"skipLibCheck": true,
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
}
}
+13 -3
View File
@@ -1,16 +1,26 @@
import dns from 'node:dns'
import dotenv from 'dotenv'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
dotenv.config()
dns.setDefaultResultOrder('verbatim')
// Map necessary Leon's env vars as Vite only expose VITE_*
process.env.VITE_LEON_NODE_ENV = process.env.LEON_NODE_ENV
process.env.VITE_LEON_HOST = process.env.LEON_HOST
process.env.VITE_LEON_PORT = process.env.LEON_PORT
export default {
export default defineConfig({
root: 'app/src',
build: {
outDir: '../dist',
emptyOutDir: true
}
}
},
server: {
port: 3000
},
plugins: [react()]
})
+2
View File
@@ -0,0 +1,2 @@
package-lock=false
save-exact=true
+22
View File
@@ -0,0 +1,22 @@
{
"name": "leon-nodejs-bridge",
"description": "Leon's Node.js bridge to communicate between the core and skills made with JavaScript",
"main": "dist/bin/leon-nodejs-bridge.js",
"author": {
"name": "Louis Grenard",
"email": "louis@getleon.ai",
"url": "https://twitter.com/grenlouis"
},
"license": "MIT",
"homepage": "https://getleon.ai",
"bugs": {
"url": "https://github.com/leon-ai/leon/issues"
},
"dependencies": {
"axios": "1.4.0",
"lodash": "4.17.21"
},
"devDependencies": {
"@types/lodash": "4.14.194"
}
}
+32
View File
@@ -0,0 +1,32 @@
import fs from 'node:fs'
import path from 'node:path'
import { SKILLS_PATH as SKILLS_ROOT_PATH } from '@/constants'
import type { SkillConfigSchema } from '@server/schemas/skill-schemas'
import type { IntentObject } from '@sdk/types'
const {
argv: [, , INTENT_OBJ_FILE_PATH]
} = process
export const INTENT_OBJECT: IntentObject = JSON.parse(
fs.readFileSync(INTENT_OBJ_FILE_PATH as string, 'utf8')
)
export const SKILL_PATH = path.join(
SKILLS_ROOT_PATH,
INTENT_OBJECT.domain,
INTENT_OBJECT.skill
)
export const SKILLS_PATH = SKILLS_ROOT_PATH
export const SKILL_CONFIG: SkillConfigSchema = JSON.parse(
fs.readFileSync(
path.join(
SKILL_PATH,
'config',
INTENT_OBJECT.extra_context_data.lang + '.json'
),
'utf8'
)
)
export { LEON_VERSION, NODEJS_BRIDGE_VERSION } from '@/constants'
+49
View File
@@ -0,0 +1,49 @@
import path from 'node:path'
import type { ActionFunction, ActionParams } from '@sdk/types'
import { INTENT_OBJECT } from '@bridge/constants'
;(async (): Promise<void> => {
const {
domain,
skill,
action,
lang,
utterance,
current_entities,
entities,
current_resolvers,
resolvers,
slots,
extra_context_data
} = INTENT_OBJECT
const params: ActionParams = {
lang,
utterance,
current_entities,
entities,
current_resolvers,
resolvers,
slots,
extra_context_data
}
try {
const actionModule = await import(
path.join(
process.cwd(),
'skills',
domain,
skill,
'src',
'actions',
`${action}.ts`
)
)
const actionFunction: ActionFunction = actionModule.run
await actionFunction(params)
} catch (e) {
console.error(`Error while running "${skill}" skill "${action}" action:`, e)
}
})()
+12
View File
@@ -0,0 +1,12 @@
import { Widget } from '../widget'
// TODO: contains the button API. rendering engine <-> SDK
interface ButtonOptions {
text: string
}
export class Button extends Widget<ButtonOptions> {
public constructor(options: ButtonOptions) {
super(options)
}
}
+130
View File
@@ -0,0 +1,130 @@
import type {
AnswerData,
AnswerInput,
AnswerOutput,
AnswerConfig
} from '@sdk/types'
import { INTENT_OBJECT, SKILL_CONFIG } from '@bridge/constants'
class Leon {
private static instance: Leon
constructor() {
if (!Leon.instance) {
Leon.instance = this
}
}
/**
* Apply data to the answer
* @param answerKey The answer key
* @param data The data to apply
* @example setAnswerData('key', { name: 'Leon' })
*/
public setAnswerData(
answerKey: string,
data: AnswerData = null
): AnswerConfig {
try {
// In case the answer key is a raw answer
if (SKILL_CONFIG.answers == null || !SKILL_CONFIG.answers[answerKey]) {
return answerKey
}
const answers = SKILL_CONFIG.answers[answerKey] ?? ''
let answer: AnswerConfig
if (Array.isArray(answers)) {
answer = answers[Math.floor(Math.random() * answers.length)] ?? ''
} else {
answer = answers
}
if (data != null) {
for (const key in data) {
// In case the answer needs speech and text differentiation
if (typeof answer !== 'string' && answer.text) {
answer.text = answer.text.replaceAll(`%${key}%`, String(data[key]))
answer.speech = answer.speech.replaceAll(
`%${key}%`,
String(data[key])
)
} else {
answer = (answer as string).replaceAll(
`%${key}%`,
String(data[key])
)
}
}
}
if (SKILL_CONFIG.variables) {
const { variables } = SKILL_CONFIG
for (const key in variables) {
// In case the answer needs speech and text differentiation
if (typeof answer !== 'string' && answer.text) {
answer.text = answer.text.replaceAll(
`%${key}%`,
String(variables[key])
)
answer.speech = answer.speech.replaceAll(
`%${key}%`,
String(variables[key])
)
} else {
answer = (answer as string).replaceAll(
`%${key}%`,
String(variables[key])
)
}
}
}
return answer
} catch (e) {
console.error('Error while setting answer data:', e)
throw e
}
}
/**
* Send an answer to the core
* @param answerInput The answer input
* @example answer({ key: 'greet' }) // 'Hello world'
* @example answer({ key: 'welcome', data: { name: 'Louis' } }) // 'Welcome Louis'
* @example answer({ key: 'confirm', core: { restart: true } }) // 'Would you like to retry?'
*/
public async answer(answerInput: AnswerInput): Promise<void> {
try {
const answerObject: AnswerOutput = {
...INTENT_OBJECT,
output: {
codes:
answerInput.widget && !answerInput.key
? 'widget'
: (answerInput.key as string),
answer:
answerInput.key != null
? this.setAnswerData(answerInput.key, answerInput.data)
: '',
core: answerInput.core
}
}
if (answerInput.widget) {
answerObject.output.widget = answerInput.widget
}
// "Temporize" for the data buffer output on the core
await new Promise((r) => setTimeout(r, 100))
process.stdout.write(JSON.stringify(answerObject))
} catch (e) {
console.error('Error while creating answer:', e)
}
}
}
export const leon = new Leon()
+99
View File
@@ -0,0 +1,99 @@
import path from 'node:path'
import fs from 'node:fs'
import { SKILL_PATH, SKILLS_PATH } from '@bridge/constants'
interface MemoryOptions<T> {
name: string
defaultMemory?: T
}
export class Memory<T = unknown> {
private readonly memoryPath: string
private readonly name: string
private readonly defaultMemory: T | undefined
private isFromAnotherSkill: boolean
constructor(options: MemoryOptions<T>) {
const { name, defaultMemory } = options
this.name = name
this.defaultMemory = defaultMemory
this.memoryPath = path.join(SKILL_PATH, 'memory', `${this.name}.json`)
this.isFromAnotherSkill = false
if (this.name.includes(':') && this.name.split(':').length === 3) {
this.isFromAnotherSkill = true
const [domainName, skillName, memoryName] = this.name.split(':')
this.memoryPath = path.join(
SKILLS_PATH,
domainName as string,
skillName as string,
'memory',
`${memoryName}.json`
)
}
}
/**
* Clear the memory and set it to the default memory value
* @example clear()
*/
public async clear(): Promise<void> {
if (!this.isFromAnotherSkill) {
await this.write(this.defaultMemory as T)
} else {
throw new Error(
`You cannot clear the memory "${this.name}" as it belongs to another skill`
)
}
}
/**
* Read the memory
* @example read()
*/
public async read(): Promise<T> {
if (this.isFromAnotherSkill && !fs.existsSync(this.memoryPath)) {
throw new Error(
`You cannot read the memory "${this.name}" as it belongs to another skill which haven't written to this memory yet`
)
}
try {
if (!fs.existsSync(this.memoryPath)) {
await this.clear()
}
return JSON.parse(await fs.promises.readFile(this.memoryPath, 'utf-8'))
} catch (e) {
console.error(`Error while reading memory for "${this.name}":`, e)
throw e
}
}
/**
* Write the memory
* @param memory The memory to write
* @example write({ foo: 'bar' }) // { foo: 'bar' }
*/
public async write(memory: T): Promise<T> {
if (!this.isFromAnotherSkill) {
try {
await fs.promises.writeFile(
this.memoryPath,
JSON.stringify(memory, null, 2)
)
return memory
} catch (e) {
console.error(`Error while writing memory for "${this.name}":`, e)
throw e
}
} else {
throw new Error(
`You cannot write into the memory "${this.name}" as it belongs to another skill`
)
}
}
}
+147
View File
@@ -0,0 +1,147 @@
import dns from 'node:dns'
import type { AxiosInstance } from 'axios'
import axios from 'axios'
import { LEON_VERSION, NODEJS_BRIDGE_VERSION } from '@bridge/constants'
interface NetworkOptions {
/** `baseURL` will be prepended to `url`. It can be convenient to set `baseURL` for an instance of `Network` to pass relative URLs. */
baseURL?: string
}
interface NetworkRequestOptions {
/** Server URL that will be used for the request. */
url: string
/** Request method to be used when making the request. */
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
/** Data to be sent as the request body. */
data?: Record<string, unknown>
/** Custom headers to be sent. */
headers?: Record<string, string>
}
interface NetworkResponse<ResponseData> {
/** Data provided by the server. */
data: ResponseData
/** HTTP status code from the server response. */
statusCode: number
/** Options that was provided for the request. */
options: NetworkRequestOptions & NetworkOptions
}
export class NetworkError<ResponseErrorData = unknown> extends Error {
public readonly response: NetworkResponse<ResponseErrorData>
public constructor(response: NetworkResponse<ResponseErrorData>) {
super(`[NetworkError]: ${response.statusCode} ${response.data}`)
this.response = response
Object.setPrototypeOf(this, NetworkError.prototype)
}
}
export class Network {
private readonly options: NetworkOptions
private axios: AxiosInstance
public constructor(options: NetworkOptions = {}) {
this.options = options
this.axios = axios.create({
baseURL: this.options.baseURL
})
}
/**
* Send HTTP request
* @param options Request options
* @example request({ url: '/send', method: 'POST', data: { message: 'Hi' } })
*/
public async request<ResponseData = unknown, ResponseErrorData = unknown>(
options: NetworkRequestOptions
): Promise<NetworkResponse<ResponseData>> {
try {
const response = await this.axios.request<string>({
url: options.url,
method: options.method.toLowerCase(),
data: options.data,
transformResponse: (data) => {
return data
},
headers: {
'User-Agent': `Leon Personal Assistant ${LEON_VERSION} - Node.js Bridge ${NODEJS_BRIDGE_VERSION}`,
...options.headers
}
})
let data = {} as ResponseData
try {
data = JSON.parse(response.data)
} catch {
data = response.data as ResponseData
}
return {
data,
statusCode: response.status,
options: {
...this.options,
...options
}
}
} catch (error) {
let statusCode = 500
let dataRawText = ''
if (axios.isAxiosError(error)) {
dataRawText = error?.response?.data ?? ''
statusCode = error?.response?.status ?? 500
}
let data: ResponseErrorData
try {
data = JSON.parse(dataRawText)
} catch {
data = dataRawText as ResponseErrorData
}
throw new NetworkError<ResponseErrorData>({
data,
statusCode,
options: {
...this.options,
...options
}
})
}
}
/**
* Check if error is a network error
* @param error Error to check
* @example isNetworkError(error) // false
*/
public isNetworkError<ResponseErrorData = unknown>(
error: unknown
): error is NetworkError<ResponseErrorData> {
return error instanceof NetworkError
}
/**
* Verify whether there is an Internet connectivity
* @example isNetworkAvailable() // true
*/
public async isNetworkAvailable(): Promise<boolean> {
try {
await dns.promises.resolve('getleon.ai')
return true
} catch {
return false
}
}
}
@@ -0,0 +1 @@
export { default } from 'lodash'
+125
View File
@@ -0,0 +1,125 @@
import path from 'node:path'
import fs from 'node:fs'
import { SKILL_PATH } from '@bridge/constants'
export class Settings<T extends Record<string, unknown>> {
private readonly settingsPath: string
private readonly settingsSamplePath: string
public constructor() {
this.settingsPath = path.join(SKILL_PATH, 'src', 'settings.json')
this.settingsSamplePath = path.join(
SKILL_PATH,
'src',
'settings.sample.json'
)
}
/**
* Check if a setting is already set
* @param key The key to verify whether its value is set
* @returns isSettingSet('apiKey') // true
*/
public async isSettingSet(key: string): Promise<boolean> {
const settingsSample = await this.getSettingsSample()
const settings = await this.get()
return (
!!settings[key] &&
JSON.stringify(settings[key]) !== JSON.stringify(settingsSample[key])
)
}
/**
* Clear the settings and set it to the default settings.sample.json file
* @example clear()
*/
public async clear(): Promise<void> {
const settingsSample = await this.getSettingsSample()
await this.set(settingsSample)
}
private async getSettingsSample(): Promise<T> {
try {
return JSON.parse(
await fs.promises.readFile(this.settingsSamplePath, 'utf8')
)
} catch (e) {
console.error(
`Error while reading settings sample at "${this.settingsSamplePath}":`,
e
)
throw e
}
}
/**
* Get the settings
* @param key The key of the setting to get
* @example get('API_KEY') // 'value'
* @example get() // { API_KEY: 'value' }
*/
public async get<Key extends keyof T>(key: Key): Promise<T[Key]>
public async get(): Promise<T>
public async get<Key extends keyof T>(key?: Key): Promise<T | T[Key]> {
try {
if (!fs.existsSync(this.settingsPath)) {
await this.clear()
}
const settings = JSON.parse(
await fs.promises.readFile(this.settingsPath, 'utf8')
)
if (key != null) {
return settings[key]
}
return settings
} catch (e) {
console.error(
`Error while reading settings at "${this.settingsPath}":`,
e
)
throw e
}
}
/**
* Set the settings
* @param key The key of the setting to set
* @param value The value of the setting to set
* @example set({ API_KEY: 'value' }) // { API_KEY: 'value' }
*/
public async set<Key extends keyof T>(key: Key, value: T[Key]): Promise<T>
public async set(settings: T): Promise<T>
public async set<Key extends keyof T>(
keyOrSettings: Key | T,
value?: T[Key]
): Promise<T> {
try {
const settings = await this.get()
const newSettings =
typeof keyOrSettings === 'object'
? keyOrSettings
: { ...settings, [keyOrSettings]: value }
await fs.promises.writeFile(
this.settingsPath,
JSON.stringify(newSettings, null, 2)
)
return newSettings
} catch (e) {
console.error(
`Error while writing settings at "${this.settingsPath}":`,
e
)
throw e
}
}
}
+37
View File
@@ -0,0 +1,37 @@
/**
* Action types
*/
import type {
ActionParams,
IntentObject,
SkillAnswerCoreData,
SkillAnswerOutput
} from '@/core/brain/types'
import type { SkillAnswerConfigSchema } from '@/schemas/skill-schemas'
export type { ActionParams, IntentObject }
export * from '@/core/nlp/types'
export type ActionFunction = (params: ActionParams) => Promise<void>
/**
* Answer types
*/
export interface Answer {
key?: string
widget?: unknown // TODO
data?: AnswerData
core?: SkillAnswerCoreData
}
export interface TextAnswer extends Answer {
key: string
}
export interface WidgetAnswer extends Answer {
widget: unknown
key?: string
}
export type AnswerData = Record<string, string | number> | null
export type AnswerInput = TextAnswer | WidgetAnswer
export type AnswerOutput = SkillAnswerOutput
export type AnswerConfig = SkillAnswerConfigSchema
+9
View File
@@ -0,0 +1,9 @@
export abstract class Widget<T> {
public readonly type: string
public readonly options: T
protected constructor(options: T) {
this.type = this.constructor.name
this.options = options
}
}
+1
View File
@@ -0,0 +1 @@
export const VERSION = '1.1.0'
+24
View File
@@ -0,0 +1,24 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/bin",
"rootDir": "../../",
"baseUrl": ".",
"paths": {
"@@/*": ["../../*"],
"@/*": ["../../server/src/*"],
"@server/*": ["../../server/src/*"],
"@bridge/*": ["./src/*"],
"@sdk/*": ["./src/sdk/*"]
},
"exactOptionalPropertyTypes": false,
"declaration": true
},
"ts-node": {
"swc": true,
"require": ["tsconfig-paths/register"],
"files": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
-2
View File
@@ -11,6 +11,4 @@ setuptools = "*"
wheel = "*"
cx-freeze = "==6.11.1"
requests = "==2.28.1"
pytube = "==9.5.0"
tinydb = "==4.7.0"
beautifulsoup4 = "==4.7.1"
+30
View File
@@ -0,0 +1,30 @@
import sys
import json
import os
import version
INTENT_OBJ_FILE_PATH = sys.argv[1]
with open(INTENT_OBJ_FILE_PATH, 'r') as f:
INTENT_OBJECT = json.load(f)
SKILLS_ROOT_PATH = os.path.join(
os.getcwd(),
'skills'
)
SKILL_PATH = os.path.join(
SKILLS_ROOT_PATH,
INTENT_OBJECT['domain'],
INTENT_OBJECT['skill']
)
SKILLS_PATH = SKILLS_ROOT_PATH
with open(os.path.join(SKILL_PATH, 'config', INTENT_OBJECT['extra_context_data']['lang'] + '.json'), 'r') as f:
SKILL_CONFIG = json.load(f)
LEON_VERSION = os.getenv('npm_package_version')
PYTHON_BRIDGE_VERSION = version.__version__
+34 -27
View File
@@ -1,37 +1,44 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import utils
import sys
from traceback import print_exc
from sys import path
from json import dumps, loads
from importlib import import_module
from constants import INTENT_OBJECT
def main():
"""Dynamically import skills related to the args and print the output"""
params = {
'lang': INTENT_OBJECT['lang'],
'utterance': INTENT_OBJECT['utterance'],
'current_entities': INTENT_OBJECT['current_entities'],
'entities': INTENT_OBJECT['entities'],
'current_resolvers': INTENT_OBJECT['current_resolvers'],
'resolvers': INTENT_OBJECT['resolvers'],
'slots': INTENT_OBJECT['slots'],
'extra_context_data': INTENT_OBJECT['extra_context_data']
}
path.append('.')
try:
sys.path.append('.')
intent_obj = utils.get_intent_obj()
skill_action_module = import_module(
'skills.'
+ INTENT_OBJECT['domain']
+ '.'
+ INTENT_OBJECT['skill']
+ '.src.actions.'
+ INTENT_OBJECT['action']
)
skill = import_module('skills.' + intent_obj['domain'] + '.' + intent_obj['skill'] + '.src.actions.' + intent_obj['action'])
getattr(skill_action_module, 'run')(params)
except Exception as e:
print(f"Error while running {INTENT_OBJECT['skill']} skill {INTENT_OBJECT['action']} action: {e}")
print_exc()
params = {
'lang': intent_obj['lang'],
'utterance': intent_obj['utterance'],
'current_entities': intent_obj['current_entities'],
'entities': intent_obj['entities'],
'current_resolvers': intent_obj['current_resolvers'],
'resolvers': intent_obj['resolvers'],
'slots': intent_obj['slots']
}
return getattr(skill, intent_obj['action'])(params)
if __name__ == '__main__':
try:
raise main()
except Exception as e:
# Print full traceback error report if skills triggers an error from the call stack
if 'exceptions must derive from BaseException' not in str(e):
print_exc()
try:
raise main()
except Exception as e:
# Print full traceback error report if skills triggers an error from the call stack
if 'exceptions must derive from BaseException' not in str(e):
print_exc()
+9
View File
@@ -0,0 +1,9 @@
from ..widget import Widget
# TODO: contains the button API. rendering engine <-> SDK
class Button(Widget):
def __init__(self, options):
super().__init__(options)
+92
View File
@@ -0,0 +1,92 @@
import random
import sys
from typing import Union
from time import sleep
import json
from .types import AnswerInput, AnswerData, AnswerConfig
from ..constants import SKILL_CONFIG, INTENT_OBJECT
class Leon:
instance: 'Leon' = None
def __init__(self) -> None:
if not Leon.instance:
Leon.instance = self
@staticmethod
def set_answer_data(answer_key: str, data: Union[AnswerData, None] = None) -> Union[str, AnswerConfig]:
"""
Apply data to the answer
:param answer_key: The answer key
:param data: The data to apply
"""
try:
# In case the answer key is a raw answer
if SKILL_CONFIG.get('answers') is None or SKILL_CONFIG['answers'].get(answer_key) is None:
return answer_key
answers = SKILL_CONFIG['answers'].get(answer_key, '')
if isinstance(answers, list):
answer = answers[random.randrange(len(answers))]
else:
answer = answers
if data:
for key, value in data.items():
# In case the answer needs speech and text differentiation
if not isinstance(answer, str) and answer.get('text'):
answer['text'] = answer['text'].replace('%{}%'.format(key), str(value))
answer['speech'] = answer['speech'].replace('%{}%'.format(key), str(value))
else:
answer = answer.replace('%{}%'.format(key), str(value))
if SKILL_CONFIG.get('variables'):
for key, value in SKILL_CONFIG['variables'].items():
# In case the answer needs speech and text differentiation
if not isinstance(answer, str) and answer.get('text'):
answer['text'] = answer['text'].replace('%{}%'.format(key), str(value))
answer['speech'] = answer['speech'].replace('%{}%'.format(key), str(value))
else:
answer = answer.replace('%{}%'.format(key), str(value))
return answer
except Exception as e:
print('Error while setting answer data:', e)
raise e
def answer(self, answer_input: AnswerInput) -> None:
"""
Send an answer to the core
:param answer_input: The answer input
"""
try:
key = answer_input.get('key')
output = {
'output': {
'codes': 'widget' if answer_input.get('widget') and not answer_input.get('key') else answer_input.get('key'),
'answer': self.set_answer_data(key, answer_input.get('data')) if key is not None else '',
'core': answer_input.get('core')
}
}
if answer_input.get('widget'):
output['output']['widget'] = answer_input['widget'].__dict__
answer_object = {
**INTENT_OBJECT,
**output
}
# "Temporize" for the data buffer output on the core
sleep(0.1)
sys.stdout.write(json.dumps(answer_object))
sys.stdout.flush()
except Exception as e:
print('Error while creating answer:', e)
leon = Leon()
+76
View File
@@ -0,0 +1,76 @@
import json
import os
from typing import TypedDict, Any
from ..constants import SKILL_PATH, SKILLS_PATH
class MemoryOptions(TypedDict, total=False):
name: str
default_memory: Any
class Memory:
def __init__(self, options: MemoryOptions):
self.name = options['name']
self.default_memory = options['default_memory'] if 'default_memory' in options else None
self.memory_path = self.memory_path = os.path.join(
SKILL_PATH,
'memory',
f'{self.name}.json'
)
self.__is_from_another_skill = False
if ':' in self.name and self.name.count(':') == 2:
self.__is_from_another_skill = True
domain_name, skill_name, memory_name = self.name.split(':')
self.memory_path = os.path.join(
SKILLS_PATH,
domain_name,
skill_name,
'memory',
memory_name + '.json'
)
def clear(self) -> None:
"""
Clear the memory and set it to the default memory value
"""
if not self.__is_from_another_skill:
self.write(self.default_memory)
else:
raise ValueError(f'You cannot clear the memory "{self.name}" as it belongs to another skill')
def read(self):
"""
Read the memory
"""
if self.__is_from_another_skill and not os.path.exists(self.memory_path):
raise ValueError(f'You cannot read the memory "{self.name}" as it belongs to another skill which hasn\'t written to this memory yet')
try:
if not os.path.exists(self.memory_path):
self.clear()
with open(self.memory_path, 'r') as f:
return json.load(f)
except Exception as e:
print(f'Error while reading memory for "{self.name}": {e}')
raise e
def write(self, memory):
"""
Write the memory
:param memory: The memory to write
"""
if not self.__is_from_another_skill:
try:
with open(self.memory_path, 'w') as f:
json.dump(memory, f, indent=2)
return memory
except Exception as e:
print(f'Error while writing memory for "{self.name}": {e}')
raise e
else:
raise ValueError(f'You cannot write into the memory "{self.name}" as it belongs to another skill')
+92
View File
@@ -0,0 +1,92 @@
import requests
import socket
from typing import Any, Dict, TypedDict, Union, Literal, Optional
from ..constants import LEON_VERSION, PYTHON_BRIDGE_VERSION
class NetworkOptions(TypedDict, total=False):
base_url: Optional[str]
class NetworkResponse(TypedDict):
data: Any
status_code: int
options: Dict[str, Any]
class NetworkError(Exception):
def __init__(self, response: NetworkResponse) -> None:
self.response = response
super().__init__(f"[NetworkError]: {response['status_code']} {response['data']}")
class NetworkRequestOptions(TypedDict, total=False):
url: str
method: Union[Literal['GET'], Literal['POST'], Literal['PUT'], Literal['PATCH'], Literal['DELETE']]
data: Dict[str, Any]
headers: Dict[str, str]
class Network:
def __init__(self, options: NetworkOptions = {'base_url': None}) -> None:
self.options = options
def request(self, options: NetworkRequestOptions) -> NetworkResponse:
try:
url = options['url']
if self.options['base_url'] is not None:
url = self.options['base_url'] + url
method = options['method']
data = options.get('data', {})
headers = options.get('headers', {})
response = requests.request(
method,
url,
json=data,
headers={
'User-Agent': f"Leon Personal Assistant {LEON_VERSION} - Python Bridge {PYTHON_BRIDGE_VERSION}",
**headers
}
)
data = {}
try:
data = response.json()
except Exception:
data = response.text
network_response: NetworkResponse = {
'data': data,
'status_code': response.status_code,
'options': {**self.options, **options}
}
if response.ok:
return network_response
else:
raise NetworkError(network_response)
except requests.exceptions.RequestException as error:
data = {}
try:
data = error.response.json()
except Exception:
data = error.response.text
raise NetworkError({
'data': data,
'status_code': error.response.status_code,
'options': {**self.options, **options}
}) from error
def is_network_error(self, error: Exception) -> bool:
return isinstance(error, NetworkError)
def is_network_available(self) -> bool:
try:
socket.gethostbyname('getleon.ai')
return True
except socket.error:
return False
+91
View File
@@ -0,0 +1,91 @@
import json
import os
from os import path
from typing import Union, Any, overload
from ..constants import SKILL_PATH
class Settings:
def __init__(self):
self.settings_path = path.join(SKILL_PATH, 'src', 'settings.json')
self.settings_sample_path = path.join(SKILL_PATH, 'src', 'settings.sample.json')
def is_setting_set(self, key: str) -> bool:
"""
Check if a setting is already set
:param key: The key to verify whether its value is set
"""
settings_sample = self.get_settings_sample()
settings = self.get()
return key in settings and json.dumps(settings[key]) != json.dumps(settings_sample[key])
def clear(self) -> None:
"""
Clear the settings and set it to the default settings.sample.json file
"""
settings_sample = self.get_settings_sample()
self.set(settings_sample)
def get_settings_sample(self) -> dict[str, Any]:
try:
with open(self.settings_sample_path, 'r') as file:
return json.load(file)
except Exception as e:
print(f"Error while reading settings sample at '{self.settings_sample_path}': {e}")
raise e
@overload
def get(self, key: str) -> Any: ...
@overload
def get(self, key: None = None) -> dict[str, Any]: ...
def get(self, key: Union[str, None] = None) -> Union[dict[str, Any], Any]:
"""
Get the settings
:param key: The key to get from the settings
"""
try:
if not os.path.exists(self.settings_path):
self.clear()
with open(self.settings_path, 'r') as file:
settings = json.load(file)
if key is not None:
return settings[key]
return settings
except Exception as e:
print(f"Error while reading settings at '{self.settings_path}': {e}")
raise e
@overload
def set(self, key_or_settings: dict[str, Any]) -> dict[str, Any]: ...
@overload
def set(self, key_or_settings: str, value: Any) -> dict[str, Any]: ...
def set(self, key_or_settings: Union[str, dict[str, Any]], value: Any = None) -> dict[str, Any]:
"""
Set the settings
:param key_or_settings: The key to set or the settings to set
:param value: The value to set
"""
try:
settings = self.get()
if isinstance(key_or_settings, dict):
new_settings = key_or_settings
else:
new_settings = {**settings, key_or_settings: value}
with open(self.settings_path, 'w') as file:
json.dump(new_settings, file, indent=2)
return new_settings
except Exception as e:
print(f"Error while writing settings at '{self.settings_path}': {e}")
raise e
+49
View File
@@ -0,0 +1,49 @@
from typing import Dict, Any, Optional, Union, Literal, TypedDict
class NLUResultSentiment(TypedDict):
vote: Optional[Union[Literal['positive'], Literal['neutral'], Literal['negative']]]
score: Optional[float]
class ExtraContextData(TypedDict):
lang: str
sentiment: str
date: str
time: str
timestamp: int
date_time: str
week_day: str
class ActionParams(TypedDict):
lang: str
utterance: str
current_entities: list[Any]
entities: list[Any]
current_resolvers: list[Any]
resolvers: list[Any]
slots: Dict[str, Any]
extra_context_data: ExtraContextData
AnswerData = Optional[Union[Dict[str, Union[str, int]], None]]
class Answer(TypedDict):
key: Optional[str]
widget: Optional[Any]
data: Optional[AnswerData]
core: Optional[Dict[str, Any]]
class AnswerInput(TypedDict, total=False):
key: Optional[str]
widget: Any
data: Optional[AnswerData]
core: Dict[str, Any]
class AnswerConfig(TypedDict):
text: str
speech: str
+4
View File
@@ -0,0 +1,4 @@
class Widget:
def __init__(self, options):
self.type = type(self).__name__
self.options = options
+11 -8
View File
@@ -1,21 +1,24 @@
from cx_Freeze import setup, Executable
import requests.certs
from version import __version__
options = {
'build_exe': {
# Add common dependencies for skills
# Add common dependencies for skills
'includes': [
'bs4',
'pytube'
]
}
'bs4',
'requests',
'timeit'
],
'include_files': [(requests.certs.where(), 'cacert.pem')]
}
}
executables = [
Executable(
script='bridges/python/src/main.py',
target_name='leon-python-bridge'
Executable(
script='bridges/python/src/main.py',
target_name='leon-python-bridge'
)
]
-148
View File
@@ -1,148 +0,0 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from json import loads, dumps
from pathlib import Path
from random import choice
from vars import useragent
from tinydb import TinyDB, Query, table, operations
from time import sleep
import sys
import os
import sqlite3
import requests
import re
dirname = os.path.dirname(os.path.realpath(__file__))
intent_object_path = sys.argv[1]
codes = []
intent_obj_file = open(intent_object_path, 'r', encoding = 'utf8')
intent_obj = loads(intent_obj_file.read())
intent_obj_file.close()
def get_intent_obj():
"""Return intent object"""
return intent_obj
def translate(key, dict = { }):
"""Pickup the language file according to the cmd arg
and return the value according to the params"""
# "Temporize" for the data buffer ouput on the core
sleep(0.1)
output = ''
variables = { }
file = open(os.path.join(os.getcwd(), 'skills', intent_obj['domain'], intent_obj['skill'], 'config', intent_obj['lang'] + '.json'), 'r', encoding = 'utf8')
obj = loads(file.read())
file.close()
# In case the key is a raw answer
if key not in obj['answers']:
return key
prop = obj['answers'][key]
if 'variables' in obj:
variables = obj['variables']
if isinstance(prop, list):
output = choice(prop)
else:
output = prop
if dict:
for key in dict:
output = output.replace('%' + key + '%', str(dict[key]))
if variables:
for key in variables:
output = output.replace('%' + key + '%', str(variables[key]))
return output
def output(type, content = '', core = { }):
"""Communicate with the core"""
if isinstance(content, dict):
speech = translate(content['key'], content['data'])
codes.append(content['key'])
else:
content = str(content)
speech = translate(content)
codes.append(content)
print(dumps({
'domain': intent_obj['domain'],
'skill': intent_obj['skill'],
'action': intent_obj['action'],
'lang': intent_obj['lang'],
'utterance': intent_obj['utterance'],
'entities': intent_obj['entities'],
'slots': intent_obj['slots'],
'output': {
'type': type,
'codes': codes,
'speech': speech,
'core': core,
'options': config('options')
}
}))
if (type == 'inter'):
sys.stdout.flush()
def http(method, url, headers = None):
"""Send HTTP request with the Leon user agent"""
session = requests.Session()
session.headers.update({ 'User-Agent': useragent, 'Cache-Control': 'no-cache' })
if headers != None:
session.headers.update(headers)
return session.request(method, url)
def config(key):
"""Get a skill configuration value"""
file = open(os.path.join(os.getcwd(), 'skills', intent_obj['domain'], intent_obj['skill'], 'src/config.json'), 'r', encoding = 'utf8')
obj = loads(file.read())
file.close()
return obj['configurations'][key]
def create_dl_dir():
"""Create the downloads folder of a current skill"""
dl_dir = os.path.join(os.getcwd(), 'downloads')
# dl_dir = os.path.dirname(os.path.realpath(__file__)) + '/../../../../downloads/'
skill_dl_dir = os.path.join(dl_dir, intent_obj['domain'], intent_obj['skill'])
Path(skill_dl_dir).mkdir(parents = True, exist_ok = True)
return skill_dl_dir
def db(db_type = 'tinydb'):
"""Create a new dedicated database
for a specific skill"""
if db_type == 'tinydb':
ext = '.json' if os.environ.get('LEON_NODE_ENV') != 'testing' else '.spec.json'
db = TinyDB(os.path.join(os.getcwd(), 'skills', intent_obj['domain'], intent_obj['skill'], 'memory/db' + ext))
return {
'db': db,
'query': Query,
'table': table,
'operations': operations
}
def get_table(slug):
"""Get a table from a specific skill"""
domain, skill, table = slug.split('.')
ext = '.json' if os.environ.get('LEON_NODE_ENV') != 'testing' else '.spec.json'
db = TinyDB(os.path.join(os.getcwd(), 'skills', domain, skill, 'memory/db' + ext))
return db.table(table)
-12
View File
@@ -1,12 +0,0 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import os
from json import loads
packagejsonfile = open(os.path.join(os.getcwd(), 'package.json'), 'r', encoding = 'utf8')
packagejson = loads(packagejsonfile.read())
packagejsonfile.close()
useragent = 'Leon-Personal-Assistant/' + packagejson['version']
+1 -1
View File
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.2.0'
+1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../schemas/voice-config-schemas/amazon.json",
"credentials": {
"accessKeyId": "",
"secretAccessKey": ""
+7 -6
View File
@@ -1,12 +1,13 @@
{
"type": "",
"$schema": "../../../schemas/voice-config-schemas/google-cloud.json",
"type": "service_account",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_email": "example@iam.gserviceaccount.com",
"client_id": "",
"auth_uri": "",
"token_uri": "",
"auth_provider_x509_cert_url": "",
"client_x509_cert_url": ""
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/"
}
+2 -1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../schemas/voice-config-schemas/watson-stt.json",
"apikey": "",
"url": ""
"url": "https://stream.watsonplatform.net/speech-to-text/api"
}
+2 -1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../schemas/voice-config-schemas/watson-tts.json",
"apikey": "",
"url": ""
"url": "https://stream.watsonplatform.net/text-to-speech/api"
}
+6 -12
View File
@@ -1,21 +1,15 @@
{
"$schema": "../../../schemas/global-data/global-answers.json",
"answers": {
"success": {},
"errors": {
"not_found": "Sorry, it seems I cannot find that",
"nlu": "It might come from my natural language understanding, the error returned is: \"%error%\""
},
"synchronizer": {
"syncing_direct": "I will now synchronize the downloaded content on your current device. Don't worry, I will let you know once I'm done",
"synced_direct": "The new content has been synchronized on your device",
"syncing_google_drive": "I will now synchronize the downloaded content on Google Drive. Don't worry, I will let you know once I'm done",
"synced_google_drive": "The new content is now available on Google Drive"
"not_found": "Sorry, it seems I cannot find that"
},
"random_errors": [
"Sorry, there is a problem with my system",
"Sorry, I don't work correctly",
"Sorry, you need to fix me",
"Sorry, I cannot do that because I'm broken"
"Sorry, there is a problem with my system. Please check my logs for further details",
"Sorry, I don't work correctly. Please look at my logs for more information",
"Sorry, you need to fix me. Please take a look at my logs for further information",
"Sorry, I cannot do that because I'm broken. Please check my logs for further details"
],
"random_skill_errors": [
"Sorry, it seems I have a problem with the \"%skill_name%\" skill from the \"%domain_name%\" domain",
+1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-entity.json",
"options": {
"red": {
"synonyms": ["red"],
+1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-entity.json",
"options": {
"LOW": {
"synonyms": ["low"]
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-entity.json",
"options": {
"Alexa": {
"synonyms": ["Alexa"],
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-resolver.json",
"name": "affirmation_denial",
"intents": {
"affirmation": {
@@ -22,7 +23,14 @@
"That works",
"Go ahead",
"Why not",
"Please"
"Please",
"Absolutely",
"Precisely",
"Spot on",
"Undoubtedly",
"Certainly",
"Without a doubt",
"Definitely"
],
"value": true
},
@@ -36,7 +44,10 @@
"No thanks",
"No I'm fine",
"Hell no",
"Please do not"
"Please do not",
"I disagree",
"Negative",
"Not at all"
],
"value": false
}
+5 -10
View File
@@ -1,21 +1,16 @@
{
"$schema": "../../../schemas/global-data/global-answers.json",
"answers": {
"success": {},
"errors": {
"not_found": "Désolé, il semblerait que je n'arrive pas à trouver ça",
"nlu": "L'erreur semble provenir de ma compréhension de langage naturel. Voici plus de détails au sujet de cette dernière : \"%error%\""
},
"synchronizer": {
"syncing_direct": "Je vais maintenant synchroniser le contenu téléchargé sur votre appareil actuel. Ne vous inquiétez pas, je vous préviendrai lorsque j'aurai terminé",
"synced_direct": "Le nouveau contenu a été synchronisé sur votre appareil",
"syncing_google_drive": "Je vais maintenant synchroniser le contenu téléchargé sur Google Drive. Ne vous inquiétez pas, je vous préviendrai lorsque j'aurai terminé",
"synced_google_drive": "Le nouveau contenu est maintenant disponible sur Google Drive"
},
"random_errors": [
"Désolé, il y a un problème avec mon système",
"Désolé, je ne fonctionne pas correctement",
"Désolé, vous devez me réparer",
"Désolé, je ne peux aboutir à votre demande parce que je suis cassé"
"Désolé, il y a un problème avec mon système. Veuillez consulter mes logs pour plus de détails",
"Désolé, je ne fonctionne pas correctement. Merci de regarder mes logs pour plus d'information",
"Désolé, vous devez me réparer. Veuillez vérifier mes logs pour en savoir plus",
"Désolé, je ne peux aboutir à votre demande parce que je suis cassé. Regardez mes logs pour plus de détails"
],
"random_skill_errors": [
"Désolé, il semblerait y avoir un problème avec le skill \"%skill_name%\" du domaine \"%domain_name%\"",
+1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-entity.json",
"options": {
"rouge": {
"synonyms": ["rouge"],
+1
View File
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-entity.json",
"options": {
"bas": {
"synonyms": ["bas", "basse"],
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-entity.json",
"options": {
"Alexa": {
"synonyms": ["Alexa"],
@@ -1,4 +1,5 @@
{
"$schema": "../../../../schemas/global-data/global-resolver.json",
"name": "affirmation_denial",
"intents": {
"affirmation": {
+157 -122
View File
@@ -1,122 +1,5 @@
{
"endpoints": [
{
"method": "POST",
"route": "/api/action/games/akinator/choose_thematic",
"params": ["thematic"],
"entitiesType": "trim"
},
{
"method": "GET",
"route": "/api/action/games/akinator/setup",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/akinator/guess",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/akinator/retry",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/setup",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/guess",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/replay",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/start",
"params": []
},
{
"method": "POST",
"route": "/api/action/games/rochambeau/play",
"params": ["handsign"],
"entitiesType": "trim"
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/rematch",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/color/favorite_color",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/color/why",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/color/color_hexadecimal",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/good_bye/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/greeting/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/introduction/introduce_leon",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/introduction/gather_basic_info",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/introduction/remember",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/joke/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/meaning_of_life/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/partner_assistant/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/random_number/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/welcome/run",
"params": []
},
{
"method": "POST",
"route": "/api/action/news/github_trends/run",
@@ -185,6 +68,163 @@
"route": "/api/action/social_communication/mbti/quiz",
"params": []
},
{
"method": "POST",
"route": "/api/action/games/akinator/choose_thematic",
"params": ["thematic"],
"entitiesType": "trim"
},
{
"method": "GET",
"route": "/api/action/games/akinator/setup",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/akinator/guess",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/akinator/retry",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/setup",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/guess",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/guess_the_number/replay",
"params": []
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/start",
"params": []
},
{
"method": "POST",
"route": "/api/action/games/rochambeau/play",
"params": ["handsign"],
"entitiesType": "trim"
},
{
"method": "GET",
"route": "/api/action/games/rochambeau/rematch",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/age/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/color/favorite_color",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/color/why",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/color/color_hexadecimal",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/good_bye/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/greeting/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/help/help",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/introduction/introduce_leon",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/introduction/gather_basic_info",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/introduction/remember",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/joke/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/meaning_of_life/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/partner_assistant/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/random_number/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/leon/welcome/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/date_time/current_date_time",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/date_time/current_date",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/date_time/current_time",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/date_time/current_week_number",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/date_time/days_countdown",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/date_time/current_date_time_with_time_zone",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/have_i_been_pwned/run",
@@ -200,11 +240,6 @@
"method": "GET",
"route": "/api/action/utilities/speed_test/run",
"params": []
},
{
"method": "GET",
"route": "/api/action/utilities/youtube_downloader/run",
"params": []
}
]
}
+2 -2
View File
@@ -12,6 +12,6 @@ services:
tty: true
command: 'npm run dev:server && npm run dev:app'
volumes:
- './:/app'
- '/app/node_modules'
- './:/home/docker/leon'
- '/home/docker/leon/node_modules'
network_mode: 'host'
+11 -10
View File
@@ -3,7 +3,7 @@
* You can consider to run this file on a different hardware
*/
const request = require('superagent')
const axios = require('axios')
const record = require('node-record-lpcm16')
const { Detector, Models } = require('@bugsounet/snowboy')
const { io } = require('socket.io-client')
@@ -21,15 +21,10 @@ socket.on('connect', () => {
console.log('Connected to the server')
console.log('Waiting for hotword...')
})
;(async () => {
try {
await axios.get(`${url}/api/v1/info`)
request.get(`${url}/api/v1/info`).end((err, res) => {
if (err || !res.ok) {
if (!err.response) {
console.error(`Failed to reach the server: ${err}`)
} else {
console.error(err.response.error.message)
}
} else {
const models = new Models()
models.add({
@@ -78,5 +73,11 @@ request.get(`${url}/api/v1/info`).end((err, res) => {
})
mic.pipe(detector)
} catch (e) {
if (!e.response) {
console.error(`Failed to reach the server: ${e}`)
} else {
console.error(e)
}
}
})
})()
-27191
View File
File diff suppressed because it is too large Load Diff
+82 -58
View File
@@ -1,6 +1,6 @@
{
"name": "leon",
"version": "1.0.0-beta.8+dev",
"version": "1.0.0-beta.10+dev",
"description": "Server, skills and web app of the Leon personal assistant",
"author": {
"name": "Louis Grenard",
@@ -40,89 +40,113 @@
"postinstall": "ts-node scripts/setup/setup.js",
"dev:app": "vite --config app/vite.config.js",
"dev:server": "npm run train && npm run generate:skills-endpoints && cross-env LEON_NODE_ENV=development tsc-watch --noClear --onSuccess \"nodemon\"",
"dev:server:no-lint": "npm run train && npm run generate:skills-endpoints && cross-env LEON_NODE_ENV=development \"nodemon\"",
"wake": "cross-env LEON_HOST=http://localhost LEON_PORT=1337 node hotword/index.js",
"delete-dist:server": "shx rm -rf ./server/dist",
"clean:python-deps": "shx rm -rf ./bridges/python/src/.venv && npm run postinstall",
"prepare": "husky install",
"generate:skills-endpoints": "ts-node scripts/generate/run-generate-skills-endpoints.js",
"generate:http-api-key": "ts-node scripts/generate/run-generate-http-api-key.js",
"generate:json-schemas": "ts-node scripts/generate/run-generate-json-schemas.js",
"build": "npm run build:app && npm run build:server",
"build:app": "cross-env LEON_NODE_ENV=production ts-node scripts/app/run-build-app.js",
"build:server": "npm run delete-dist:server && npm run train && npm run generate:skills-endpoints && tsc && resolve-tspaths && shx rm -rf server/dist/core server/dist/package.json && shx mv -f server/dist/server/src/* server/dist && shx rm -rf server/dist/server && shx mkdir -p server/dist/tmp",
"build:server": "npm run delete-dist:server && npm run train && npm run generate:skills-endpoints && tsc --project tsconfig.json && resolve-tspaths && shx rm -rf server/dist/core server/dist/package.json && shx mv -f server/dist/server/src/* server/dist && shx rm -rf server/dist/server && shx mkdir -p server/dist/tmp",
"build:nodejs-bridge": "ts-node scripts/build-binaries.js nodejs-bridge",
"build:python-bridge": "ts-node scripts/build-binaries.js python-bridge",
"build:tcp-server": "ts-node scripts/build-binaries.js tcp-server",
"start:tcp-server": "cross-env PIPENV_PIPFILE=tcp_server/src/Pipfile pipenv run python tcp_server/src/main.py",
"start": "cross-env LEON_NODE_ENV=production node ./server/dist/index.js",
"start": "cross-env LEON_NODE_ENV=production node server/dist/pre-check.js && node server/dist/index.js",
"python-bridge": "cross-env PIPENV_PIPFILE=bridges/python/src/Pipfile pipenv run python bridges/python/src/main.py server/src/intent-object.sample.json",
"train": "ts-node scripts/train/run-train.js",
"prepare-release": "ts-node scripts/release/prepare-release.js",
"skill-package": "ts-node scripts/skill-package.js",
"pre-release:nodejs-bridge": "ts-node scripts/release/pre-release-binaries.js nodejs-bridge",
"pre-release:python-bridge": "ts-node scripts/release/pre-release-binaries.js python-bridge",
"pre-release:tcp-server": "ts-node scripts/release/pre-release-binaries.js tcp-server",
"check": "ts-node scripts/run-check.js",
"check": "ts-node scripts/check.js",
"docker:build": "docker build -t leon-ai/leon .",
"docker:run": "docker compose up",
"docker:dev": "docker compose --file=docker-compose.dev.yml up",
"docker:check": "docker run --rm --interactive leon-ai/leon npm run check"
},
"dependencies": {
"@aws-sdk/client-polly": "^3.18.0",
"@fastify/static": "^6.5.0",
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@ffprobe-installer/ffprobe": "^1.4.1",
"@google-cloud/speech": "^4.2.0",
"@google-cloud/text-to-speech": "^3.2.1",
"@nlpjs/builtin-microsoft": "^4.22.7",
"@nlpjs/core-loader": "^4.22.7",
"@nlpjs/lang-all": "^4.22.12",
"@nlpjs/nlp": "^4.22.17",
"archiver": "^5.3.1",
"async": "^3.2.0",
"cross-env": "^7.0.3",
"dayjs": "^1.11.5",
"dotenv": "^10.0.0",
"execa": "^5.0.0",
"fastify": "^4.5.3",
"fluent-ffmpeg": "^2.1.2",
"googleapis": "^67.1.1",
"ibm-watson": "^6.1.1",
"@aws-sdk/client-polly": "3.18.0",
"@fastify/static": "6.9.0",
"@ffmpeg-installer/ffmpeg": "1.1.0",
"@ffprobe-installer/ffprobe": "1.4.1",
"@google-cloud/speech": "4.2.0",
"@google-cloud/text-to-speech": "3.2.1",
"@nlpjs/builtin-microsoft": "4.22.7",
"@nlpjs/core-loader": "4.22.7",
"@nlpjs/lang-all": "4.22.12",
"@nlpjs/nlp": "4.22.17",
"@segment/ajv-human-errors": "2.1.2",
"@sinclair/typebox": "0.25.8",
"ajv": "8.11.0",
"ajv-formats": "2.1.1",
"archiver": "5.3.1",
"async": "3.2.4",
"axios": "1.1.2",
"cross-env": "7.0.3",
"dayjs": "1.11.5",
"dotenv": "10.0.0",
"execa": "5.0.0",
"extract-zip": "2.0.1",
"fastify": "4.15.0",
"fluent-ffmpeg": "2.1.2",
"getos": "3.2.1",
"googleapis": "67.1.1",
"ibm-watson": "6.1.1",
"node-wav": "0.0.2",
"pretty-bytes": "^5.6.0",
"socket.io": "^4.5.2",
"socket.io-client": "^4.5.2",
"stt": "^1.4.0",
"superagent": "^8.0.0",
"tree-kill": "^1.2.2"
"os-name": "4.0.1",
"pretty-bytes": "5.6.0",
"pretty-ms": "7.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"socket.io": "4.5.2",
"socket.io-client": "4.5.2",
"stt": "1.4.0",
"tree-kill": "1.2.2"
},
"devDependencies": {
"@nlpjs/utils": "^4.24.1",
"@swc/core": "^1.2.245",
"@tsconfig/node16-strictest": "^1.0.3",
"@nlpjs/utils": "4.24.1",
"@swc/core": "1.3.14",
"@tsconfig/node16-strictest": "1.0.4",
"@types/archiver": "5.3.2",
"@types/cli-spinner": "0.2.1",
"@types/node": "^18.7.13",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"cli-spinner": "^0.2.10",
"@types/fluent-ffmpeg": "2.1.20",
"@types/getos": "3.0.1",
"@types/node": "18.7.13",
"@types/node-wav": "0.0.0",
"@types/react": "18.2.6",
"@types/react-dom": "18.2.4",
"@typescript-eslint/eslint-plugin": "5.55.0",
"@typescript-eslint/parser": "5.55.0",
"@vercel/ncc": "0.36.1",
"@vitejs/plugin-react": "4.0.0",
"cli-spinner": "0.2.10",
"eslint": "8.22.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.1",
"eslint-plugin-import": "^2.26.0",
"eslint-config-prettier": "8.5.0",
"eslint-import-resolver-typescript": "3.5.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-unicorn": "43.0.2",
"git-changelog": "^2.0.0",
"husky": "^7.0.0",
"inquirer": "^8.1.0",
"jest": "^27.4.7",
"jest-canvas-mock": "^2.3.1",
"jest-extended": "^2.0.0",
"json": "^10.0.0",
"lint-staged": "^13.0.3",
"nodemon": "^2.0.19",
"prettier": "2.7.1",
"resolve-tspaths": "^0.7.4",
"semver": "^7.3.5",
"shx": "^0.3.3",
"ts-node": "^10.9.1",
"tsc-watch": "^5.0.3",
"tsconfig-paths": "^4.1.0",
"typescript": "^4.8.2",
"vite": "^3.0.9"
"git-changelog": "2.0.0",
"husky": "7.0.0",
"inquirer": "8.1.0",
"jest": "27.4.7",
"jest-canvas-mock": "2.3.1",
"jest-extended": "2.0.0",
"json": "10.0.0",
"lint-staged": "13.0.3",
"nodemon": "2.0.19",
"prettier": "2.8.7",
"resolve-tspaths": "0.8.8",
"semver": "7.3.5",
"shx": "0.3.3",
"ts-node": "10.9.1",
"tsc-watch": "6.0.0",
"tsconfig-paths": "4.1.2",
"typescript": "5.0.2",
"vite": "4.3.5"
}
}
@@ -0,0 +1,12 @@
{
"lang": "en",
"domain": "leon",
"skill": "age",
"action": "run",
"utterance": "How old are you?",
"slots": {},
"entities": [],
"current_entities": [],
"resolvers": [],
"current_resolvers": []
}
+80 -25
View File
@@ -9,14 +9,18 @@ import {
PYTHON_BRIDGE_SRC_PATH,
TCP_SERVER_SRC_PATH,
BINARIES_FOLDER_NAME,
NODEJS_BRIDGE_DIST_PATH,
PYTHON_BRIDGE_DIST_PATH,
TCP_SERVER_DIST_PATH,
NODEJS_BRIDGE_BIN_NAME,
PYTHON_BRIDGE_BIN_NAME,
TCP_SERVER_BIN_NAME
TCP_SERVER_BIN_NAME,
NODEJS_BRIDGE_ROOT_PATH
} from '@/constants'
import { OSTypes } from '@/types'
import { LogHelper } from '@/helpers/log-helper'
import { LoaderHelper } from '@/helpers/loader-helper'
import { OSHelper, OSTypes } from '@/helpers/os-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Build binaries for the given OS according to the given build target
@@ -28,8 +32,15 @@ import { OSHelper, OSTypes } from '@/helpers/os-helper'
const BUILD_TARGETS = new Map()
BUILD_TARGETS.set('nodejs-bridge', {
name: 'Node.js bridge',
needsPythonEnv: false,
distPath: NODEJS_BRIDGE_DIST_PATH,
archiveName: `${NODEJS_BRIDGE_BIN_NAME.split('.')[0]}.zip`
})
BUILD_TARGETS.set('python-bridge', {
name: 'Python bridge',
needsPythonEnv: true,
pipfilePath: path.join(PYTHON_BRIDGE_SRC_PATH, 'Pipfile'),
setupFilePath: path.join(PYTHON_BRIDGE_SRC_PATH, 'setup.py'),
distPath: PYTHON_BRIDGE_DIST_PATH,
@@ -38,6 +49,7 @@ BUILD_TARGETS.set('python-bridge', {
})
BUILD_TARGETS.set('tcp-server', {
name: 'TCP server',
needsPythonEnv: true,
pipfilePath: path.join(TCP_SERVER_SRC_PATH, 'Pipfile'),
setupFilePath: path.join(TCP_SERVER_SRC_PATH, 'setup.py'),
distPath: TCP_SERVER_DIST_PATH,
@@ -61,21 +73,24 @@ BUILD_TARGETS.set('tcp-server', {
const {
name: buildTarget,
needsPythonEnv,
pipfilePath,
setupFilePath,
distPath,
archiveName,
dotVenvPath
} = BUILD_TARGETS.get(givenBuildTarget)
const buildPath = path.join(distPath, BINARIES_FOLDER_NAME)
const buildPath = needsPythonEnv
? path.join(distPath, BINARIES_FOLDER_NAME)
: path.join(distPath, 'bin')
const { type: osType } = OSHelper.getInformation()
const { type: osType } = SystemHelper.getInformation()
/**
* Install requirements
*/
try {
if (osType === OSTypes.Linux) {
if (needsPythonEnv && osType === OSTypes.Linux) {
LogHelper.info('Checking whether the "patchelf" utility can be found...')
await command('patchelf --version', { shell: true })
@@ -91,30 +106,66 @@ BUILD_TARGETS.set('tcp-server', {
process.exit(1)
}
/**
* Build
*/
try {
LogHelper.info(`Building the ${buildTarget}...`)
LogHelper.info(`Building the ${buildTarget}...`)
// Required environment variables to set up
process.env.PIPENV_PIPFILE = pipfilePath
process.env.PIPENV_VENV_IN_PROJECT = true
if (needsPythonEnv) {
/**
* Build for binaries requiring a Python environment
*/
try {
// Required environment variables to set up
process.env.PIPENV_PIPFILE = pipfilePath
process.env.PIPENV_VENV_IN_PROJECT = true
await command(
`pipenv run python ${setupFilePath} build --build-exe ${buildPath}`,
{
await command(
`pipenv run python ${setupFilePath} build --build-exe ${buildPath}`,
{
shell: true,
stdio: 'inherit'
}
)
LogHelper.success(`The ${buildTarget} has been built`)
} catch (e) {
LogHelper.error(
`An error occurred while building the ${buildTarget}. Try to delete the ${dotVenvPath} folder, run the setup command then build again: ${e}`
)
process.exit(1)
}
} else {
/**
* Build for binaries not requiring a Python environment
*/
try {
const distBinPath = path.join(NODEJS_BRIDGE_DIST_PATH, 'bin')
const distMainFilePath = path.join(distBinPath, 'index.js')
const distRenamedMainFilePath = path.join(
distBinPath,
NODEJS_BRIDGE_BIN_NAME
)
await fs.promises.rm(buildPath, { recursive: true, force: true })
const inputMainFilePath = path.join(
NODEJS_BRIDGE_ROOT_PATH,
'src',
'main.ts'
)
await command(`ncc build ${inputMainFilePath} --out ${distBinPath}`, {
shell: true,
stdio: 'inherit'
}
)
})
LogHelper.success(`The ${buildTarget} has been built`)
} catch (e) {
LogHelper.error(
`An error occurred while building the ${buildTarget}. Try to delete the ${dotVenvPath} folder, run the setup command then build again: ${e}`
)
process.exit(1)
await fs.promises.rename(distMainFilePath, distRenamedMainFilePath)
LogHelper.success(`The ${buildTarget} has been built`)
} catch (e) {
LogHelper.error(
`An error occurred while building the ${buildTarget}: ${e}`
)
process.exit(1)
}
}
/**
@@ -142,7 +193,11 @@ BUILD_TARGETS.set('tcp-server', {
archive.pipe(output)
archive.directory(buildPath, BINARIES_FOLDER_NAME)
if (needsPythonEnv) {
archive.directory(buildPath, BINARIES_FOLDER_NAME)
} else {
archive.directory(buildPath, 'bin')
}
await archive.finalize()
})()
+2 -2
View File
@@ -1,7 +1,7 @@
import execa from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { OSHelper } from '@/helpers/os-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Check OS environment
@@ -10,7 +10,7 @@ export default () =>
new Promise(async (resolve, reject) => {
LogHelper.info('Checking OS environment...')
const info = OSHelper.getInformation()
const info = SystemHelper.getInformation()
if (info.type === 'windows') {
LogHelper.error('Voice offline mode is not available on Windows')
+390 -199
View File
@@ -1,207 +1,357 @@
import fs from 'node:fs'
import path from 'node:path'
import os from 'node:os'
import { spawn } from 'node:child_process'
import dotenv from 'dotenv'
import { command } from 'execa'
import semver from 'semver'
import kill from 'tree-kill'
import axios from 'axios'
import osName from 'os-name'
import getos from 'getos'
import { version } from '@@/package.json'
import { LogHelper } from '@/helpers/log-helper'
import { PYTHON_BRIDGE_BIN_PATH, EN_SPACY_MODEL_NAME } from '@/constants'
import { SystemHelper } from '@/helpers/system-helper'
import {
MINIMUM_REQUIRED_RAM,
LEON_VERSION,
NODEJS_BRIDGE_BIN_PATH,
PYTHON_BRIDGE_BIN_PATH,
TCP_SERVER_BIN_PATH,
TCP_SERVER_VERSION,
NODEJS_BRIDGE_VERSION,
PYTHON_BRIDGE_VERSION,
INSTANCE_ID
} from '@/constants'
dotenv.config()
/**
* Checking script
* Help to figure out what is installed or not
* Help to figure out the setup state
*/
export default () =>
new Promise(async (resolve, reject) => {
try {
const nodeMinRequiredVersion = '10'
const npmMinRequiredVersion = '5'
const pythonMinRequiredVersion = '3'
const flitePath = 'bin/flite/flite'
const coquiLanguageModelPath = 'bin/coqui/huge-vocabulary.scorer'
const amazonPath = 'core/config/voice/amazon.json'
const googleCloudPath = 'core/config/voice/google-cloud.json'
const watsonSttPath = 'core/config/voice/watson-stt.json'
const watsonTtsPath = 'core/config/voice/watson-tts.json'
const globalResolversNlpModelPath =
'core/data/models/leon-global-resolvers-model.nlp'
const skillsResolversNlpModelPath =
'core/data/models/leon-skills-resolvers-model.nlp'
const mainNlpModelPath = 'core/data/models/leon-main-model.nlp'
const report = {
can_run: { title: 'Run', type: 'error', v: true },
can_run_skill: { title: 'Run skills', type: 'error', v: true },
can_text: { title: 'Reply you by texting', type: 'error', v: true },
has_spacy_model: {
title: 'spaCy model is installed',
type: 'error',
v: true
},
can_amazon_polly_tts: {
title: 'Amazon Polly text-to-speech',
type: 'warning',
v: true
},
can_google_cloud_tts: {
title: 'Google Cloud text-to-speech',
type: 'warning',
v: true
},
can_watson_tts: {
title: 'Watson text-to-speech',
type: 'warning',
v: true
},
can_offline_tts: {
title: 'Offline text-to-speech',
type: 'warning',
v: true
},
can_google_cloud_stt: {
title: 'Google Cloud speech-to-text',
type: 'warning',
v: true
},
can_watson_stt: {
title: 'Watson speech-to-text',
type: 'warning',
v: true
},
can_offline_stt: {
title: 'Offline speech-to-text',
type: 'warning',
v: true
}
;(async () => {
try {
const nodeMinRequiredVersion = '16'
const npmMinRequiredVersion = '8'
const flitePath = 'bin/flite/flite'
const coquiLanguageModelPath = 'bin/coqui/huge-vocabulary.scorer'
const amazonPath = 'core/config/voice/amazon.json'
const googleCloudPath = 'core/config/voice/google-cloud.json'
const watsonSttPath = 'core/config/voice/watson-stt.json'
const watsonTtsPath = 'core/config/voice/watson-tts.json'
const globalResolversNlpModelPath =
'core/data/models/leon-global-resolvers-model.nlp'
const skillsResolversNlpModelPath =
'core/data/models/leon-skills-resolvers-model.nlp'
const mainNlpModelPath = 'core/data/models/leon-main-model.nlp'
const report = {
can_run: { title: 'Run', type: 'error', v: true },
can_run_skill: { title: 'Run skills', type: 'error', v: true },
can_text: { title: 'Reply you by texting', type: 'error', v: true },
can_start_tcp_server: {
title: 'Start the TCP server',
type: 'error',
v: true
},
can_amazon_polly_tts: {
title: 'Amazon Polly text-to-speech',
type: 'warning',
v: true
},
can_google_cloud_tts: {
title: 'Google Cloud text-to-speech',
type: 'warning',
v: true
},
can_watson_tts: {
title: 'Watson text-to-speech',
type: 'warning',
v: true
},
can_offline_tts: {
title: 'Offline text-to-speech',
type: 'warning',
v: true
},
can_google_cloud_stt: {
title: 'Google Cloud speech-to-text',
type: 'warning',
v: true
},
can_watson_stt: {
title: 'Watson speech-to-text',
type: 'warning',
v: true
},
can_offline_stt: {
title: 'Offline speech-to-text',
type: 'warning',
v: true
}
}
let reportDataInput = {
leonVersion: null,
instanceID: INSTANCE_ID || null,
environment: {
osDetails: null,
nodeVersion: null,
npmVersion: null
},
nlpModels: {
globalResolversModelState: null,
skillsResolversModelState: null,
mainModelState: null
},
nodeJSBridge: {
version: null,
executionTime: null,
command: null,
output: null,
error: null
},
pythonBridge: {
version: null,
executionTime: null,
command: null,
output: null,
error: null
},
tcpServer: {
version: null,
startTime: null,
command: null,
output: null,
error: null
},
report: null
}
LogHelper.title('Checking')
LogHelper.title('Checking')
/**
* Leon version checking
*/
/**
* Leon version checking
*/
LogHelper.info('Leon version')
LogHelper.success(`${version}\n`)
LogHelper.info('Leon version')
LogHelper.success(`${LEON_VERSION}\n`)
reportDataInput.leonVersion = LEON_VERSION
/**
* Environment checking
*/
LogHelper.info('OS')
/**
* Environment checking
*/
const osInfo = {
type: os.type(),
platform: os.platform(),
arch: os.arch(),
cpus: os.cpus().length,
release: os.release()
}
LogHelper.info('Environment')
const osInfo = {
type: os.type(),
platform: os.platform(),
arch: os.arch(),
cpus: os.cpus().length,
release: os.release(),
osName: osName(),
distro: null
}
const totalRAMInGB = SystemHelper.getTotalRAM()
const freeRAMInGB = SystemHelper.getFreeRAM()
if (Math.round(freeRAMInGB) < MINIMUM_REQUIRED_RAM) {
report.can_run.v = false
LogHelper.error(
`Free RAM: ${freeRAMInGB} GB | Total RAM: ${totalRAMInGB} GB. Leon needs at least ${MINIMUM_REQUIRED_RAM} GB of RAM`
)
} else {
LogHelper.success(
`Free RAM: ${freeRAMInGB} GB | Total RAM: ${totalRAMInGB} GB`
)
}
if (osInfo.platform === 'linux') {
getos((e, os) => {
osInfo.distro = os
LogHelper.success(`${JSON.stringify(osInfo)}\n`)
})
} else {
LogHelper.success(`${JSON.stringify(osInfo)}\n`)
;(
await Promise.all([
command('node --version', { shell: true }),
command('npm --version', { shell: true }),
command('pipenv --version', { shell: true })
])
).forEach((p) => {
LogHelper.info(p.command)
}
if (
p.command.indexOf('node --version') !== -1 &&
!semver.satisfies(
semver.clean(p.stdout),
`>=${nodeMinRequiredVersion}`
)
) {
Object.keys(report).forEach((item) => {
if (report[item].type === 'error') report[item].v = false
})
LogHelper.error(
`${p.stdout}\nThe Node.js version must be >=${nodeMinRequiredVersion}. Please install it: https://nodejs.org (or use nvm)\n`
)
} else if (
p.command.indexOf('npm --version') !== -1 &&
!semver.satisfies(
semver.clean(p.stdout),
`>=${npmMinRequiredVersion}`
)
) {
Object.keys(report).forEach((item) => {
if (report[item].type === 'error') report[item].v = false
})
LogHelper.error(
`${p.stdout}\nThe npm version must be >=${npmMinRequiredVersion}. Please install it: https://www.npmjs.com/get-npm (or use nvm)\n`
)
} else {
LogHelper.success(`${p.stdout}\n`)
}
})
;(
await Promise.all([
command('pipenv --where', { shell: true }),
command('pipenv run python --version', { shell: true })
])
).forEach((p) => {
LogHelper.info(p.command)
reportDataInput.environment.osDetails = osInfo
reportDataInput.environment.totalRAMInGB = totalRAMInGB
reportDataInput.environment.freeRAMInGB = freeRAMInGB
;(
await Promise.all([
command('node --version', { shell: true }),
command('npm --version', { shell: true })
])
).forEach((p) => {
LogHelper.info(p.command)
if (
p.command.indexOf('pipenv run python --version') !== -1 &&
!semver.satisfies(
p.stdout.split(' ')[1],
`>=${pythonMinRequiredVersion}`
)
) {
Object.keys(report).forEach((item) => {
if (report[item].type === 'error') report[item].v = false
})
LogHelper.error(
`${p.stdout}\nThe Python version must be >=${pythonMinRequiredVersion}. Please install it: https://www.python.org/downloads\n`
)
} else {
LogHelper.success(`${p.stdout}\n`)
}
})
/**
* Skill execution checking
*/
try {
LogHelper.time('Skill execution time')
const p = await command(
`${PYTHON_BRIDGE_BIN_PATH} scripts/assets/intent-object.json`,
{ shell: true }
)
LogHelper.timeEnd('Skill execution time')
LogHelper.info(p.command)
LogHelper.success(`${p.stdout}\n`)
} catch (e) {
LogHelper.info(e.command)
report.can_run_skill.v = false
LogHelper.error(`${e}\n`)
}
/**
* spaCy model checking
*/
try {
const p = await command(
`pipenv run python -c "import ${EN_SPACY_MODEL_NAME}"`,
{ shell: true }
)
LogHelper.info(p.command)
LogHelper.success(`spaCy model installed\n`)
} catch (e) {
LogHelper.info(e.command)
report.has_spacy_model.v = false
if (
p.command.indexOf('node --version') !== -1 &&
!semver.satisfies(semver.clean(p.stdout), `>=${nodeMinRequiredVersion}`)
) {
Object.keys(report).forEach((item) => {
if (report[item].type === 'error') report[item].v = false
})
LogHelper.error(
'No spaCy model is installed. It is recommended to run the following command: "npm run clean:python-deps"\n'
`${p.stdout}\nThe Node.js version must be >=${nodeMinRequiredVersion}. Please install it: https://nodejs.org (or use nvm)\n`
)
} else if (
p.command.indexOf('npm --version') !== -1 &&
!semver.satisfies(semver.clean(p.stdout), `>=${npmMinRequiredVersion}`)
) {
Object.keys(report).forEach((item) => {
if (report[item].type === 'error') report[item].v = false
})
LogHelper.error(
`${p.stdout}\nThe npm version must be >=${npmMinRequiredVersion}. Please install it: https://www.npmjs.com/get-npm (or use nvm)\n`
)
} else {
LogHelper.success(`${p.stdout}\n`)
if (p.command.includes('node --version')) {
reportDataInput.environment.nodeVersion = p.stdout
} else if (p.command.includes('npm --version')) {
reportDataInput.environment.npmVersion = p.stdout
}
}
})
/**
* Skill execution checking with Node.js bridge
*/
LogHelper.success(`Node.js bridge version: ${NODEJS_BRIDGE_VERSION}`)
reportDataInput.nodeJSBridge.version = NODEJS_BRIDGE_VERSION
LogHelper.info('Executing a skill...')
try {
const executionStart = Date.now()
const p = await command(
`${NODEJS_BRIDGE_BIN_PATH} "${path.join(
process.cwd(),
'scripts',
'assets',
'nodejs-bridge-intent-object.json'
)}"`,
{ shell: true }
)
const executionEnd = Date.now()
const executionTime = executionEnd - executionStart
LogHelper.info(p.command)
reportDataInput.nodeJSBridge.command = p.command
LogHelper.success(p.stdout)
reportDataInput.nodeJSBridge.output = p.stdout
LogHelper.info(`Skill execution time: ${executionTime}ms\n`)
reportDataInput.nodeJSBridge.executionTime = `${executionTime}ms`
} catch (e) {
LogHelper.info(e.command)
report.can_run_skill.v = false
LogHelper.error(`${e}\n`)
reportDataInput.nodeJSBridge.error = JSON.stringify(e)
}
/**
* Skill execution checking with Python bridge
*/
LogHelper.success(`Python bridge version: ${PYTHON_BRIDGE_VERSION}`)
reportDataInput.pythonBridge.version = PYTHON_BRIDGE_VERSION
LogHelper.info('Executing a skill...')
try {
const executionStart = Date.now()
const p = await command(
`${PYTHON_BRIDGE_BIN_PATH} "${path.join(
process.cwd(),
'scripts',
'assets',
'python-bridge-intent-object.json'
)}"`,
{ shell: true }
)
const executionEnd = Date.now()
const executionTime = executionEnd - executionStart
LogHelper.info(p.command)
reportDataInput.pythonBridge.command = p.command
LogHelper.success(p.stdout)
reportDataInput.pythonBridge.output = p.stdout
LogHelper.info(`Skill execution time: ${executionTime}ms\n`)
reportDataInput.pythonBridge.executionTime = `${executionTime}ms`
} catch (e) {
LogHelper.info(e.command)
report.can_run_skill.v = false
LogHelper.error(`${e}\n`)
reportDataInput.pythonBridge.error = JSON.stringify(e)
}
/**
* TCP server startup checking
*/
LogHelper.success(`TCP server version: ${TCP_SERVER_VERSION}`)
reportDataInput.tcpServer.version = TCP_SERVER_VERSION
LogHelper.info('Starting the TCP server...')
const tcpServerCommand = `${TCP_SERVER_BIN_PATH} en`
const tcpServerStart = Date.now()
const p = spawn(tcpServerCommand, { shell: true })
const ignoredWarnings = [
'UserWarning: Unable to retrieve source for @torch.jit._overload function'
]
LogHelper.info(tcpServerCommand)
reportDataInput.tcpServer.command = tcpServerCommand
if (osInfo.platform === 'darwin') {
LogHelper.info(
'For the first start, it may take a few minutes to cold start the TCP server on macOS. No worries it is a one-time thing'
)
}
let tcpServerOutput = ''
p.stdout.on('data', (data) => {
const newData = data.toString()
tcpServerOutput += newData
if (newData?.toLowerCase().includes('waiting for')) {
kill(p.pid)
LogHelper.success('The TCP server can successfully start')
}
})
p.stderr.on('data', (data) => {
const newData = data.toString()
// Ignore given warnings on stderr output
if (!ignoredWarnings.some((w) => newData.includes(w))) {
tcpServerOutput += newData
report.can_start_tcp_server.v = false
reportDataInput.tcpServer.error = newData
LogHelper.error(`Cannot start the TCP server: ${newData}`)
}
})
const timeout = 3 * 60_000
// In case it takes too long, force kill
setTimeout(() => {
kill(p.pid)
const error = `The TCP server timed out after ${timeout}ms`
LogHelper.error(error)
reportDataInput.tcpServer.error = error
report.can_start_tcp_server.v = false
}, timeout)
p.stdout.on('end', async () => {
const tcpServerEnd = Date.now()
reportDataInput.tcpServer.output = tcpServerOutput
reportDataInput.tcpServer.startTime = `${tcpServerEnd - tcpServerStart}ms`
LogHelper.info(
`TCP server startup time: ${reportDataInput.tcpServer.startTime}\n`
)
/**
* Global resolvers NLP model checking
@@ -211,18 +361,25 @@ export default () =>
if (
!fs.existsSync(globalResolversNlpModelPath) ||
!Object.keys(fs.readFileSync(globalResolversNlpModelPath)).length
!Object.keys(await fs.promises.readFile(globalResolversNlpModelPath))
.length
) {
const state = 'Global resolvers NLP model not found or broken'
report.can_text.v = false
Object.keys(report).forEach((item) => {
if (item.indexOf('stt') !== -1 || item.indexOf('tts') !== -1)
report[item].v = false
})
LogHelper.error(
'Global resolvers NLP model not found or broken. Try to generate a new one: "npm run train"\n'
`${state}. Try to generate a new one: "npm run train"\n`
)
reportDataInput.nlpModels.globalResolversModelState = state
} else {
LogHelper.success('Found and valid\n')
const state = 'Found and valid'
LogHelper.success(`${state}\n`)
reportDataInput.nlpModels.globalResolversModelState = state
}
/**
@@ -233,18 +390,25 @@ export default () =>
if (
!fs.existsSync(skillsResolversNlpModelPath) ||
!Object.keys(fs.readFileSync(skillsResolversNlpModelPath)).length
!Object.keys(await fs.promises.readFile(skillsResolversNlpModelPath))
.length
) {
const state = 'Skills resolvers NLP model not found or broken'
report.can_text.v = false
Object.keys(report).forEach((item) => {
if (item.indexOf('stt') !== -1 || item.indexOf('tts') !== -1)
report[item].v = false
})
LogHelper.error(
'Skills resolvers NLP model not found or broken. Try to generate a new one: "npm run train"\n'
`${state}. Try to generate a new one: "npm run train"\n`
)
reportDataInput.nlpModels.skillsResolversModelState = state
} else {
LogHelper.success('Found and valid\n')
const state = 'Found and valid'
LogHelper.success(`${state}\n`)
reportDataInput.nlpModels.skillsResolversModelState = state
}
/**
@@ -255,18 +419,24 @@ export default () =>
if (
!fs.existsSync(mainNlpModelPath) ||
!Object.keys(fs.readFileSync(mainNlpModelPath)).length
!Object.keys(await fs.promises.readFile(mainNlpModelPath)).length
) {
const state = 'Main NLP model not found or broken'
report.can_text.v = false
Object.keys(report).forEach((item) => {
if (item.indexOf('stt') !== -1 || item.indexOf('tts') !== -1)
report[item].v = false
})
LogHelper.error(
'Main NLP model not found or broken. Try to generate a new one: "npm run train"\n'
`${state}. Try to generate a new one: "npm run train"\n`
)
reportDataInput.nlpModels.mainModelState = state
} else {
LogHelper.success('Found and valid\n')
const state = 'Found and valid'
LogHelper.success(`${state}\n`)
reportDataInput.nlpModels.mainModelState = state
}
/**
@@ -276,7 +446,7 @@ export default () =>
LogHelper.info('Amazon Polly TTS')
try {
const json = JSON.parse(fs.readFileSync(amazonPath))
const json = JSON.parse(await fs.promises.readFile(amazonPath))
if (
json.credentials.accessKeyId === '' ||
json.credentials.secretAccessKey === ''
@@ -294,7 +464,7 @@ export default () =>
LogHelper.info('Google Cloud TTS/STT')
try {
const json = JSON.parse(fs.readFileSync(googleCloudPath))
const json = JSON.parse(await fs.promises.readFile(googleCloudPath))
const results = []
Object.keys(json).forEach((item) => {
if (json[item] === '') results.push(false)
@@ -315,7 +485,7 @@ export default () =>
LogHelper.info('Watson TTS')
try {
const json = JSON.parse(fs.readFileSync(watsonTtsPath))
const json = JSON.parse(await fs.promises.readFile(watsonTtsPath))
const results = []
Object.keys(json).forEach((item) => {
if (json[item] === '') results.push(false)
@@ -336,7 +506,7 @@ export default () =>
if (!fs.existsSync(flitePath)) {
report.can_offline_tts.v = false
LogHelper.warning(
`Cannot find ${flitePath}. You can setup the offline TTS by running: "npm run setup:offline-tts"\n`
`Cannot find ${flitePath}. You can set up the offline TTS by running: "npm run setup:offline-tts"\n`
)
} else {
LogHelper.success(`Found Flite at ${flitePath}\n`)
@@ -345,7 +515,7 @@ export default () =>
LogHelper.info('Watson STT')
try {
const json = JSON.parse(fs.readFileSync(watsonSttPath))
const json = JSON.parse(await fs.promises.readFile(watsonSttPath))
const results = []
Object.keys(json).forEach((item) => {
if (json[item] === '') results.push(false)
@@ -394,7 +564,7 @@ export default () =>
report.can_run.v &&
report.can_run_skill.v &&
report.can_text.v &&
report.has_spacy_model.v
report.can_start_tcp_server.v
) {
LogHelper.success('Hooray! Leon can run correctly')
LogHelper.info(
@@ -404,9 +574,30 @@ export default () =>
LogHelper.error('Please fix the errors above')
}
resolve()
} catch (e) {
LogHelper.error(e)
reject()
}
})
reportDataInput.report = report
reportDataInput = JSON.parse(
SystemHelper.sanitizeUsername(JSON.stringify(reportDataInput))
)
LogHelper.title('REPORT URL')
LogHelper.info('Sending report...')
try {
const { data } = await axios.post('https://getleon.ai/api/report', {
report: reportDataInput
})
const { data: responseReportData } = data
LogHelper.success(`Report URL: ${responseReportData.reportUrl}`)
} catch (e) {
LogHelper.error(`Failed to send report: ${e}`)
}
process.exit(0)
})
} catch (e) {
LogHelper.error(e)
}
})()
+4 -4
View File
@@ -22,13 +22,13 @@ export default () =>
try {
// TODO: handle case where the memory folder contain multiple DB nodes
const dbFolder = join(currentSkill.path, 'memory')
const dbTestFiles = fs
.readdirSync(dbFolder)
.filter((entity) => entity.indexOf('.spec.json') !== -1)
const dbTestFiles = (await fs.promises.readdir(dbFolder)).filter(
(entity) => entity.indexOf('.spec.json') !== -1
)
if (dbTestFiles.length > 0) {
LogHelper.info(`Deleting ${dbTestFiles[0]}...`)
fs.unlinkSync(join(dbFolder, dbTestFiles[0]))
await fs.promises.unlink(join(dbFolder, dbTestFiles[0]))
LogHelper.success(`${dbTestFiles[0]} deleted`)
}
} catch (e) {
+20 -15
View File
@@ -6,24 +6,29 @@ import { LogHelper } from '@/helpers/log-helper'
* This script is executed after "git commit" or "git merge" (Git hook https://git-scm.com/docs/githooks#_commit_msg)
* it ensures the authenticity of commit messages
*/
LogHelper.info('Checking commit message...')
;(async () => {
LogHelper.info('Checking commit message...')
const commitEditMsgFile = '.git/COMMIT_EDITMSG'
const commitEditMsgFile = '.git/COMMIT_EDITMSG'
if (fs.existsSync(commitEditMsgFile)) {
try {
const commitMessage = fs.readFileSync(commitEditMsgFile, 'utf8')
const regex =
'(build|BREAKING|chore|ci|docs|feat|fix|perf|refactor|style|test)(\\((web app|docker|server|hotword|tcp server|python bridge|skill\\/([\\w-]+)))?\\)?: .{1,50}'
if (fs.existsSync(commitEditMsgFile)) {
try {
const commitMessage = await fs.promises.readFile(
commitEditMsgFile,
'utf8'
)
const regex =
'(build|BREAKING|chore|ci|docs|feat|fix|perf|refactor|style|test)(\\((web app|scripts|docker|server|hotword|tcp server|bridge\\/(python|nodejs)|skill\\/([\\w-]+)))?\\)?: .{1,50}'
if (commitMessage.match(regex) !== null) {
LogHelper.success('Commit message validated')
} else {
LogHelper.error(`Commit message does not match the format: ${regex}`)
if (commitMessage.match(regex) !== null) {
LogHelper.success('Commit message validated')
} else {
LogHelper.error(`Commit message does not match the format: ${regex}`)
process.exit(1)
}
} catch (e) {
LogHelper.error(e.message)
process.exit(1)
}
} catch (e) {
LogHelper.error(e.message)
process.exit(1)
}
}
})()
+7 -7
View File
@@ -14,7 +14,7 @@ dotenv.config()
* Generate HTTP API key script
* save it in the .env file
*/
const generateHttpApiKey = () =>
const generateHTTPAPIKey = () =>
new Promise(async (resolve, reject) => {
LogHelper.info('Generating the HTTP API key...')
@@ -23,7 +23,7 @@ const generateHttpApiKey = () =>
const str = StringHelper.random(11)
const dotEnvPath = path.join(process.cwd(), '.env')
const envVarKey = 'LEON_HTTP_API_KEY'
let content = fs.readFileSync(dotEnvPath, 'utf8')
let content = await fs.promises.readFile(dotEnvPath, 'utf8')
shasum.update(str)
const sha1 = shasum.digest('hex')
@@ -39,7 +39,7 @@ const generateHttpApiKey = () =>
content = lines.join('\n')
fs.writeFileSync(dotEnvPath, content)
await fs.promises.writeFile(dotEnvPath, content)
LogHelper.success('HTTP API key generated')
resolve()
@@ -56,17 +56,17 @@ export default () =>
!process.env.LEON_HTTP_API_KEY ||
process.env.LEON_HTTP_API_KEY === ''
) {
await generateHttpApiKey()
await generateHTTPAPIKey()
} else if (!process.env.IS_DOCKER) {
const answer = await prompt({
type: 'confirm',
name: 'generate.httpApiKey',
name: 'generate.httpAPIKey',
message: 'Do you want to regenerate the HTTP API key?',
default: false
})
if (answer.generate.httpApiKey === true) {
await generateHttpApiKey()
if (answer.generate.httpAPIKey === true) {
await generateHTTPAPIKey()
}
}
+80
View File
@@ -0,0 +1,80 @@
import fs from 'node:fs'
import path from 'node:path'
import { LogHelper } from '@/helpers/log-helper'
import {
domainSchemaObject,
skillSchemaObject,
skillConfigSchemaObject
} from '@/schemas/skill-schemas'
import {
globalEntitySchemaObject,
globalResolverSchemaObject,
globalAnswersSchemaObject
} from '@/schemas/global-data-schemas'
import {
amazonVoiceConfiguration,
googleCloudVoiceConfiguration,
watsonVoiceConfiguration
} from '@/schemas/voice-config-schemas'
/**
* Generate JSON schemas
* @param {string} categoryName
* @param {Map<string, Object>} schemas
*/
export const generateSchemas = async (categoryName, schemas) => {
const categorySchemasPath = path.join(process.cwd(), 'schemas', categoryName)
await fs.promises.mkdir(categorySchemasPath, { recursive: true })
for (const [schemaName, schemaObject] of schemas.entries()) {
const schemaPath = path.join(categorySchemasPath, `${schemaName}.json`)
await fs.promises.writeFile(
schemaPath,
JSON.stringify(
{
$schema: 'https://json-schema.org/draft-07/schema',
...schemaObject
},
null,
2
)
)
}
}
export default async () => {
LogHelper.info('Generating the JSON schemas...')
await Promise.all([
generateSchemas(
'global-data',
new Map([
['global-entity', globalEntitySchemaObject],
['global-resolver', globalResolverSchemaObject],
['global-answers', globalAnswersSchemaObject]
])
),
generateSchemas(
'skill-schemas',
new Map([
['domain', domainSchemaObject],
['skill', skillSchemaObject],
['skill-config', skillConfigSchemaObject]
])
),
generateSchemas(
'voice-config-schemas',
new Map([
['amazon', amazonVoiceConfiguration],
['google-cloud', googleCloudVoiceConfiguration],
['watson-stt', watsonVoiceConfiguration],
['watson-tts', watsonVoiceConfiguration]
])
)
])
LogHelper.success('JSON schemas generated')
}
@@ -39,7 +39,9 @@ export default () =>
// Check if a new routing generation is necessary
if (fs.existsSync(outputFilePath)) {
const mtimeEndpoints = fs.statSync(outputFilePath).mtime.getTime()
const mtimeEndpoints = (
await fs.promises.stat(outputFilePath)
).mtime.getTime()
let i = 0
for (const currentDomain of skillDomains.values()) {
@@ -49,7 +51,7 @@ export default () =>
for (let j = 0; j < skillKeys.length; j += 1) {
const skillFriendlyName = skillKeys[j]
const currentSkill = currentDomain.skills[skillFriendlyName]
const fileInfo = fs.statSync(
const fileInfo = await fs.promises.stat(
path.join(currentSkill.path, 'config', `${lang}.json`)
)
const mtime = fileInfo.mtime.getTime()
@@ -91,7 +93,7 @@ export default () =>
`${lang}.json`
)
const { actions } = JSON.parse(
fs.readFileSync(configFilePath, 'utf8')
await fs.promises.readFile(configFilePath, 'utf8')
)
const actionsKeys = Object.keys(actions)
@@ -145,7 +147,10 @@ export default () =>
LogHelper.info(`Writing ${outputFile} file...`)
try {
fs.writeFileSync(outputFilePath, JSON.stringify(finalObj, null, 2))
await fs.promises.writeFile(
outputFilePath,
JSON.stringify(finalObj, null, 2)
)
LogHelper.success(`${outputFile} file generated`)
resolve()
} catch (e) {
@@ -0,0 +1,14 @@
import { LogHelper } from '@/helpers/log-helper'
import generateJsonSchemas from './generate-json-schemas'
/**
* Execute the generating JSON schemas script
*/
;(async () => {
try {
await generateJsonSchemas()
} catch (error) {
LogHelper.error(`Failed to generate the json schemas: ${error}`)
}
})()
+13 -10
View File
@@ -35,9 +35,12 @@ export default (version) =>
const repoUrl = sh.stdout.substr(0, sh.stdout.lastIndexOf('.git'))
const previousTag = sh.stdout.substr(sh.stdout.indexOf('\n') + 1).trim()
const changelogData = fs.readFileSync(changelog, 'utf8')
const changelogData = await fs.promises.readFile(changelog, 'utf8')
const compareUrl = `${repoUrl}/compare/${previousTag}...v${version}`
let tmpData = fs.readFileSync(`scripts/tmp/${tmpChangelog}`, 'utf8')
let tmpData = await fs.promises.readFile(
`scripts/tmp/${tmpChangelog}`,
'utf8'
)
LogHelper.success(`Remote origin URL gotten: ${repoUrl}.git`)
LogHelper.success(`Previous tag gotten: ${previousTag}`)
@@ -46,14 +49,14 @@ export default (version) =>
tmpData = tmpData.replace(version, `[${version}](${compareUrl})`)
}
fs.writeFile(changelog, `${tmpData}${changelogData}`, (err) => {
if (err) LogHelper.error(`Failed to write into file: ${err}`)
else {
fs.unlinkSync(`scripts/tmp/${tmpChangelog}`)
LogHelper.success(`${changelog} generated`)
resolve()
}
})
try {
await fs.promises.writeFile(changelog, `${tmpData}${changelogData}`)
await fs.promises.unlink(`scripts/tmp/${tmpChangelog}`)
LogHelper.success(`${changelog} generated`)
resolve()
} catch (error) {
LogHelper.error(`Failed to write into file: ${error}`)
}
} catch (e) {
LogHelper.error(`Error during git commands: ${e}`)
reject(e)
+14 -6
View File
@@ -3,7 +3,11 @@ import path from 'node:path'
import { prompt } from 'inquirer'
import { command } from 'execa'
import { PYTHON_BRIDGE_SRC_PATH, TCP_SERVER_SRC_PATH } from '@/constants'
import {
NODEJS_BRIDGE_SRC_PATH,
PYTHON_BRIDGE_SRC_PATH,
TCP_SERVER_SRC_PATH
} from '@/constants'
import { LogHelper } from '@/helpers/log-helper'
import { LoaderHelper } from '@/helpers/loader-helper'
@@ -15,13 +19,17 @@ import { LoaderHelper } from '@/helpers/loader-helper'
const BUILD_TARGETS = new Map()
BUILD_TARGETS.set('nodejs-bridge', {
workflowFileName: 'pre-release-nodejs-bridge.yml',
versionFilePath: path.join(NODEJS_BRIDGE_SRC_PATH, 'version.ts')
})
BUILD_TARGETS.set('python-bridge', {
workflowFileName: 'pre-release-python-bridge.yml',
setupFilePath: path.join(PYTHON_BRIDGE_SRC_PATH, 'setup.py')
versionFilePath: path.join(PYTHON_BRIDGE_SRC_PATH, 'version.py')
})
BUILD_TARGETS.set('tcp-server', {
workflowFileName: 'pre-release-tcp-server.yml',
setupFilePath: path.join(TCP_SERVER_SRC_PATH, 'setup.py')
versionFilePath: path.join(TCP_SERVER_SRC_PATH, 'version.py')
})
;(async () => {
LoaderHelper.start()
@@ -29,21 +37,21 @@ BUILD_TARGETS.set('tcp-server', {
const { argv } = process
const givenReleaseTarget = argv[2].toLowerCase()
const givenBranch = argv[3]?.toLowerCase()
const { workflowFileName, setupFilePath } =
const { workflowFileName, versionFilePath } =
BUILD_TARGETS.get(givenReleaseTarget)
LoaderHelper.stop()
const answer = await prompt({
type: 'confirm',
name: 'binary.bumped',
message: `Have you bumped the version number of the binary from the "${setupFilePath}" file?`,
message: `Have you bumped the version number of the binary from the "${versionFilePath}" file?`,
default: false
})
LoaderHelper.start()
if (!answer.binary.bumped) {
LogHelper.info(
'Please bump the version number of the binary from the setup file before continuing'
'Please bump the version number of the binary from the version file before continuing'
)
process.exit(0)
}
+2 -1
View File
@@ -10,7 +10,8 @@ export default (version) =>
LogHelper.info('Updating version...')
const promises = []
const files = ['package.json', 'package-lock.json']
// const files = ['package.json', 'package-lock.json']
const files = ['package.json']
for (let i = 0; i < files.length; i += 1) {
promises.push(
-16
View File
@@ -1,16 +0,0 @@
import { LoaderHelper } from '@/helpers/loader-helper'
import check from './check'
/**
* Execute the checking script
*/
;(async () => {
try {
LoaderHelper.start()
await check()
LoaderHelper.stop()
} catch (e) {
LoaderHelper.stop()
}
})()
+1 -1
View File
@@ -9,6 +9,6 @@ import setupHotword from './setup-hotword'
try {
await setupHotword()
} catch (e) {
LogHelper.error(`Failed to setup offline hotword: ${e}`)
LogHelper.error(`Failed to set up offline hotword: ${e}`)
}
})()
+1 -1
View File
@@ -9,6 +9,6 @@ import setupStt from './setup-stt'
try {
await setupStt()
} catch (e) {
LogHelper.error(`Failed to setup offline STT: ${e}`)
LogHelper.error(`Failed to set up offline STT: ${e}`)
}
})()
+1 -1
View File
@@ -9,6 +9,6 @@ import setupTts from './setup-tts'
try {
await setupTts()
} catch (e) {
LogHelper.error(`Failed to setup offline TTS: ${e}`)
LogHelper.error(`Failed to set up offline TTS: ${e}`)
}
})()
+2 -2
View File
@@ -1,7 +1,7 @@
import { command } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { OSHelper } from '@/helpers/os-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Setup offline hotword detection
@@ -10,7 +10,7 @@ export default () =>
new Promise(async (resolve, reject) => {
LogHelper.info('Setting up offline hotword detection...')
const info = OSHelper.getInformation()
const info = SystemHelper.getInformation()
let pkgm = 'apt-get install'
if (info.type === 'macos') {
pkgm = 'brew'
+3 -3
View File
@@ -3,10 +3,10 @@ import fs from 'node:fs'
import { command } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { OSHelper } from '@/helpers/os-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Setup offline speech-to-text
* Set up offline speech-to-text
*/
export default () =>
new Promise(async (resolve, reject) => {
@@ -17,7 +17,7 @@ export default () =>
// check this repo for updates: https://github.com/coqui-ai/STT-models/tree/main/english/coqui
const coquiModelVersion = '1.0.0'
let downloader = 'wget'
if (OSHelper.getInformation().type === 'macos') {
if (SystemHelper.getInformation().type === 'macos') {
downloader = 'curl -L -O'
}
+5 -5
View File
@@ -3,10 +3,10 @@ import fs from 'node:fs'
import { command } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { OSHelper } from '@/helpers/os-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Setup offline text-to-speech
* Set up offline text-to-speech
*/
export default () =>
new Promise(async (resolve, reject) => {
@@ -15,11 +15,11 @@ export default () =>
const destFliteFolder = 'bin/flite'
const tmpDir = 'scripts/tmp'
let makeCores = ''
if (OSHelper.getNumberOfCPUCores() > 2) {
makeCores = `-j ${OSHelper.getNumberOfCPUCores() - 2}`
if (SystemHelper.getNumberOfCPUCores() > 2) {
makeCores = `-j ${SystemHelper.getNumberOfCPUCores() - 2}`
}
let downloader = 'wget'
if (OSHelper.getInformation().type === 'macos') {
if (SystemHelper.getInformation().type === 'macos') {
downloader = 'curl -L -O'
}
+31
View File
@@ -0,0 +1,31 @@
import fs from 'node:fs'
import { LEON_FILE_PATH } from '@/constants'
import { Telemetry } from '@/telemetry'
import { LogHelper } from '@/helpers/log-helper'
export default async () => {
try {
const { instanceID, birthDate } = await Telemetry.postInstall()
if (!fs.existsSync(LEON_FILE_PATH)) {
await fs.promises.writeFile(
LEON_FILE_PATH,
JSON.stringify(
{
instanceID,
birthDate
},
null,
2
)
)
LogHelper.success(`Instance ID created: ${instanceID}`)
} else {
LogHelper.success(`Instance ID already exists: ${instanceID}`)
}
} catch (e) {
LogHelper.warning(`Failed to create the instance ID: ${e}`)
}
}
+176
View File
@@ -0,0 +1,176 @@
import fs from 'node:fs'
import path from 'node:path'
import stream from 'node:stream'
import readline from 'node:readline'
import axios from 'axios'
import { command } from 'execa'
import prettyBytes from 'pretty-bytes'
import prettyMilliseconds from 'pretty-ms'
import extractZip from 'extract-zip'
import {
BINARIES_FOLDER_NAME,
GITHUB_URL,
NODEJS_BRIDGE_ROOT_PATH,
NODEJS_BRIDGE_DIST_PATH,
PYTHON_BRIDGE_DIST_PATH,
TCP_SERVER_DIST_PATH,
NODEJS_BRIDGE_BIN_NAME,
PYTHON_BRIDGE_BIN_NAME,
TCP_SERVER_BIN_NAME,
NODEJS_BRIDGE_VERSION,
PYTHON_BRIDGE_VERSION,
TCP_SERVER_VERSION
} from '@/constants'
import { LogHelper } from '@/helpers/log-helper'
/**
* Set up binaries according to the given setup target
* 1. Delete the existing dist binaries if already exist
* 2. Download the latest binaries from GitHub releases
* 3. Extract the downloaded ZIP file to the dist folder
*/
const TARGETS = new Map()
TARGETS.set('nodejs-bridge', {
name: 'Node.js bridge',
distPath: NODEJS_BRIDGE_DIST_PATH,
manifestPath: path.join(NODEJS_BRIDGE_DIST_PATH, 'manifest.json'),
archiveName: `${NODEJS_BRIDGE_BIN_NAME.split('.')[0]}.zip`,
version: NODEJS_BRIDGE_VERSION,
isPlatformDependent: false // Need to be built for the target platform or not
})
TARGETS.set('python-bridge', {
name: 'Python bridge',
distPath: PYTHON_BRIDGE_DIST_PATH,
manifestPath: path.join(PYTHON_BRIDGE_DIST_PATH, 'manifest.json'),
archiveName: `${PYTHON_BRIDGE_BIN_NAME}-${BINARIES_FOLDER_NAME}.zip`,
version: PYTHON_BRIDGE_VERSION,
isPlatformDependent: true
})
TARGETS.set('tcp-server', {
name: 'TCP server',
distPath: TCP_SERVER_DIST_PATH,
manifestPath: path.join(TCP_SERVER_DIST_PATH, 'manifest.json'),
archiveName: `${TCP_SERVER_BIN_NAME}-${BINARIES_FOLDER_NAME}.zip`,
version: TCP_SERVER_VERSION,
isPlatformDependent: true
})
async function createManifestFile(manifestPath, name, version) {
const manifest = {
name,
version,
setupDate: Date.now()
}
await fs.promises.writeFile(manifestPath, JSON.stringify(manifest, null, 2))
}
const setupBinaries = async (key) => {
const {
name,
distPath,
archiveName,
version,
manifestPath,
isPlatformDependent
} = TARGETS.get(key)
let manifest = null
if (fs.existsSync(manifestPath)) {
manifest = JSON.parse(await fs.promises.readFile(manifestPath, 'utf8'))
LogHelper.info(`Found ${name} ${manifest.version}`)
LogHelper.info(`Latest version is ${version}`)
}
if (!manifest || manifest.version !== version) {
const buildPath = isPlatformDependent
? path.join(distPath, BINARIES_FOLDER_NAME)
: path.join(distPath, 'bin')
const archivePath = path.join(distPath, archiveName)
await Promise.all([
fs.promises.rm(buildPath, { recursive: true, force: true }),
fs.promises.rm(archivePath, { recursive: true, force: true })
])
if (key === 'nodejs-bridge') {
try {
LogHelper.info('Installing Node.js bridge npm packages...')
await command(
`npm install --package-lock=false --prefix ${NODEJS_BRIDGE_ROOT_PATH}`,
{
shell: true
}
)
LogHelper.success('Node.js bridge npm packages installed')
} catch (e) {
throw new Error(`Failed to install Node.js bridge npm packages: ${e}`)
}
}
try {
LogHelper.info(`Downloading ${name}...`)
const archiveWriter = fs.createWriteStream(archivePath)
const latestReleaseAssetURL = `${GITHUB_URL}/releases/download/${key}_v${version}/${archiveName}`
const { data } = await axios.get(latestReleaseAssetURL, {
responseType: 'stream',
onDownloadProgress: ({ loaded, total, progress, estimated, rate }) => {
const percentage = Math.floor(progress * 100)
const downloadedSize = prettyBytes(loaded)
const totalSize = prettyBytes(total)
const estimatedTime = !estimated
? 0
: prettyMilliseconds(estimated * 1_000, { secondsDecimalDigits: 0 })
const downloadRate = !rate ? 0 : prettyBytes(rate)
readline.clearLine(process.stdout, 0)
readline.cursorTo(process.stdout, 0, null)
process.stdout.write(
`Download progress: ${percentage}% (${downloadedSize}/${totalSize} | ${downloadRate}/s | ${estimatedTime} ETA)`
)
if (percentage === 100) {
process.stdout.write('\n')
}
}
})
data.pipe(archiveWriter)
await stream.promises.finished(archiveWriter)
LogHelper.success(`${name} downloaded`)
LogHelper.info(`Extracting ${name}...`)
const absoluteDistPath = path.resolve(distPath)
await extractZip(archivePath, { dir: absoluteDistPath })
LogHelper.success(`${name} extracted`)
await Promise.all([
fs.promises.rm(archivePath, { recursive: true, force: true }),
createManifestFile(manifestPath, name, version)
])
LogHelper.success(`${name} manifest file created`)
LogHelper.success(`${name} ${version} ready`)
} catch (e) {
throw new Error(`Failed to set up ${name}: ${e}`)
}
} else {
LogHelper.success(`${name} is already at the latest version (${version})`)
}
}
export default async () => {
await setupBinaries('nodejs-bridge')
await setupBinaries('python-bridge')
await setupBinaries('tcp-server')
}
+7 -7
View File
@@ -4,23 +4,23 @@ import path from 'node:path'
import { LogHelper } from '@/helpers/log-helper'
/**
* Setup Leon's core configuration
* Set up Leon's core configuration
*/
export default () =>
new Promise((resolve) => {
new Promise(async (resolve) => {
LogHelper.info('Configuring core...')
const dir = 'core/config'
const list = (dir) => {
const entities = fs.readdirSync(dir)
const list = async (dir) => {
const entities = await fs.promises.readdir(dir)
// Browse core config entities
for (let i = 0; i < entities.length; i += 1) {
const file = `${entities[i].replace('.sample.json', '.json')}`
// Recursive if the entity is a directory
const way = path.join(dir, entities[i])
if (fs.statSync(way).isDirectory()) {
list(way)
if ((await fs.promises.stat(way)).isDirectory()) {
await list(way)
} else if (
entities[i].indexOf('.sample.json') !== -1 &&
!fs.existsSync(`${dir}/${file}`)
@@ -40,6 +40,6 @@ export default () =>
}
}
list(dir)
await list(dir)
resolve()
})
+9 -8
View File
@@ -11,9 +11,10 @@ import {
PYTHON_BRIDGE_SRC_PATH,
TCP_SERVER_SRC_PATH
} from '@/constants'
import { CPUArchitectures, OSTypes } from '@/types'
import { LogHelper } from '@/helpers/log-helper'
import { LoaderHelper } from '@/helpers/loader-helper'
import { CPUArchitectures, OSHelper, OSTypes } from '@/helpers/os-helper'
import { SystemHelper } from '@/helpers/system-helper'
/**
* Set up development environment according to the given setup target
@@ -128,19 +129,19 @@ SPACY_MODELS.set('fr', {
const pipfileMtime = fs.statSync(pipfilePath).mtime
const hasDotVenv = fs.existsSync(dotVenvPath)
const { type: osType, cpuArchitecture } = OSHelper.getInformation()
const { type: osType, cpuArchitecture } = SystemHelper.getInformation()
const installPythonPackages = async () => {
LogHelper.info(`Installing Python packages from ${pipfilePath}.lock...`)
// Delete .venv directory to reset the development environment
if (hasDotVenv) {
LogHelper.info(`Deleting ${dotVenvPath}...`)
fs.rmSync(dotVenvPath, { recursive: true, force: true })
await fs.promises.rm(dotVenvPath, { recursive: true, force: true })
LogHelper.success(`${dotVenvPath} deleted`)
}
try {
await command(`pipenv install --verbose --site-packages`, {
await command('pipenv install --verbose --site-packages', {
shell: true,
stdio: 'inherit'
})
@@ -154,21 +155,21 @@ SPACY_MODELS.set('fr', {
LogHelper.info(
'Installing Rust installer as it is needed for the "tokenizers" package for macOS ARM64 architecture...'
)
await command(`curl https://sh.rustup.rs -sSf | sh -s -- -y`, {
await command('curl https://sh.rustup.rs -sSf | sh -s -- -y', {
shell: true,
stdio: 'inherit'
})
LogHelper.success('Rust installer installed')
LogHelper.info('Reloading configuration from "$HOME/.cargo/env"...')
await command(`source "$HOME/.cargo/env"`, {
await command('source "$HOME/.cargo/env"', {
shell: true,
stdio: 'inherit'
})
LogHelper.success('Configuration reloaded')
LogHelper.info('Checking Rust compiler version...')
await command(`rustc --version`, {
await command('rustc --version', {
shell: true,
stdio: 'inherit'
})
@@ -210,7 +211,7 @@ SPACY_MODELS.set('fr', {
await installPythonPackages()
} else {
if (fs.existsSync(dotProjectPath)) {
const dotProjectMtime = fs.statSync(dotProjectPath).mtime
const dotProjectMtime = (await fs.promises.stat(dotProjectPath)).mtime
// Check if Python deps tree has been modified since the initial setup
if (pipfileMtime > dotProjectMtime) {
-102
View File
@@ -1,102 +0,0 @@
import fs from 'node:fs'
import path from 'node:path'
import { commandSync } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
/**
* Setup skills configuration
*/
export default () =>
new Promise(async (resolve, reject) => {
LogHelper.info('Setting up skills configuration...')
const skillDomains = await SkillDomainHelper.getSkillDomains()
for (const currentDomain of skillDomains.values()) {
const skillKeys = Object.keys(currentDomain.skills)
// Browse skills
for (let j = 0; j < skillKeys.length; j += 1) {
const skillFriendlyName = skillKeys[j]
const currentSkill = currentDomain.skills[skillFriendlyName]
const configDir = path.join(currentSkill.path, 'src')
const configFile = path.join(configDir, 'config.json')
const configSampleFile = path.join(configDir, 'config.sample.json')
// If there is a bridge set from the skill config
if (currentSkill.bridge) {
// Check if the config and config.sample file exist
if (fs.existsSync(configFile) && fs.existsSync(configSampleFile)) {
const config = JSON.parse(
fs.readFileSync(configFile, 'utf8')
)?.configurations
const configSample = JSON.parse(
fs.readFileSync(configSampleFile, 'utf8')
)?.configurations
const configKeys = Object.keys(config)
const configSampleKeys = Object.keys(configSample)
// Check if there is a new config key in the config sample compared to the config.json
if (
JSON.stringify(configKeys) !== JSON.stringify(configSampleKeys)
) {
// Browse config keys of the new skill config
for (let j = 0; j < configSampleKeys.length; j += 1) {
// Check if the current config key does not exist
if (configKeys.includes(configSampleKeys[j]) === false) {
LogHelper.info(
`Adding new configuration key "${configSampleKeys[j]}" for the ${skillFriendlyName} skill...`
)
// Prepare to inject the new config key object
const configKey = {
[configSampleKeys[j]]: configSample[configSampleKeys[j]]
}
try {
// Add new skill configuration in the config.json file
commandSync(
`json -I -f ${configFile} -e 'this.configurations.${
configSampleKeys[j]
}=${JSON.stringify(configKey[configSampleKeys[j]])}'`,
{ shell: true }
)
LogHelper.success(
`"${configSampleKeys[j]}" configuration key added to ${configFile}`
)
} catch (e) {
LogHelper.error(
`Error while adding "${configSampleKeys[j]}" configuration key to ${configFile}: ${e}`
)
reject()
}
}
}
}
} else if (!fs.existsSync(configSampleFile)) {
// Stop the setup if the config.sample.json of the current skill does not exist
LogHelper.error(
`The "${skillFriendlyName}" skill configuration file does not exist. Try to pull the project (git pull)`
)
reject()
} else {
// Duplicate config.sample.json of the current skill to config.json
fs.createReadStream(configSampleFile).pipe(
fs.createWriteStream(`${configDir}/config.json`)
)
LogHelper.success(
`"${skillFriendlyName}" skill configuration file created`
)
resolve()
}
}
}
}
LogHelper.success('Skills configured')
resolve()
})
@@ -0,0 +1,65 @@
import path from 'node:path'
import fs from 'node:fs'
import { command } from 'execa'
import { isFileEmpty } from '@/utilities'
import { LogHelper } from '@/helpers/log-helper'
/**
* Install Node.js skills packages on setup
* 1. If skill is Node.js, then verify if an installation is needed
* 2. If install is needed, then install npm packages
*/
export default async function (skillFriendlyName, currentSkill) {
if (currentSkill.bridge === 'nodejs') {
const skillSRCPath = path.join(currentSkill.path, 'src')
const skillPackageJSONPath = path.join(skillSRCPath, 'package.json')
if (fs.existsSync(skillPackageJSONPath)) {
const isPackageJSONEmpty = await isFileEmpty(skillPackageJSONPath)
if (!isPackageJSONEmpty) {
const packageJSONMtime = (await fs.promises.stat(skillPackageJSONPath))
.mtime
const lastSkillNPMInstallFilePath = path.join(
skillSRCPath,
'.last-skill-npm-install'
)
if (fs.existsSync(lastSkillNPMInstallFilePath)) {
const lastSkillNPMInstallTime = new Date(
Number(
await fs.promises.readFile(lastSkillNPMInstallFilePath, 'utf8')
)
)
if (packageJSONMtime <= lastSkillNPMInstallTime) {
LogHelper.success(
`"${skillFriendlyName}" skill npm packages are up-to-date`
)
return
}
}
LogHelper.info(
`Installing npm packages for the "${skillFriendlyName}" skill...`
)
await command(
`npm install --package-lock=false --prefix ${skillSRCPath}`,
{
shell: true
}
)
await fs.promises.writeFile(
lastSkillNPMInstallFilePath,
`${Date.now()}`
)
LogHelper.success(`"${skillFriendlyName}" skill npm packages installed`)
}
}
}
}
@@ -0,0 +1,77 @@
import fs from 'node:fs'
import path from 'node:path'
import { commandSync } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
/**
* Set up skills settings
*/
export default async function (skillFriendlyName, currentSkill) {
const skillSrcPath = path.join(currentSkill.path, 'src')
const settingsPath = path.join(skillSrcPath, 'settings.json')
const settingsSamplePath = path.join(skillSrcPath, 'settings.sample.json')
// If there is a bridge set from the skill settings
if (currentSkill.bridge) {
// Check if the settings and settings.sample file exist
if (fs.existsSync(settingsPath) && fs.existsSync(settingsSamplePath)) {
const settings = JSON.parse(
await fs.promises.readFile(settingsPath, 'utf8')
)
const settingsSample = JSON.parse(
await fs.promises.readFile(settingsSamplePath, 'utf8')
)
const settingsKeys = Object.keys(settings)
const settingsSampleKeys = Object.keys(settingsSample)
// Check if there is a new settings key in the settings sample compared to the settings.json
if (JSON.stringify(settingsKeys) !== JSON.stringify(settingsSampleKeys)) {
// Browse settings keys of the new settings config
for (let j = 0; j < settingsSampleKeys.length; j += 1) {
// Check if the current settings key does not exist
if (!settingsKeys.includes(settingsSampleKeys[j])) {
LogHelper.info(
`Adding new settings key "${settingsSampleKeys[j]}" for the ${skillFriendlyName} skill...`
)
// Prepare to inject the new settings key object
const configKey = {
[settingsSampleKeys[j]]: settingsSample[settingsSampleKeys[j]]
}
try {
// Add new skill settings in the settings.json file
commandSync(
`json -I -f ${settingsPath} -e 'this.${
settingsSampleKeys[j]
}=${JSON.stringify(configKey[settingsSampleKeys[j]])}'`,
{ shell: true }
)
LogHelper.success(
`"${settingsSampleKeys[j]}" settings key added to ${settingsPath}`
)
} catch (e) {
LogHelper.error(
`Error while adding "${settingsSampleKeys[j]}" settings key to ${settingsPath}: ${e}`
)
}
}
}
}
} else if (!fs.existsSync(settingsSamplePath)) {
// Stop the setup if the settings.sample.json of the current skill does not exist
LogHelper.error(
`The "${skillFriendlyName}" skill settings file does not exist. Try to pull the project (git pull)`
)
} else {
// Duplicate settings.sample.json of the current skill to settings.json
fs.createReadStream(settingsSamplePath).pipe(
fs.createWriteStream(`${skillSrcPath}/settings.json`)
)
LogHelper.success(`"${skillFriendlyName}" skill settings file created`)
}
}
}
@@ -0,0 +1,37 @@
import { LogHelper } from '@/helpers/log-helper'
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
import setupSkillsSettings from './setup-skills-settings'
import installNodejsSkillsPackages from './install-nodejs-skills-packages'
/**
* Browse skills and set them up
*/
export default async function () {
LogHelper.info('Setting up skills...')
try {
const skillDomains = await SkillDomainHelper.getSkillDomains()
for (const currentDomain of skillDomains.values()) {
const skillKeys = Object.keys(currentDomain.skills)
// Browse skills
for (let i = 0; i < skillKeys.length; i += 1) {
const skillFriendlyName = skillKeys[i]
const currentSkill = currentDomain.skills[skillFriendlyName]
LogHelper.info(`Setting up "${skillFriendlyName}" skill...`)
await setupSkillsSettings(skillFriendlyName, currentSkill)
await installNodejsSkillsPackages(skillFriendlyName, currentSkill)
LogHelper.success(`"${skillFriendlyName}" skill set up`)
}
}
LogHelper.success('Skills are set up')
} catch (e) {
LogHelper.error(`Failed to set up skills: ${e}`)
}
}

Some files were not shown because too many files have changed in this diff Show More