Skip to content

Commit

Permalink
Merge pull request #8 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tiberiuichim authored Sep 4, 2024
2 parents 1dadf20 + 401c17b commit 6a9d759
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [0.1.2](https://github.com/eea/volto-chatbot/compare/0.1.1...0.1.2) - 13 August 2024
### [0.1.3](https://github.com/eea/volto-chatbot/compare/0.1.2...0.1.3) - 4 September 2024

#### :house: Internal changes

- style: Automated code fix [eea-jenkins - [`fc2b165`](https://github.com/eea/volto-chatbot/commit/fc2b16561c2f633a92ab85b012c7dbe031a5c213)]

#### :hammer_and_wrench: Others

- Remove console log [Tiberiu Ichim - [`a17a8cd`](https://github.com/eea/volto-chatbot/commit/a17a8cdd06da8e2134b81100c166c0d10a8d4f16)]
- Cleanup [Tiberiu Ichim - [`48987e9`](https://github.com/eea/volto-chatbot/commit/48987e985fb5e50625ba63e41f352f05518a3812)]
- Improve chatbot [Tiberiu Ichim - [`89d3cee`](https://github.com/eea/volto-chatbot/commit/89d3cee81cc306cf2e3b4d66cbff0a77c9e7ede6)]
### [0.1.2](https://github.com/eea/volto-chatbot/compare/0.1.1...0.1.2) - 15 August 2024

#### :house: Internal changes

Expand Down Expand Up @@ -77,4 +88,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- yarn bootstrap [alin - [`064d130`](https://github.com/eea/volto-chatbot/commit/064d130ad938a046a4f8dfaa3e78d2fe426c53aa)]
- Initial commit [Tiberiu Ichim - [`c9e59d3`](https://github.com/eea/volto-chatbot/commit/c9e59d3d0d91c2a40c5d215aa26d8ed982fd7856)]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-chatbot",
"version": "0.1.2",
"version": "0.1.3",
"description": "@eeacms/volto-chatbot: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
11 changes: 5 additions & 6 deletions src/ChatBlock/ChatBlockView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import ChatWindow from './ChatWindow';
import superagent from 'superagent';

function ChatBlockView(props) {
const { assistantData } = props;
const { assistantData, data } = props;

return assistantData ? (
<div>
<div>
<ChatWindow persona={assistantData} />
</div>
</div>
<ChatWindow
persona={assistantData}
placeholderPrompt={data.placeholderPrompt}
/>
) : (
<div>Chatbot</div>
);
Expand Down
9 changes: 7 additions & 2 deletions src/ChatBlock/ChatWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import SendIcon from './../icons/send.svg';

import './style.less';

function ChatWindow({ persona, rehypePrism, remarkGfm }) {
function ChatWindow({
persona,
rehypePrism,
remarkGfm,
placeholderPrompt = 'Ask a question',
}) {
const libs = { rehypePrism, remarkGfm }; // rehypePrism, remarkGfm
const { onSubmit, messages, isStreaming, clearChat } = useBackendChat({
persona,
Expand Down Expand Up @@ -91,7 +96,7 @@ function ChatWindow({ persona, rehypePrism, remarkGfm }) {
ref={textareaRef}
value={input}
placeholder={
messages.length > 0 ? 'Ask follow-up...' : 'Placeholder text'
messages.length > 0 ? 'Ask follow-up...' : placeholderPrompt
}
onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => {
Expand Down
6 changes: 5 additions & 1 deletion src/ChatBlock/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ export function ChatBlockSchema({ assistants }) {
{
id: 'default',
title: 'Defalt',
fields: ['assistant'],
fields: ['assistant', 'placeholderPrompt'],
},
],
properties: {
assistant: {
title: 'Assistant',
choices: assistants?.map(({ id, name }) => [id.toString(), name]),
},
placeholderPrompt: {
default: 'Ask a question',
title: 'Prompt',
},
},
required: [],
};
Expand Down
18 changes: 17 additions & 1 deletion src/ChatBlock/withDanswerData.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import React from 'react';
import {
PlaceholderParagraph,
PlaceholderLine,
Placeholder,
} from 'semantic-ui-react';

const Loader = () => (
<Placeholder>
<PlaceholderParagraph>
<PlaceholderLine />
<PlaceholderLine />
<PlaceholderLine />
<PlaceholderLine />
</PlaceholderParagraph>
</Placeholder>
);

export default function withDanswerData(callback) {
function wrapper(Component) {
Expand All @@ -21,7 +37,7 @@ export default function withDanswerData(callback) {
return state ? (
<Component {...props} {...state} />
) : (
<div>Fetching external data...</div>
<Loader active={true} />
);
}
return WrappedComponent;
Expand Down

0 comments on commit 6a9d759

Please sign in to comment.