Skip to content

Commit

Permalink
[feature] Add env var to show/hide Chat History Button
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Seabock (Centific Technologies Inc) committed Apr 11, 2024
1 parent 62753bb commit 2976911
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"args": [
"run",
"--no-reload",
"-p 50505"
"-p 5050"
],
"console": "integratedTerminal",
"justMyCode": false,
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,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 @@ -229,6 +230,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
2 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
)
UI_FAVICON = os.environ.get("UI_FAVICON") or "/favicon.ico"
UI_SHOW_SHARE_BUTTON = os.environ.get("UI_SHOW_SHARE_BUTTON", "true").lower() == "true"
UI_SHOW_CHAT_HISTORY_BUTTON = os.environ.get("UI_SHOW_CHAT_HISTORY_BUTTON", "true").lower() == "true"


def create_app():
Expand Down Expand Up @@ -261,6 +262,7 @@ async def assets(path):
"chat_title": UI_CHAT_TITLE,
"chat_description": UI_CHAT_DESCRIPTION,
"show_share_button": UI_SHOW_SHARE_BUTTON,
"show_chat_history_button": UI_SHOW_CHAT_HISTORY_BUTTON,
},
"sanitize_answer": SANITIZE_ANSWER,
}
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 @@ -109,6 +109,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 @@ -79,10 +79,10 @@ 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 &&
<HistoryButton onClick={handleHistoryClick} text={appStateContext?.state?.isChatHistoryOpen ? hideHistoryLabel : showHistoryLabel} />
}
{ui?.show_share_button &&<ShareButton onClick={handleShareClick} text={shareLabel} />}
{ui?.show_share_button && <ShareButton onClick={handleShareClick} text={shareLabel} />}
</Stack>
</Stack>
</header>
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-2d2026f2.js"></script>
<script type="module" crossorigin src="/assets/index-aa031eb2.js"></script>
<link rel="stylesheet" href="/assets/index-81370a29.css">
</head>
<body>
Expand Down

1 comment on commit 2976911

@kagoolastha23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting an application error. Any guide on how to resolve it?

Please sign in to comment.