Skip to content

Commit

Permalink
Merge pull request #484 from aws-samples/hubin-daily
Browse files Browse the repository at this point in the history
feat: Start a new chat
  • Loading branch information
NingLu authored Dec 10, 2024
2 parents e85e1a0 + c8d3314 commit f30fd2e
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 167 deletions.
7 changes: 5 additions & 2 deletions source/portal/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@
.mt-5 {
margin-top: 5px;
}

.chat-container {
.chat-container-layout {
height: calc(100% - 60px);
}
.chat-container {
height: calc(100% - 20px);
display: flex;
flex-direction: column;
justify-content: space-between;
Expand All @@ -63,6 +65,7 @@
overflow: auto;
flex: 1;
padding-bottom: 30px;
height: 100%;
}

.message-content {
Expand Down
17 changes: 17 additions & 0 deletions source/portal/src/layout/CommonLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ import messages from '@cloudscape-design/components/i18n/messages/all.en';
import TopNavigation from '@cloudscape-design/components/top-navigation';
import { useTranslation } from 'react-i18next';
import {
ADITIONAL_SETTRINGS,
ENABLE_TRACE,
CURRENT_CHAT_BOT,
DEFAULT_ZH_LANG,
EN_TEXT,
LANGUAGE_ITEMS,
ZH_LANGUAGE_LIST,
ZH_TEXT,
USE_CHAT_HISTORY,
ONLY_RAG_TOOL,
SCENARIO,
MODEL_OPTION,
MAX_TOKEN,
TEMPERATURE,
} from 'src/utils/const';
import { useAuth } from 'react-oidc-context';
import ConfigContext from 'src/context/config-context';
import { useLocation, useNavigate } from 'react-router-dom';
import CustomBreadCrumb, { BreadCrumbType } from './CustomBreadCrumb';
import { CustomNavigationItem } from 'src/types';
const STORAGE_KEYS = [CURRENT_CHAT_BOT, USE_CHAT_HISTORY, ENABLE_TRACE, ONLY_RAG_TOOL, SCENARIO, MODEL_OPTION, MAX_TOKEN, TEMPERATURE, ADITIONAL_SETTRINGS]

interface CommonLayoutProps {
activeHref: string;
Expand All @@ -48,6 +58,12 @@ const CommonLayout: React.FC<CommonLayoutProps> = ({
i18n.changeLanguage(lng);
};

const clearStorage = () => {
STORAGE_KEYS.forEach(key => {
localStorage.removeItem(key);
})
}

useEffect(() => {
setDisplayName(
auth.user?.profile?.email ||
Expand Down Expand Up @@ -135,6 +151,7 @@ const CommonLayout: React.FC<CommonLayoutProps> = ({
if (item.detail.id === 'signout') {
if (fullLogoutUrl) {
auth.removeUser();
clearStorage()
window.location.href = fullLogoutUrl;
}
auth.removeUser();
Expand Down
4 changes: 3 additions & 1 deletion source/portal/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"signOut": "Sign Out",
"chatSpace": "Chats",
"chat": "Current chat",
"chatDescription": "Click the button on the right to start a new conversation with chatBot",
"chatBot": "Chatbot",
"docLibrary": "Document Library",
"addLibrary": "Add Document",
Expand Down Expand Up @@ -169,7 +170,8 @@
"action": "Action",
"startToChat": "Start to chat",
"discardChanges": "Discard Changes",
"saveChanges": "Save Changes"
"saveChanges": "Save Changes",
"startNewChat": "Start a new chat"
},
"header": {
"reSignIn": "Please login again",
Expand Down
4 changes: 3 additions & 1 deletion source/portal/src/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"signOut": "退出登录",
"chatSpace": "聊天",
"chat": "当前会话",
"chatDescription": "点击右侧按钮开始与机器人的新对话",
"chatBot": "聊天机器人",
"docLibrary": "文档库",
"addLibrary": "添加文档",
Expand Down Expand Up @@ -169,7 +170,8 @@
"action": "操作",
"startToChat": "开始聊天",
"discardChanges": "放弃更改",
"saveChanges": "保存更改"
"saveChanges": "保存更改",
"startNewChat": "开启新的对话"
},
"header": {
"reSignIn": "请重新登录",
Expand Down
Loading

0 comments on commit f30fd2e

Please sign in to comment.