Skip to content

Commit 9073b65

Browse files
bnodirpamelafox
andauthored
Frontend multi-language support #1690 (#1790)
* WIP: Frontend multi-language support #1690 * WIP(2): Merge branch 'main' into multiLang * WIP(4): Implement language switching for File Upload Feature * Playwright fail fix * Merge with main * Merge fix * Use fluent dropdown and add label to language picker * Use string instead of String * Pin mypy * Reflecting changes based on review comments * Reflecting changes based on review comments-2 * Make the language picker optional * Fixes in docs/deploy_features.md * Revert changes made to package-lock.json * minor fix * minor fix * Playwright fail fix * Use the language value in the API payload * merge --------- Co-authored-by: Pamela Fox <[email protected]> Co-authored-by: Pamela Fox <[email protected]>
1 parent eb5627c commit 9073b65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1157
-201
lines changed

.azdo/pipelines/azure-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ steps:
8686
AZURE_COMPUTER_VISION_RESOURCE_GROUP: $(AZURE_COMPUTER_VISION_RESOURCE_GROUP)
8787
AZURE_COMPUTER_VISION_LOCATION: $(AZURE_COMPUTER_VISION_LOCATION)
8888
AZURE_COMPUTER_VISION_SKU: $(AZURE_COMPUTER_VISION_SKU)
89+
ENABLE_LANGUAGE_PICKER: $(ENABLE_LANGUAGE_PICKER)
8990
USE_SPEECH_INPUT_BROWSER: $(USE_SPEECH_INPUT_BROWSER)
9091
USE_SPEECH_OUTPUT_BROWSER: $(USE_SPEECH_OUTPUT_BROWSER)
9192
USE_SPEECH_OUTPUT_AZURE: $(USE_SPEECH_OUTPUT_AZURE)

.github/workflows/azure-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
USE_GPT4V: ${{ vars.USE_GPT4V }}
7474
AZURE_VISION_ENDPOINT: ${{ vars.AZURE_VISION_ENDPOINT }}
7575
VISION_SECRET_NAME: ${{ vars.VISION_SECRET_NAME }}
76+
ENABLE_LANGUAGE_PICKER: ${{ vars.ENABLE_LANGUAGE_PICKER }}
7677
USE_SPEECH_INPUT_BROWSER: ${{ vars.USE_SPEECH_INPUT_BROWSER }}
7778
USE_SPEECH_OUTPUT_BROWSER: ${{ vars.USE_SPEECH_OUTPUT_BROWSER }}
7879
USE_SPEECH_OUTPUT_AZURE: ${{ vars.USE_SPEECH_OUTPUT_AZURE }}

app/backend/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
CONFIG_CREDENTIAL,
6060
CONFIG_GPT4V_DEPLOYED,
6161
CONFIG_INGESTER,
62+
CONFIG_LANGUAGE_PICKER_ENABLED,
6263
CONFIG_OPENAI_CLIENT,
6364
CONFIG_SEARCH_CLIENT,
6465
CONFIG_SEMANTIC_RANKER_DEPLOYED,
@@ -267,6 +268,7 @@ def config():
267268
"showSemanticRankerOption": current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED],
268269
"showVectorOption": current_app.config[CONFIG_VECTOR_SEARCH_ENABLED],
269270
"showUserUpload": current_app.config[CONFIG_USER_UPLOAD_ENABLED],
271+
"showLanguagePicker": current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED],
270272
"showSpeechInput": current_app.config[CONFIG_SPEECH_INPUT_ENABLED],
271273
"showSpeechOutputBrowser": current_app.config[CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED],
272274
"showSpeechOutputAzure": current_app.config[CONFIG_SPEECH_OUTPUT_AZURE_ENABLED],
@@ -429,6 +431,7 @@ async def setup_clients():
429431

430432
USE_GPT4V = os.getenv("USE_GPT4V", "").lower() == "true"
431433
USE_USER_UPLOAD = os.getenv("USE_USER_UPLOAD", "").lower() == "true"
434+
ENABLE_LANGUAGE_PICKER = os.getenv("ENABLE_LANGUAGE_PICKER", "").lower() == "true"
432435
USE_SPEECH_INPUT_BROWSER = os.getenv("USE_SPEECH_INPUT_BROWSER", "").lower() == "true"
433436
USE_SPEECH_OUTPUT_BROWSER = os.getenv("USE_SPEECH_OUTPUT_BROWSER", "").lower() == "true"
434437
USE_SPEECH_OUTPUT_AZURE = os.getenv("USE_SPEECH_OUTPUT_AZURE", "").lower() == "true"
@@ -576,6 +579,7 @@ async def setup_clients():
576579
current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED] = AZURE_SEARCH_SEMANTIC_RANKER != "disabled"
577580
current_app.config[CONFIG_VECTOR_SEARCH_ENABLED] = os.getenv("USE_VECTORS", "").lower() != "false"
578581
current_app.config[CONFIG_USER_UPLOAD_ENABLED] = bool(USE_USER_UPLOAD)
582+
current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED] = ENABLE_LANGUAGE_PICKER
579583
current_app.config[CONFIG_SPEECH_INPUT_ENABLED] = USE_SPEECH_INPUT_BROWSER
580584
current_app.config[CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED] = USE_SPEECH_OUTPUT_BROWSER
581585
current_app.config[CONFIG_SPEECH_OUTPUT_AZURE_ENABLED] = USE_SPEECH_OUTPUT_AZURE

app/backend/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
CONFIG_SEARCH_CLIENT = "search_client"
1515
CONFIG_OPENAI_CLIENT = "openai_client"
1616
CONFIG_INGESTER = "ingester"
17+
CONFIG_LANGUAGE_PICKER_ENABLED = "language_picker_enabled"
1718
CONFIG_SPEECH_INPUT_ENABLED = "speech_input_enabled"
1819
CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED = "speech_output_browser_enabled"
1920
CONFIG_SPEECH_OUTPUT_AZURE_ENABLED = "speech_output_azure_enabled"

app/frontend/package-lock.json

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

app/frontend/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
"@fluentui/react-icons": "^2.0.249",
2020
"@react-spring/web": "^9.7.3",
2121
"dompurify": "^3.0.6",
22+
"i18next": "^23.12.2",
23+
"i18next-browser-languagedetector": "^8.0.0",
24+
"i18next-http-backend": "^2.5.2",
2225
"ndjson-readablestream": "^1.2.0",
2326
"react": "^18.3.1",
2427
"react-dom": "^18.3.1",
2528
"react-markdown": "^9.0.1",
2629
"react-router-dom": "^6.23.1",
30+
"react-helmet-async": "^2.0.5",
31+
"react-i18next": "^15.0.0",
2732
"react-syntax-highlighter": "^15.5.0",
2833
"rehype-raw": "^7.0.0",
2934
"remark-gfm": "^4.0.0",

app/frontend/src/api/models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type ChatAppRequestOverrides = {
3535
use_gpt4v?: boolean;
3636
gpt4v_input?: GPT4VInput;
3737
vector_fields: VectorFieldOptions[];
38+
language: string;
3839
};
3940

4041
export type ResponseMessage = {
@@ -84,6 +85,7 @@ export type Config = {
8485
showSemanticRankerOption: boolean;
8586
showVectorOption: boolean;
8687
showUserUpload: boolean;
88+
showLanguagePicker: boolean;
8789
showSpeechInput: boolean;
8890
showSpeechOutputBrowser: boolean;
8991
showSpeechOutputAzure: boolean;

app/frontend/src/components/AnalysisPanel/AnalysisPanel.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Stack, Pivot, PivotItem } from "@fluentui/react";
2-
2+
import { useTranslation } from "react-i18next";
33
import styles from "./AnalysisPanel.module.css";
44

55
import { SupportingContent } from "../SupportingContent";
@@ -30,6 +30,7 @@ export const AnalysisPanel = ({ answer, activeTab, activeCitation, citationHeigh
3030
const [citation, setCitation] = useState("");
3131

3232
const client = useLogin ? useMsal().instance : undefined;
33+
const { t } = useTranslation();
3334

3435
const fetchCitation = async () => {
3536
const token = client ? await getToken(client) : undefined;
@@ -78,21 +79,21 @@ export const AnalysisPanel = ({ answer, activeTab, activeCitation, citationHeigh
7879
>
7980
<PivotItem
8081
itemKey={AnalysisPanelTabs.ThoughtProcessTab}
81-
headerText="Thought process"
82+
headerText={t("headerTexts.thoughtProcess")}
8283
headerButtonProps={isDisabledThoughtProcessTab ? pivotItemDisabledStyle : undefined}
8384
>
8485
<ThoughtProcess thoughts={answer.context.thoughts || []} />
8586
</PivotItem>
8687
<PivotItem
8788
itemKey={AnalysisPanelTabs.SupportingContentTab}
88-
headerText="Supporting content"
89+
headerText={t("headerTexts.supportingContent")}
8990
headerButtonProps={isDisabledSupportingContentTab ? pivotItemDisabledStyle : undefined}
9091
>
9192
<SupportingContent supportingContent={answer.context.data_points} />
9293
</PivotItem>
9394
<PivotItem
9495
itemKey={AnalysisPanelTabs.CitationTab}
95-
headerText="Citation"
96+
headerText={t("headerTexts.citation")}
9697
headerButtonProps={isDisabledCitationTab ? pivotItemDisabledStyle : undefined}
9798
>
9899
{renderFileViewer()}

0 commit comments

Comments
 (0)