Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Start a new chat #484

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading