Skip to content

Commit

Permalink
Merge pull request #506 from aws-samples/hubin-daily
Browse files Browse the repository at this point in the history
fix: input component issues when pages opened by firefox
  • Loading branch information
NingLu authored Jan 7, 2025
2 parents 1c8bdf0 + 70163d3 commit 39d6418
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
27 changes: 13 additions & 14 deletions source/portal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion source/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"preview": "vite preview"
},
"dependencies": {
"@cloudscape-design/component-toolkit": "^1.0.0-beta.81",
"@cloudscape-design/components": "^3.0.604",
"@cloudscape-design/global-styles": "^1.0.27",
"axios": "^1.7.4",
Expand Down
34 changes: 23 additions & 11 deletions source/portal/src/pages/chatbot/ChatBot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
setTemperature(defaultConfig.temperature)
setTopKRetrievals(defaultConfig.topKRetrievals)
setScore(defaultConfig.score)
setUserMessage('')
setAdditionalConfig('')
// setModelOption(optionList?.[0]?.value ?? '')
setSessionId(uuidv4());
Expand Down Expand Up @@ -392,13 +393,16 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
}
};

document.addEventListener('compositionstart', () => {
setIsComposing(true);
});
const inputElement = document.querySelector('input');

document.addEventListener('compositionend', () => {
setIsComposing(false);
});
if (inputElement) {
inputElement.addEventListener('compositionstart', () => {
setIsComposing(true);
});
inputElement.addEventListener('compositionend', () => {
setIsComposing(false);
});
}

useEffect(() => {
if (lastMessage !== null) {
Expand Down Expand Up @@ -467,23 +471,25 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
}

if (!maxRounds.trim()) {
setMaxTokenError('validation.requireMaxRounds');
setMaxRoundsError('validation.requireMaxRounds');
setModelSettingExpand(true);
return;
}

if (parseInt(maxRounds) < 0) {
setMaxTokenError('validation.maxRoundsRange');
setMaxRoundsError('validation.maxRoundsRange');
setModelSettingExpand(true);
return;
}

if (!topKRetrievals.trim()) {
setMaxTokenError('validation.requireTopKRetrievals');
setTopKRetrievalsError('validation.requireTopKRetrievals');
setModelSettingExpand(true);
return;
}

if (parseInt(topKRetrievals) < 1) {
setMaxTokenError('validation.topKRetrievals');
setTopKRetrievalsError('validation.topKRetrievals');
setModelSettingExpand(true);
return;
}
Expand Down Expand Up @@ -790,6 +796,9 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
type="number"
value={maxRounds}
onChange={({ detail }) => {
if(parseInt(detail.value) < 0 || parseInt(detail.value) > 100){
return
}
setMaxRoundsError('');
setMaxRounds(detail.value);
}}
Expand Down Expand Up @@ -851,6 +860,9 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
type="number"
value={topKRetrievals}
onChange={({ detail }) => {
if(parseInt(detail.value) < 0 || parseInt(detail.value) > 100){
return
}
setTopKRetrievalsError('');
setTopKRetrievals(detail.value);
}}
Expand All @@ -864,7 +876,7 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
>
<Input
type="number"
step={0.1}
step={0.01}
value={score}
onChange={({ detail }) => {
if(parseFloat(detail.value) < 0 || parseFloat(detail.value) > 1){
Expand Down

0 comments on commit 39d6418

Please sign in to comment.