Skip to content

Commit 4efcfcf

Browse files
iseabockIan Seabock (Centific Technologies Inc)
andauthored
[feature] Add env var to show/hide Chat History Button (microsoft#771)
Co-authored-by: Ian Seabock (Centific Technologies Inc) <v-ianseabock@microsoft.com>
1 parent efc2bfe commit 4efcfcf

File tree

8 files changed

+11
-6
lines changed

8 files changed

+11
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ The interface allows for easy adaptation of the UI by modifying certain elements
148148
- `UI_CHAT_DESCRIPTION`
149149
- `UI_FAVICON`
150150
- `UI_SHOW_SHARE_BUTTON`
151+
- `UI_SHOW_CHAT_HISTORY_BUTTON`
151152

152153
Feel free to fork this repository and make your own modifications to the UX or backend logic. You can modify the source (`frontend/src`). For example, you may want to change aspects of the chat display, or expose some of the settings in `app.py` in the UI for users to try out different behaviors. After your code changes, you will need to rebuild the front-end via `start.sh` or `start.cmd`.
153154

@@ -254,6 +255,7 @@ Note: settings starting with `AZURE_SEARCH` are only needed when using Azure Ope
254255
|UI_CHAT_DESCRIPTION|This chatbot is configured to answer your questions| Description (chat window)
255256
|UI_FAVICON|| Defaults to Contoso favicon. Configure the URL to your favicon to modify.
256257
|UI_SHOW_SHARE_BUTTON|True|Share button (right-top)
258+
|UI_SHOW_CHAT_HISTORY_BUTTON|True|Show chat history button (right-top)
257259
|SANITIZE_ANSWER|False|Whether to sanitize the answer from Azure OpenAI. Set to True to remove any HTML tags from the response.|
258260
|USE_PROMPTFLOW|False|Use existing Promptflow deployed endpoint. If set to `True` then both `PROMPTFLOW_ENDPOINT` and `PROMPTFLOW_API_KEY` also need to be set.|
259261
|PROMPTFLOW_ENDPOINT||URL of the deployed Promptflow endpoint e.g. https://pf-deployment-name.region.inference.ml.azure.com/score|

app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ async def assets(path):
8585
"chat_title": app_settings.ui.chat_title,
8686
"chat_description": app_settings.ui.chat_description,
8787
"show_share_button": app_settings.ui.show_share_button,
88+
"show_chat_history_button": app_settings.ui.show_chat_history_button,
8889
},
8990
"sanitize_answer": app_settings.base_settings.sanitize_answer,
9091
}

backend/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class _UiSettings(BaseSettings):
4848
chat_description: str = "This chatbot is configured to answer your questions"
4949
favicon: str = "/favicon.ico"
5050
show_share_button: bool = True
51+
show_chat_history_button: bool = True
5152

5253

5354
class _ChatHistorySettings(BaseSettings):

frontend/src/api/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export type UI = {
137137
logo?: string
138138
chat_logo?: string
139139
show_share_button?: boolean
140+
show_chat_history_button?: boolean
140141
}
141142

142143
export type FrontendSettings = {

frontend/src/pages/layout/Layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Layout = () => {
4545
}
4646
}, [copyClicked])
4747

48-
useEffect(() => {}, [appStateContext?.state.isCosmosDBAvailable.status])
48+
useEffect(() => { }, [appStateContext?.state.isCosmosDBAvailable.status])
4949

5050
useEffect(() => {
5151
const handleResize = () => {
@@ -77,7 +77,7 @@ const Layout = () => {
7777
</Link>
7878
</Stack>
7979
<Stack horizontal tokens={{ childrenGap: 4 }} className={styles.shareButtonContainer}>
80-
{appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.NotConfigured && (
80+
{appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.NotConfigured && ui?.show_chat_history_button !== false && (
8181
<HistoryButton
8282
onClick={handleHistoryClick}
8383
text={appStateContext?.state?.isChatHistoryOpen ? hideHistoryLabel : showHistoryLabel}

static/assets/index-2e11eaf6.js renamed to static/assets/index-eaff1adf.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/assets/index-2e11eaf6.js.map renamed to static/assets/index-eaff1adf.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" type="image/x-icon" href="{{ favicon }}" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>{{ title }}</title>
8-
<script type="module" crossorigin src="/assets/index-2e11eaf6.js"></script>
8+
<script type="module" crossorigin src="/assets/index-eaff1adf.js"></script>
99
<link rel="stylesheet" href="/assets/index-61492790.css">
1010
</head>
1111
<body>

0 commit comments

Comments
 (0)