Skip to content

Commit

Permalink
[feature] Add env var to show/hide Chat History Button (#771)
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Seabock (Centific Technologies Inc) <[email protected]>
  • Loading branch information
iseabock and Ian Seabock (Centific Technologies Inc) committed Jul 10, 2024
1 parent 6bc2752 commit f7aaab3
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ The interface allows for easy adaptation of the UI by modifying certain elements
- `UI_CHAT_DESCRIPTION`
- `UI_FAVICON`
- `UI_SHOW_SHARE_BUTTON`
- `UI_SHOW_CHAT_HISTORY_BUTTON`

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`.

Expand Down Expand Up @@ -254,6 +255,7 @@ Note: settings starting with `AZURE_SEARCH` are only needed when using Azure Ope
|UI_CHAT_DESCRIPTION|This chatbot is configured to answer your questions| Description (chat window)
|UI_FAVICON|| Defaults to Contoso favicon. Configure the URL to your favicon to modify.
|UI_SHOW_SHARE_BUTTON|True|Share button (right-top)
|UI_SHOW_CHAT_HISTORY_BUTTON|True|Show chat history button (right-top)
|SANITIZE_ANSWER|False|Whether to sanitize the answer from Azure OpenAI. Set to True to remove any HTML tags from the response.|
|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.|
|PROMPTFLOW_ENDPOINT||URL of the deployed Promptflow endpoint e.g. https://pf-deployment-name.region.inference.ml.azure.com/score|
Expand Down
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ async def assets(path):
"chat_title": app_settings.ui.chat_title,
"chat_description": app_settings.ui.chat_description,
"show_share_button": app_settings.ui.show_share_button,
"show_chat_history_button": app_settings.ui.show_chat_history_button,
},
"sanitize_answer": app_settings.base_settings.sanitize_answer,
}
Expand Down
1 change: 1 addition & 0 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class _UiSettings(BaseSettings):
chat_description: str = "This chatbot is configured to answer your questions"
favicon: str = "/favicon.ico"
show_share_button: bool = True
show_chat_history_button: bool = True


class _ChatHistorySettings(BaseSettings):
Expand Down
1 change: 1 addition & 0 deletions frontend/src/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export type UI = {
logo?: string
chat_logo?: string
show_share_button?: boolean
show_chat_history_button?: boolean
}

export type FrontendSettings = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Layout = () => {
}
}, [copyClicked])

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

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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/x-icon" href="{{ favicon }}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ title }}</title>
<script type="module" crossorigin src="/assets/index-2e11eaf6.js"></script>
<script type="module" crossorigin src="/assets/index-eaff1adf.js"></script>
<link rel="stylesheet" href="/assets/index-61492790.css">
</head>
<body>
Expand Down

0 comments on commit f7aaab3

Please sign in to comment.