@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/DEVELOP.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# volto-addon-template
|
|
2
|
+
|
|
3
|
+
## Develop
|
|
4
|
+
|
|
5
|
+
1. Make sure you have `docker` and `docker compose` installed and running on your machine:
|
|
6
|
+
|
|
7
|
+
```Bash
|
|
8
|
+
git clone https://github.com/eea/volto-addon-template.git
|
|
9
|
+
cd volto-addon-template
|
|
10
|
+
git checkout -b bugfix-123456 develop
|
|
11
|
+
make
|
|
12
|
+
make start
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
1. Wait for `Volto started at 0.0.0.0:3000` meesage
|
|
16
|
+
|
|
17
|
+
1. Go to http://localhost:3000
|
|
18
|
+
|
|
19
|
+
1. Initialize git hooks
|
|
20
|
+
|
|
21
|
+
```Bash
|
|
22
|
+
yarn prepare
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
1. Happy hacking!
|
|
26
|
+
|
|
27
|
+
### Or add @eeacms/volto-addon-template to your Volto project
|
|
28
|
+
|
|
29
|
+
Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
|
|
30
|
+
|
|
31
|
+
1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`
|
|
32
|
+
|
|
33
|
+
npm install -g yo @plone/generator-volto mrs-developer
|
|
34
|
+
|
|
35
|
+
1. Create new volto app
|
|
36
|
+
|
|
37
|
+
yo @plone/volto my-volto-project --addon @eeacms/volto-addon-template --skip-install
|
|
38
|
+
cd my-volto-project
|
|
39
|
+
|
|
40
|
+
1. Add the following to `mrs.developer.json`:
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
"volto-addon-template": {
|
|
44
|
+
"url": "https://github.com/eea/volto-addon-template.git",
|
|
45
|
+
"package": "@eeacms/volto-addon-template",
|
|
46
|
+
"branch": "develop",
|
|
47
|
+
"path": "src"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
1. Install
|
|
52
|
+
|
|
53
|
+
make develop
|
|
54
|
+
yarn
|
|
55
|
+
|
|
56
|
+
1. Start backend
|
|
57
|
+
|
|
58
|
+
docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend
|
|
59
|
+
|
|
60
|
+
...wait for backend to setup and start - `Ready to handle requests`:
|
|
61
|
+
|
|
62
|
+
...you can also check http://localhost:8080/Plone
|
|
63
|
+
|
|
64
|
+
1. Start frontend
|
|
65
|
+
|
|
66
|
+
yarn start
|
|
67
|
+
|
|
68
|
+
1. Go to http://localhost:3000
|
|
69
|
+
|
|
70
|
+
1. Happy hacking!
|
|
71
|
+
|
|
72
|
+
cd src/addons/volto-addon-template/
|
|
73
|
+
|
|
74
|
+
## Cypress
|
|
75
|
+
|
|
76
|
+
To run cypress locally, first make sure you don't have any Volto/Plone running on ports `8080` and `3000`.
|
|
77
|
+
|
|
78
|
+
You don't have to be in a `clean-volto-project`, you can be in any Volto Frontend
|
|
79
|
+
project where you added `volto-addon-template` to `mrs.developer.json`
|
|
80
|
+
|
|
81
|
+
Go to:
|
|
82
|
+
|
|
83
|
+
```BASH
|
|
84
|
+
cd src/addons/volto-addon-template/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Start:
|
|
88
|
+
|
|
89
|
+
```Bash
|
|
90
|
+
make
|
|
91
|
+
make start
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `volto-addon-template` block installed.
|
|
95
|
+
|
|
96
|
+
Open Cypress Interface:
|
|
97
|
+
|
|
98
|
+
```Bash
|
|
99
|
+
make cypress-open
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or run it:
|
|
103
|
+
|
|
104
|
+
```Bash
|
|
105
|
+
make cypress-run
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Mock develop environment
|
|
109
|
+
|
|
110
|
+
The following environment variables are used in the develop environment:
|
|
111
|
+
|
|
112
|
+
```Bash
|
|
113
|
+
MOCK_INDEX=1
|
|
114
|
+
MOCK_LLM_CALL=true
|
|
115
|
+
MOCK_STREAM_DELAY=1
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You can also dump the Halloumi response by setting:
|
|
119
|
+
|
|
120
|
+
```Bash
|
|
121
|
+
DUMP_HALLOUMI_RESPONSE=1
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
This is kind of exclusive, you don't want to dump if you're mocking the LLM call.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 European Environment Agency
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Volto Chatbot
|
|
2
|
+
|
|
3
|
+
[](https://github.com/eea/volto-eea-chatbot/releases)
|
|
4
|
+
|
|
5
|
+
[](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-eea-chatbot/job/master/display/redirect)
|
|
6
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-master)
|
|
7
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-master)
|
|
8
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-master)
|
|
9
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-master)
|
|
10
|
+
|
|
11
|
+
[](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-eea-chatbot/job/develop/display/redirect)
|
|
12
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-develop)
|
|
13
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-develop)
|
|
14
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-develop)
|
|
15
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-eea-chatbot-develop)
|
|
16
|
+
|
|
17
|
+
[Volto](https://github.com/plone/volto) add-on that integrates an AI-powered chatbot with a customizable interface and advanced settings to tailor its behavior and enhance user interactions.
|
|
18
|
+
|
|
19
|
+
## Upgrade
|
|
20
|
+
|
|
21
|
+
**1.0.0 (Breaking)** - This release introduces breaking changes to the chatbot configuration and API endpoints, making it compatible with Onyx v2.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
https://github.com/user-attachments/assets/f9b5f813-672f-4e4d-81d0-bf2aec35b587
|
|
26
|
+
|
|
27
|
+
The **Volto Chatbot** block allows the integration of an AI-powered chatbot into your Volto project. It offers a customizable interface and advanced settings to tailor the chatbot's behavior to your needs. Below is an overview of its features and configuration options.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Functionalities
|
|
32
|
+
|
|
33
|
+
| **Property** | **Description** | **Type** | **Default** |
|
|
34
|
+
| ---------------------------- | ------------------------------------------------------------------------------- | -------- | -------------------------------- |
|
|
35
|
+
| `assistant` | Choose from the list of available assistants configured in the application. | Dropdown | - |
|
|
36
|
+
| `qgenAsistantId` | Select an assistant for generating related questions. | Dropdown | - |
|
|
37
|
+
| `enableQgen` | Toggle the generation of related questions. | Boolean | `false` |
|
|
38
|
+
| `enableFeedback` | Enable or disable thumbs up/down feedback for assistant responses. | Boolean | `true` |
|
|
39
|
+
| `enableMatomoTracking` | Enable tracking of user interactions via Matomo Analytics. | Boolean | `true` |
|
|
40
|
+
| `enableShowTotalFailMessage` | Show total failure message. | Boolean | `false` |
|
|
41
|
+
| `showAssistantTitle` | Display or hide the assistant's title in the chat interface. | Boolean | `true` |
|
|
42
|
+
| `showAssistantDescription` | Display or hide the assistant's description in the chat interface. | Boolean | `true` |
|
|
43
|
+
| `qualityCheck` | Show Halloumi-based automated quality check. | Dropdown | `Disabled` |
|
|
44
|
+
| `onDemandInputToggle` | Sets the default state of the fact-check AI toggle. | Boolean | `true` |
|
|
45
|
+
| `showTools` | Show or hide tools in the chat interface. | Array | `["internal_search_tool_start"]` |
|
|
46
|
+
| `scrollToInput` | Automatically scroll the page to focus on the chat input when interacting. | Boolean | `false` |
|
|
47
|
+
| `showAssistantPrompts` | Show or hide predefined prompts provided by the assistant. | Boolean | `true` |
|
|
48
|
+
| `enableStarterPrompts` | Define custom prompts to initiate a chat with the assistant. | Boolean | `false` |
|
|
49
|
+
| `starterPromptsHeading` | Heading shown above the prompts. | String | - |
|
|
50
|
+
| `starterPromptsPosition` | Prompts position. | Dropdown | `Top` |
|
|
51
|
+
| `placeholderPrompt` | Set placeholder text for the chat input field. | String | `Ask a question` |
|
|
52
|
+
| `chatTitle` | Title assigned to saved chats, visible only in Onyx or analytics. | String | `Online public chat` |
|
|
53
|
+
| `height` | Set the height of the chat window using CSS dimensions (e.g., `500px`, `70vh`). | String | - |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Getting started
|
|
58
|
+
|
|
59
|
+
### Try volto-eea-chatbot with Docker
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
git clone https://github.com/eea/volto-eea-chatbot.git
|
|
63
|
+
cd volto-eea-chatbot
|
|
64
|
+
make
|
|
65
|
+
make start
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Go to http://localhost:3000
|
|
69
|
+
|
|
70
|
+
### Add volto-eea-chatbot to your Volto project
|
|
71
|
+
|
|
72
|
+
1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
|
|
73
|
+
|
|
74
|
+
```Bash
|
|
75
|
+
docker compose up backend
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
1. Start Volto frontend
|
|
79
|
+
|
|
80
|
+
- If you already have a volto project, just update `package.json`:
|
|
81
|
+
|
|
82
|
+
```JSON
|
|
83
|
+
"addons": [
|
|
84
|
+
"@eeacms/volto-eea-chatbot"
|
|
85
|
+
],
|
|
86
|
+
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@eeacms/volto-eea-chatbot": "*"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- If not, create one:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
npm install -g yo @plone/generator-volto
|
|
96
|
+
yo @plone/volto my-volto-project --canary --addon @eeacms/volto-eea-chatbot
|
|
97
|
+
cd my-volto-project
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
1. Install new add-ons and restart Volto:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
yarn
|
|
104
|
+
yarn start
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Environment Configuration
|
|
108
|
+
|
|
109
|
+
To properly configure the middleware and authenticate with the Onyx service, ensure that the following environment variables are set:
|
|
110
|
+
|
|
111
|
+
This document lists the environment variables used in the Volto Chatbot project.
|
|
112
|
+
|
|
113
|
+
- `ONYX_URL`
|
|
114
|
+
The base URL for the Onyx service. Used for API calls to Onyx.
|
|
115
|
+
|
|
116
|
+
- `ONYX_API_KEY`
|
|
117
|
+
The API key for authenticating with the Onyx service. This is the recommended authentication method.
|
|
118
|
+
|
|
119
|
+
- `JEST_USE_SETUP`
|
|
120
|
+
Used in Jest configuration. When set to 'ON', it enables a specific Jest setup.
|
|
121
|
+
|
|
122
|
+
- `LLMGW_URL`
|
|
123
|
+
The URL for the LLM Gateway service.
|
|
124
|
+
|
|
125
|
+
- `LLMGW_TOKEN`
|
|
126
|
+
The token for authenticating with the LLM Gateway service.
|
|
127
|
+
|
|
128
|
+
### Development-specific environment variables
|
|
129
|
+
|
|
130
|
+
- `MOCK_HALLOUMI_FILE_PATH`
|
|
131
|
+
When set, this specifies the absolute path to the JSON file containing the mocked Halloumi response. Setting this variable enables mocking of Halloumi API calls.
|
|
132
|
+
|
|
133
|
+
- `DUMP_HALLOUMI_FILE_PATH`
|
|
134
|
+
When set, the Halloumi response will be dumped to the specified absolute file path for debugging or to create new mock files.
|
|
135
|
+
|
|
136
|
+
- `MOCK_LLM_FILE_PATH`
|
|
137
|
+
When set, this specifies the absolute path to the JSONL file containing the mocked Onyx stream response. Setting this variable enables mocking of Onyx LLM calls.
|
|
138
|
+
|
|
139
|
+
- `DUMP_LLM_FILE_PATH`
|
|
140
|
+
When set, the LLM response will be dumped to the specified absolute file path for debugging or to create new mock files.
|
|
141
|
+
|
|
142
|
+
- `MOCK_STREAM_DELAY`
|
|
143
|
+
Specifies a delay for mock streaming, used in testing or development.
|
|
144
|
+
|
|
145
|
+
## Release
|
|
146
|
+
|
|
147
|
+
See [RELEASE.md](https://github.com/eea/volto-eea-chatbot/blob/master/RELEASE.md).
|
|
148
|
+
|
|
149
|
+
## How to contribute
|
|
150
|
+
|
|
151
|
+
See [DEVELOP.md](https://github.com/eea/volto-eea-chatbot/blob/master/DEVELOP.md).
|
|
152
|
+
|
|
153
|
+
## Copyright and license
|
|
154
|
+
|
|
155
|
+
The Initial Owner of the Original Code is European Environment Agency (EEA).
|
|
156
|
+
All Rights Reserved.
|
|
157
|
+
|
|
158
|
+
See [LICENSE.md](https://github.com/eea/volto-eea-chatbot/blob/master/LICENSE.md) for details.
|
|
159
|
+
|
|
160
|
+
## Funding
|
|
161
|
+
|
|
162
|
+
[European Environment Agency (EU)](http://eea.europa.eu)
|
|
163
|
+
de is European Environment Agency (EEA).
|
|
164
|
+
All Rights Reserved.
|
|
165
|
+
|
|
166
|
+
See [LICENSE.md](https://github.com/eea/volto-addon-template/blob/master/LICENSE.md) for details.
|
|
167
|
+
|
|
168
|
+
## Funding
|
|
169
|
+
|
|
170
|
+
[European Environment Agency (EU)](http://eea.europa.eu)
|
package/RELEASE.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## Release
|
|
2
|
+
|
|
3
|
+
### Automatic release using Jenkins
|
|
4
|
+
|
|
5
|
+
* The automatic release is started by creating a [Pull Request](../../compare/master...develop) from `develop` to `master`. The pull request status checks correlated to the branch and PR Jenkins jobs need to be processed successfully. 1 review from a github user with rights is mandatory.
|
|
6
|
+
* It runs on every commit on `master` branch, which is protected from direct commits, only allowing pull request merge commits.
|
|
7
|
+
* The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the Readme.md badges and the green check/red cross/yellow circle near the last commit information. If you click on the icon, you will have the list of checks that were run. The `continuous-integration/jenkins/branch` link goes to the Jenkins job execution webpage.
|
|
8
|
+
* Automated release scripts are located in the `eeacms/gitflow` docker image, specifically [js-release.sh](https://github.com/eea/eea.docker.gitflow/blob/master/src/js-release.sh) script. It uses the `release-it` tool.
|
|
9
|
+
* As long as a PR request is open from develop to master, the PR Jenkins job will automatically re-create the CHANGELOG.md and package.json files to be production-ready.
|
|
10
|
+
* The version format must be MAJOR.MINOR.PATCH. By default, next release is set to next minor version (with patch 0).
|
|
11
|
+
* You can manually change the version in `package.json`. The new version must not be already present in the tags/releases of the repository, otherwise it will be automatically increased by the script. Any changes to the version will trigger a `CHANGELOG.md` re-generation.
|
|
12
|
+
* Automated commits and commits with [JENKINS] or [YARN] in the commit log are excluded from `CHANGELOG.md` file.
|
|
13
|
+
|
|
14
|
+
### Manual release from the develop branch ( beta release )
|
|
15
|
+
|
|
16
|
+
#### Installation and configuration of release-it
|
|
17
|
+
|
|
18
|
+
You need to first install the [release-it](https://github.com/release-it/release-it) client.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install -g release-it
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
|
|
25
|
+
|
|
26
|
+
Release-it is a tool that automates 4 important steps in the release process:
|
|
27
|
+
|
|
28
|
+
1. Version increase in `package.json` ( increased from the current version in `package.json`)
|
|
29
|
+
2. `CHANGELOG.md` automatic generation from commit messages ( grouped by releases )
|
|
30
|
+
3. GitHub release on the commit with the changelog and package.json modification on the develop branch
|
|
31
|
+
4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
|
|
32
|
+
|
|
33
|
+
To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Using release-it tool
|
|
46
|
+
|
|
47
|
+
There are 3 yarn scripts that can be run to do the release
|
|
48
|
+
|
|
49
|
+
##### yarn release-beta
|
|
50
|
+
|
|
51
|
+
Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
? Select increment (next version):
|
|
55
|
+
❯ prepatch (0.1.1-beta.0)
|
|
56
|
+
preminor (0.2.0-beta.0)
|
|
57
|
+
premajor (1.0.0-beta.0)
|
|
58
|
+
Other, please specify...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
##### yarn release-major-beta
|
|
62
|
+
|
|
63
|
+
Same as `yarn release-beta`, but with premajor version pre-selected.
|
|
64
|
+
|
|
65
|
+
##### yarn release
|
|
66
|
+
|
|
67
|
+
Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
|
|
68
|
+
|
|
69
|
+
#### Important notes
|
|
70
|
+
|
|
71
|
+
> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
|
|
72
|
+
|
|
73
|
+
> Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
|
|
74
|
+
|
package/TESTING.md
ADDED
package/babel.config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
const presets = ['razzle'];
|
|
4
|
+
const plugins = [
|
|
5
|
+
[
|
|
6
|
+
'react-intl', // React Intl extractor, required for the whole i18n infrastructure to work
|
|
7
|
+
{
|
|
8
|
+
messagesDir: './build/messages/',
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
plugins,
|
|
15
|
+
presets,
|
|
16
|
+
};
|
|
17
|
+
};
|
package/bootstrap
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const ejs = require('ejs');
|
|
4
|
+
|
|
5
|
+
const currentDir = path.basename(process.cwd());
|
|
6
|
+
|
|
7
|
+
const bootstrap = function (ofile) {
|
|
8
|
+
fs.readFile(ofile, 'utf8', function (err, data) {
|
|
9
|
+
if (err) {
|
|
10
|
+
return console.log(err);
|
|
11
|
+
}
|
|
12
|
+
const result = ejs.render(data, {
|
|
13
|
+
addonName: `@eeacms/${currentDir}`,
|
|
14
|
+
name: currentDir
|
|
15
|
+
});
|
|
16
|
+
const output = ofile.replace('.tpl', '');
|
|
17
|
+
fs.writeFile(output, result, 'utf8', function (err) {
|
|
18
|
+
if (err) {
|
|
19
|
+
return console.log(err);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (ofile.includes('.tpl')) {
|
|
23
|
+
fs.unlink(ofile, (err) => {
|
|
24
|
+
if (err) {
|
|
25
|
+
return console.error(err);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fs.readdir(".", { withFileTypes: true }, (err, dirents) => {
|
|
33
|
+
const files = dirents
|
|
34
|
+
.filter(dirent => dirent.isFile())
|
|
35
|
+
.map(dirent => dirent.name);
|
|
36
|
+
files.forEach(function (file) {
|
|
37
|
+
if (file != 'bootstrap') {
|
|
38
|
+
bootstrap(file);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { defineConfig } = require('cypress');
|
|
2
|
+
|
|
3
|
+
module.exports = defineConfig({
|
|
4
|
+
viewportWidth: 1280,
|
|
5
|
+
defaultCommandTimeout: 8888,
|
|
6
|
+
chromeWebSecurity: false,
|
|
7
|
+
reporter: 'junit',
|
|
8
|
+
video: false,
|
|
9
|
+
retries: {
|
|
10
|
+
runMode: 2,
|
|
11
|
+
openMode: 0,
|
|
12
|
+
},
|
|
13
|
+
reporterOptions: {
|
|
14
|
+
mochaFile: 'cypress/reports/cypress-[hash].xml',
|
|
15
|
+
jenkinsMode: true,
|
|
16
|
+
toConsole: true,
|
|
17
|
+
},
|
|
18
|
+
e2e: {
|
|
19
|
+
setupNodeEvents(on, config) {
|
|
20
|
+
// e2e testing node events setup code
|
|
21
|
+
require('@cypress/code-coverage/task')(on, config);
|
|
22
|
+
require('cypress-fail-fast/plugin')(on, config);
|
|
23
|
+
return config;
|
|
24
|
+
},
|
|
25
|
+
baseUrl: 'http://localhost:3000',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
version: "3"
|
|
2
|
+
services:
|
|
3
|
+
backend:
|
|
4
|
+
image: eeacms/plone-backend
|
|
5
|
+
ports:
|
|
6
|
+
- "8080:8080"
|
|
7
|
+
environment:
|
|
8
|
+
SITE: "Plone"
|
|
9
|
+
PROFILES: "eea.kitkat:testing"
|
|
10
|
+
|
|
11
|
+
frontend:
|
|
12
|
+
build:
|
|
13
|
+
context: ./
|
|
14
|
+
dockerfile: ./Dockerfile
|
|
15
|
+
args:
|
|
16
|
+
ADDON_NAME: "${ADDON_NAME}"
|
|
17
|
+
ADDON_PATH: "${ADDON_PATH}"
|
|
18
|
+
VOLTO_VERSION: ${VOLTO_VERSION:-16}
|
|
19
|
+
ports:
|
|
20
|
+
- "3000:3000"
|
|
21
|
+
- "3001:3001"
|
|
22
|
+
depends_on:
|
|
23
|
+
- backend
|
|
24
|
+
volumes:
|
|
25
|
+
- ./:/app/src/addons/${ADDON_PATH}
|
|
26
|
+
environment:
|
|
27
|
+
CI: "true"
|
|
28
|
+
NODE_ENV: "development"
|
|
29
|
+
RAZZLE_JEST_CONFIG: "src/addons/${ADDON_PATH}/jest-addon.config.js"
|
|
30
|
+
RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone"
|
|
31
|
+
RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone"
|
|
32
|
+
HOST: "0.0.0.0"
|