@eeacms/volto-eea-chatbot 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.coverage.babel.config.js +9 -0
- package/.eslintrc.js +68 -0
- package/.husky/pre-commit +2 -0
- package/.release-it.json +17 -0
- package/AGENTS.md +89 -0
- package/CHANGELOG.md +770 -0
- package/DEVELOP.md +124 -0
- package/LICENSE.md +9 -0
- package/README.md +170 -0
- package/RELEASE.md +74 -0
- package/TESTING.md +5 -0
- package/babel.config.js +17 -0
- package/bootstrap +41 -0
- package/cypress.config.js +27 -0
- package/docker-compose.yml +32 -0
- package/jest-addon.config.js +465 -0
- package/jest.setup.js +65 -0
- package/locales/de/LC_MESSAGES/volto.po +14 -0
- package/locales/en/LC_MESSAGES/volto.po +14 -0
- package/locales/it/LC_MESSAGES/volto.po +14 -0
- package/locales/ro/LC_MESSAGES/volto.po +14 -0
- package/locales/volto.pot +16 -0
- package/package.json +98 -0
- package/razzle.extend.js +40 -0
- package/src/ChatBlock/ChatBlockEdit.jsx +46 -0
- package/src/ChatBlock/ChatBlockView.jsx +21 -0
- package/src/ChatBlock/chat/AIMessage.tsx +566 -0
- package/src/ChatBlock/chat/ChatMessage.tsx +35 -0
- package/src/ChatBlock/chat/ChatWindow.tsx +288 -0
- package/src/ChatBlock/chat/UserMessage.tsx +27 -0
- package/src/ChatBlock/chat/index.ts +4 -0
- package/src/ChatBlock/components/AutoResizeTextarea.jsx +67 -0
- package/src/ChatBlock/components/BlinkingDot.tsx +3 -0
- package/src/ChatBlock/components/ChatMessageFeedback.jsx +77 -0
- package/src/ChatBlock/components/EmptyState.jsx +70 -0
- package/src/ChatBlock/components/FeedbackModal.jsx +125 -0
- package/src/ChatBlock/components/HalloumiFeedback.jsx +126 -0
- package/src/ChatBlock/components/Icon.tsx +35 -0
- package/src/ChatBlock/components/QualityCheckToggle.jsx +26 -0
- package/src/ChatBlock/components/RelatedQuestions.jsx +59 -0
- package/src/ChatBlock/components/Source.jsx +93 -0
- package/src/ChatBlock/components/SourceChip.tsx +55 -0
- package/src/ChatBlock/components/Spinner.jsx +3 -0
- package/src/ChatBlock/components/UserActionsToolbar.jsx +44 -0
- package/src/ChatBlock/components/WebResultIcon.tsx +42 -0
- package/src/ChatBlock/components/markdown/Citation.jsx +70 -0
- package/src/ChatBlock/components/markdown/ClaimModal.jsx +98 -0
- package/src/ChatBlock/components/markdown/ClaimSegments.jsx +172 -0
- package/src/ChatBlock/components/markdown/RenderClaimView.jsx +96 -0
- package/src/ChatBlock/components/markdown/colors.js +29 -0
- package/src/ChatBlock/components/markdown/colors.less +52 -0
- package/src/ChatBlock/components/markdown/colors.test.js +69 -0
- package/src/ChatBlock/components/markdown/index.js +115 -0
- package/src/ChatBlock/fonts/DejaVuSans.ttf +0 -0
- package/src/ChatBlock/hocs/withOnyxData.jsx +46 -0
- package/src/ChatBlock/hooks/index.ts +7 -0
- package/src/ChatBlock/hooks/useChatController.ts +333 -0
- package/src/ChatBlock/hooks/useChatStreaming.ts +82 -0
- package/src/ChatBlock/hooks/useDeepCompareMemoize.js +17 -0
- package/src/ChatBlock/hooks/useMarked.js +44 -0
- package/src/ChatBlock/hooks/useQualityMarkers.js +119 -0
- package/src/ChatBlock/hooks/useScrollonStream.ts +131 -0
- package/src/ChatBlock/hooks/useToolDisplayTiming.ts +80 -0
- package/src/ChatBlock/index.js +32 -0
- package/src/ChatBlock/packets/MultiToolRenderer.tsx +235 -0
- package/src/ChatBlock/packets/RendererComponent.tsx +115 -0
- package/src/ChatBlock/packets/index.ts +4 -0
- package/src/ChatBlock/packets/renderers/CustomToolRenderer.tsx +63 -0
- package/src/ChatBlock/packets/renderers/FetchToolRenderer.tsx +59 -0
- package/src/ChatBlock/packets/renderers/ImageToolRenderer.tsx +62 -0
- package/src/ChatBlock/packets/renderers/MessageTextRenderer.tsx +172 -0
- package/src/ChatBlock/packets/renderers/ReasoningRenderer.tsx +122 -0
- package/src/ChatBlock/packets/renderers/SearchToolRenderer.tsx +323 -0
- package/src/ChatBlock/packets/renderers/index.ts +6 -0
- package/src/ChatBlock/schema.js +403 -0
- package/src/ChatBlock/services/index.ts +3 -0
- package/src/ChatBlock/services/messageProcessor.ts +348 -0
- package/src/ChatBlock/services/packetUtils.ts +48 -0
- package/src/ChatBlock/services/streamingService.ts +342 -0
- package/src/ChatBlock/style.less +1881 -0
- package/src/ChatBlock/tests/AIMessage.test.jsx +95 -0
- package/src/ChatBlock/tests/AutoResizeTextarea.test.jsx +49 -0
- package/src/ChatBlock/tests/BlinkingDot.test.jsx +71 -0
- package/src/ChatBlock/tests/ChatMessageFeedback.test.jsx +73 -0
- package/src/ChatBlock/tests/Citation.test.jsx +107 -0
- package/src/ChatBlock/tests/EmptyState.test.jsx +137 -0
- package/src/ChatBlock/tests/FeedbackModal.test.jsx +138 -0
- package/src/ChatBlock/tests/HalloumiFeedback.test.jsx +94 -0
- package/src/ChatBlock/tests/QualityCheckToggle.test.jsx +105 -0
- package/src/ChatBlock/tests/RelatedQuestions.test.jsx +215 -0
- package/src/ChatBlock/tests/Source.test.jsx +79 -0
- package/src/ChatBlock/tests/Spinner.test.jsx +18 -0
- package/src/ChatBlock/tests/index.test.js +51 -0
- package/src/ChatBlock/tests/messageProcessor.test.jsx +154 -0
- package/src/ChatBlock/tests/schema.test.js +166 -0
- package/src/ChatBlock/tests/useDeepCompareMemoize.test.js +107 -0
- package/src/ChatBlock/tests/useToolDisplayTiming.test.jsx +151 -0
- package/src/ChatBlock/types/cssmodules.d.ts +7 -0
- package/src/ChatBlock/types/interfaces.ts +154 -0
- package/src/ChatBlock/types/slate.d.ts +3 -0
- package/src/ChatBlock/types/streamingModels.ts +267 -0
- package/src/ChatBlock/types/volto.d.ts +3 -0
- package/src/ChatBlock/utils/citations.ts +25 -0
- package/src/ChatBlock/utils/index.tsx +114 -0
- package/src/halloumi/README.md +1 -0
- package/src/halloumi/generative.js +219 -0
- package/src/halloumi/generative.test.js +88 -0
- package/src/halloumi/middleware.js +70 -0
- package/src/halloumi/postprocessing.js +273 -0
- package/src/halloumi/postprocessing.test.js +441 -0
- package/src/halloumi/preprocessing.js +115 -0
- package/src/halloumi/preprocessing.test.js +245 -0
- package/src/icons/bot.svg +1 -0
- package/src/icons/check.svg +1 -0
- package/src/icons/chevron.svg +3 -0
- package/src/icons/clear.svg +1 -0
- package/src/icons/copy.svg +1 -0
- package/src/icons/done.svg +5 -0
- package/src/icons/external-link.svg +1 -0
- package/src/icons/file.svg +1 -0
- package/src/icons/glasses.svg +1 -0
- package/src/icons/globe.svg +1 -0
- package/src/icons/rotate.svg +1 -0
- package/src/icons/search.svg +5 -0
- package/src/icons/send.svg +1 -0
- package/src/icons/square-pen.svg +1 -0
- package/src/icons/stop.svg +9 -0
- package/src/icons/thumbs-down.svg +1 -0
- package/src/icons/thumbs-up.svg +1 -0
- package/src/icons/user.svg +1 -0
- package/src/index.js +58 -0
- package/src/middleware.js +250 -0
- package/tsconfig.json +40 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const projectRootPath = fs.realpathSync(__dirname + '/../../../');
|
|
4
|
+
|
|
5
|
+
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
6
|
+
let configFile;
|
|
7
|
+
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
|
|
8
|
+
configFile = `${projectRootPath}/tsconfig.json`;
|
|
9
|
+
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
|
|
10
|
+
configFile = `${projectRootPath}/jsconfig.json`;
|
|
11
|
+
|
|
12
|
+
if (configFile) {
|
|
13
|
+
const jsConfig = require(configFile).compilerOptions;
|
|
14
|
+
const pathsConfig = jsConfig.paths;
|
|
15
|
+
if (pathsConfig['@plone/volto'])
|
|
16
|
+
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
20
|
+
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
21
|
+
|
|
22
|
+
// Extends ESlint configuration for adding aliases to `src` directories in Volto addons
|
|
23
|
+
const addonAliases = Object.keys(reg.packages).map((o) => [
|
|
24
|
+
o,
|
|
25
|
+
reg.packages[o].modulePath,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
|
|
29
|
+
|
|
30
|
+
const defaultConfig = {
|
|
31
|
+
extends: `${voltoPath}/.eslintrc`,
|
|
32
|
+
settings: {
|
|
33
|
+
'import/resolver': {
|
|
34
|
+
alias: {
|
|
35
|
+
map: [
|
|
36
|
+
['@plone/volto', '@plone/volto/src'],
|
|
37
|
+
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
|
|
38
|
+
...addonAliases,
|
|
39
|
+
['@package', `${__dirname}/src`],
|
|
40
|
+
['@root', `${__dirname}/src`],
|
|
41
|
+
['~', `${__dirname}/src`],
|
|
42
|
+
],
|
|
43
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
|
|
44
|
+
},
|
|
45
|
+
'babel-plugin-root-import': {
|
|
46
|
+
rootPathSuffix: 'src',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
'react/jsx-no-target-blank': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
allowReferrer: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
// 'import/no-unresolved': 'off',
|
|
58
|
+
'no-console': 'off',
|
|
59
|
+
// 'react-hooks/exhaustive-deps': 'warn',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const config = addonExtenders.reduce(
|
|
64
|
+
(acc, extender) => extender.modify(acc),
|
|
65
|
+
defaultConfig,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
module.exports = config;
|
package/.release-it.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"npm": {
|
|
3
|
+
"publish": false
|
|
4
|
+
},
|
|
5
|
+
"git": {
|
|
6
|
+
"changelog": "npx auto-changelog --stdout --commit-limit false -u --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs",
|
|
7
|
+
"tagName": "${version}"
|
|
8
|
+
},
|
|
9
|
+
"github": {
|
|
10
|
+
"release": true,
|
|
11
|
+
"releaseName": "${version}",
|
|
12
|
+
"releaseNotes": "npx auto-changelog --stdout --commit-limit false -u --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
|
|
13
|
+
},
|
|
14
|
+
"hooks": {
|
|
15
|
+
"after:bump": "npx auto-changelog --commit-limit false -p"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Project Overview: Volto Chatbot
|
|
2
|
+
|
|
3
|
+
This project is a Volto add-on designed to integrate an AI-powered chatbot
|
|
4
|
+
into a Volto
|
|
5
|
+
(React-based frontend for Plone) project. It provides a customizable
|
|
6
|
+
interface and advanced
|
|
7
|
+
settings to tailor the chatbot's behavior and enhance user interactions. The chatbot
|
|
8
|
+
integrates with the Onyx service for its AI capabilities.
|
|
9
|
+
|
|
10
|
+
**Key Technologies:**
|
|
11
|
+
|
|
12
|
+
- **Frontend:** React, Volto (Plone frontend framework)
|
|
13
|
+
- **Backend Integration:** Onyx service
|
|
14
|
+
- **Development Tools:** Node.js, Cypress (E2E testing), Jest (unit testing),
|
|
15
|
+
ESLint (linting), Prettier (code formatting), Stylelint (CSS linting).
|
|
16
|
+
|
|
17
|
+
### Integrating into an Existing Volto Project
|
|
18
|
+
|
|
19
|
+
1. **Ensure Plone Backend is Running:** Make sure you have a Plone backend up
|
|
20
|
+
and running, typically at `http://localhost:8080/Plone`. You can start it
|
|
21
|
+
with Docker:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
docker compose up backend
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. **Update `package.json`:** In your Volto project's `package.json`,
|
|
28
|
+
add `@eeacms/volto-eea-chatbot` to the `addons` array
|
|
29
|
+
and `dependencies`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
"addons": [
|
|
33
|
+
"@eeacms/volto-eea-chatbot"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@eeacms/volto-eea-chatbot": "*"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. **Install and Start:**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
yarn install
|
|
44
|
+
yarn start
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Environment Configuration
|
|
48
|
+
|
|
49
|
+
The project requires specific environment variables for Onyx service
|
|
50
|
+
authentication. Create a `.env` file in your project root with the following content:
|
|
51
|
+
|
|
52
|
+
```env
|
|
53
|
+
ONYX_URL=https://api.onyx.com
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- `ONYX_URL`: The base URL of the Onyx service.
|
|
57
|
+
|
|
58
|
+
## Development Conventions
|
|
59
|
+
|
|
60
|
+
The project adheres to several development conventions to maintain code quality
|
|
61
|
+
and consistency.
|
|
62
|
+
|
|
63
|
+
- **Linting:**
|
|
64
|
+
- Run ESLint checks: `make lint`
|
|
65
|
+
- Fix ESLint issues automatically: `make lint-fix`
|
|
66
|
+
- **Code Formatting:**
|
|
67
|
+
- Check code formatting with Prettier: `make prettier`
|
|
68
|
+
- Fix formatting issues automatically: `make prettier-fix`
|
|
69
|
+
- **Styling (CSS/LESS):**
|
|
70
|
+
- Run Stylelint checks: `make stylelint`
|
|
71
|
+
- Fix Stylelint issues automatically: `make stylelint-fix`
|
|
72
|
+
- **Testing:**
|
|
73
|
+
- Run unit tests (likely Jest): `make test`
|
|
74
|
+
- Update snapshots for tests: `make test-update`
|
|
75
|
+
- Run Cypress end-to-end tests in headless mode: `make cypress-run`
|
|
76
|
+
- Open Cypress test runner: `make cypress-open`
|
|
77
|
+
- **Specific test file:** To test the addon, run
|
|
78
|
+
`make addon-test TEST_FILE=src/addons/volto-eea-chatbot/src`. To test a specific file,
|
|
79
|
+
for example `preprocessing.test.js`, run
|
|
80
|
+
`make addon-test TEST_FILE=src/addons/volto-eea-chatbot/src/halloumi/preprocessing.test.js`
|
|
81
|
+
- **Pre-commit Hook:** A `pre-commit` hook is configured to automatically run
|
|
82
|
+
`stylelint:fix`, `prettier:fix`, and `lint:fix` before each commit.
|
|
83
|
+
- **Internationalization:** Generate translation files: `make i18n`
|
|
84
|
+
- **Git Workflow:** When committing changes, always use `git status` to review
|
|
85
|
+
changes and then `git add <relevant files changed>` to stage specific files,
|
|
86
|
+
instead of `git add .`.
|
|
87
|
+
|
|
88
|
+
For more detailed contribution guidelines, refer to `DEVELOP.md`.
|
|
89
|
+
For release procedures, refer to `RELEASE.md`.
|