Skip to content

Commit 063b64c

Browse files
committed
Refactor chat history configuration variables
Changed variable names to make their functions clearer.
1 parent afc8d1b commit 063b64c

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

app/backend/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
CONFIG_AUTH_CLIENT,
6060
CONFIG_BLOB_CONTAINER_CLIENT,
6161
CONFIG_CHAT_APPROACH,
62-
CONFIG_CHAT_HISTORY_ENABLED,
62+
CONFIG_CHAT_HISTORY_BROWSER_ENABLED,
6363
CONFIG_CHAT_VISION_APPROACH,
6464
CONFIG_CREDENTIAL,
6565
CONFIG_GPT4V_DEPLOYED,
@@ -277,7 +277,7 @@ def config():
277277
"showSpeechInput": current_app.config[CONFIG_SPEECH_INPUT_ENABLED],
278278
"showSpeechOutputBrowser": current_app.config[CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED],
279279
"showSpeechOutputAzure": current_app.config[CONFIG_SPEECH_OUTPUT_AZURE_ENABLED],
280-
"showChatHistory": current_app.config[CONFIG_CHAT_HISTORY_ENABLED],
280+
"showChatHistoryBrowser": current_app.config[CONFIG_CHAT_HISTORY_BROWSER_ENABLED],
281281
}
282282
)
283283

@@ -441,7 +441,7 @@ async def setup_clients():
441441
USE_SPEECH_INPUT_BROWSER = os.getenv("USE_SPEECH_INPUT_BROWSER", "").lower() == "true"
442442
USE_SPEECH_OUTPUT_BROWSER = os.getenv("USE_SPEECH_OUTPUT_BROWSER", "").lower() == "true"
443443
USE_SPEECH_OUTPUT_AZURE = os.getenv("USE_SPEECH_OUTPUT_AZURE", "").lower() == "true"
444-
USE_CHAT_HISTORY = os.getenv("USE_CHAT_HISTORY", "").lower() == "true"
444+
USE_CHAT_HISTORY_BROWSER = os.getenv("USE_CHAT_HISTORY_BROWSER", "").lower() == "true"
445445

446446
# WEBSITE_HOSTNAME is always set by App Service, RUNNING_IN_PRODUCTION is set in main.bicep
447447
RUNNING_ON_AZURE = os.getenv("WEBSITE_HOSTNAME") is not None or os.getenv("RUNNING_IN_PRODUCTION") is not None
@@ -612,7 +612,7 @@ async def setup_clients():
612612
current_app.config[CONFIG_SPEECH_INPUT_ENABLED] = USE_SPEECH_INPUT_BROWSER
613613
current_app.config[CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED] = USE_SPEECH_OUTPUT_BROWSER
614614
current_app.config[CONFIG_SPEECH_OUTPUT_AZURE_ENABLED] = USE_SPEECH_OUTPUT_AZURE
615-
current_app.config[CONFIG_CHAT_HISTORY_ENABLED] = USE_CHAT_HISTORY
615+
current_app.config[CONFIG_CHAT_HISTORY_BROWSER_ENABLED] = USE_CHAT_HISTORY_BROWSER
616616

617617
# Various approaches to integrate GPT and external knowledge, most applications will use a single one of these patterns
618618
# or some derivative, here we include several for exploration purposes

app/backend/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
CONFIG_SPEECH_SERVICE_LOCATION = "speech_service_location"
2323
CONFIG_SPEECH_SERVICE_TOKEN = "speech_service_token"
2424
CONFIG_SPEECH_SERVICE_VOICE = "speech_service_voice"
25-
CONFIG_CHAT_HISTORY_ENABLED = "chat_history_enabled"
25+
CONFIG_CHAT_HISTORY_BROWSER_ENABLED = "chat_history_browser_enabled"

app/frontend/src/api/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export type Config = {
8989
showSpeechInput: boolean;
9090
showSpeechOutputBrowser: boolean;
9191
showSpeechOutputAzure: boolean;
92-
showChatHistory: boolean;
92+
showChatHistoryBrowser: boolean;
9393
};
9494

9595
export type SimpleAPIResponse = {

app/frontend/src/pages/chat/Chat.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const Chat = () => {
8484
const [showSpeechInput, setShowSpeechInput] = useState<boolean>(false);
8585
const [showSpeechOutputBrowser, setShowSpeechOutputBrowser] = useState<boolean>(false);
8686
const [showSpeechOutputAzure, setShowSpeechOutputAzure] = useState<boolean>(false);
87-
const [showChatHistory, setShowChatHistory] = useState<boolean>(false);
87+
const [showChatHistoryBrowser, setShowChatHistoryBrowser] = useState<boolean>(false);
8888
const audio = useRef(new Audio()).current;
8989
const [isPlaying, setIsPlaying] = useState(false);
9090

@@ -110,7 +110,7 @@ const Chat = () => {
110110
setShowSpeechInput(config.showSpeechInput);
111111
setShowSpeechOutputBrowser(config.showSpeechOutputBrowser);
112112
setShowSpeechOutputAzure(config.showSpeechOutputAzure);
113-
setShowChatHistory(config.showChatHistory);
113+
setShowChatHistoryBrowser(config.showChatHistoryBrowser);
114114
});
115115
};
116116

@@ -160,7 +160,7 @@ const Chat = () => {
160160
const client = useLogin ? useMsal().instance : undefined;
161161
const { loggedIn } = useContext(LoginContext);
162162

163-
const historyProvider: HistoryProviderOptions = showChatHistory ? HistoryProviderOptions.IndexedDB : HistoryProviderOptions.None;
163+
const historyProvider: HistoryProviderOptions = showChatHistoryBrowser ? HistoryProviderOptions.IndexedDB : HistoryProviderOptions.None;
164164
const historyManager = useHistoryManager(historyProvider);
165165

166166
const makeApiRequest = async (question: string) => {
@@ -366,7 +366,7 @@ const Chat = () => {
366366
</Helmet>
367367
<div className={styles.commandsSplitContainer}>
368368
<div className={styles.commandsContainer}>
369-
{showChatHistory && <HistoryButton className={styles.commandButton} onClick={() => setIsHistoryPanelOpen(!isHistoryPanelOpen)} />}
369+
{showChatHistoryBrowser && <HistoryButton className={styles.commandButton} onClick={() => setIsHistoryPanelOpen(!isHistoryPanelOpen)} />}
370370
</div>
371371
<div className={styles.commandsContainer}>
372372
<ClearChatButton className={styles.commandButton} onClick={clearChat} disabled={!lastQuestionRef.current || isLoading} />
@@ -475,7 +475,7 @@ const Chat = () => {
475475
/>
476476
)}
477477

478-
{showChatHistory && (
478+
{showChatHistoryBrowser && (
479479
<HistoryPanel
480480
provider={historyProvider}
481481
isOpen={isHistoryPanelOpen}

0 commit comments

Comments
 (0)