Skip to content

Commit 6000a61

Browse files
authored
Merge branch 'main' into beta-release-rework
2 parents dbed769 + 8caa5bf commit 6000a61

File tree

116 files changed

+3114
-656
lines changed

Some content is hidden

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

116 files changed

+3114
-656
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-validation.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
- name: Build Bicep for linting
2323
uses: azure/CLI@v2
2424
with:
25-
inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout
25+
inlineScript: |
26+
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
27+
az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout
2628
2729
psrule:
2830
runs-on: ubuntu-latest
@@ -42,7 +44,7 @@ jobs:
4244
outputPath: reports/ps-rule-results.sarif
4345
summary: true
4446
continue-on-error: true
45-
47+
4648
env:
4749
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION: 'true'
4850
PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION_TIMEOUT: '30'

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

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ Follow these steps to provision Azure resources and deploy the application code:
134134
azd auth login
135135
```
136136

137+
For GitHub Codespaces users, if the previous command fails, try:
138+
```shell
139+
azd auth login --use-device-code
140+
```
141+
137142
1. Create a new azd environment:
138143

139144
```shell

app/backend/app.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
SpeechSynthesizer,
1717
)
1818
from azure.core.exceptions import ResourceNotFoundError
19-
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
19+
from azure.identity.aio import (
20+
AzureDeveloperCliCredential,
21+
ManagedIdentityCredential,
22+
get_bearer_token_provider,
23+
)
2024
from azure.monitor.opentelemetry import configure_azure_monitor
2125
from azure.search.documents.aio import SearchClient
2226
from azure.search.documents.indexes.aio import SearchIndexClient
@@ -59,6 +63,7 @@
5963
CONFIG_CREDENTIAL,
6064
CONFIG_GPT4V_DEPLOYED,
6165
CONFIG_INGESTER,
66+
CONFIG_LANGUAGE_PICKER_ENABLED,
6267
CONFIG_OPENAI_CLIENT,
6368
CONFIG_SEARCH_CLIENT,
6469
CONFIG_SEMANTIC_RANKER_DEPLOYED,
@@ -267,6 +272,7 @@ def config():
267272
"showSemanticRankerOption": current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED],
268273
"showVectorOption": current_app.config[CONFIG_VECTOR_SEARCH_ENABLED],
269274
"showUserUpload": current_app.config[CONFIG_USER_UPLOAD_ENABLED],
275+
"showLanguagePicker": current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED],
270276
"showSpeechInput": current_app.config[CONFIG_SPEECH_INPUT_ENABLED],
271277
"showSpeechOutputBrowser": current_app.config[CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED],
272278
"showSpeechOutputAzure": current_app.config[CONFIG_SPEECH_OUTPUT_AZURE_ENABLED],
@@ -429,15 +435,26 @@ async def setup_clients():
429435

430436
USE_GPT4V = os.getenv("USE_GPT4V", "").lower() == "true"
431437
USE_USER_UPLOAD = os.getenv("USE_USER_UPLOAD", "").lower() == "true"
438+
ENABLE_LANGUAGE_PICKER = os.getenv("ENABLE_LANGUAGE_PICKER", "").lower() == "true"
432439
USE_SPEECH_INPUT_BROWSER = os.getenv("USE_SPEECH_INPUT_BROWSER", "").lower() == "true"
433440
USE_SPEECH_OUTPUT_BROWSER = os.getenv("USE_SPEECH_OUTPUT_BROWSER", "").lower() == "true"
434441
USE_SPEECH_OUTPUT_AZURE = os.getenv("USE_SPEECH_OUTPUT_AZURE", "").lower() == "true"
435442

436-
# Use the current user identity to authenticate with Azure OpenAI, AI Search and Blob Storage (no secrets needed,
437-
# just use 'az login' locally, and managed identity when deployed on Azure). If you need to use keys, use separate AzureKeyCredential instances with the
438-
# keys for each service
439-
# If you encounter a blocking error during a DefaultAzureCredential resolution, you can exclude the problematic credential by using a parameter (ex. exclude_shared_token_cache_credential=True)
440-
azure_credential = DefaultAzureCredential(exclude_shared_token_cache_credential=True)
443+
# Use the current user identity for keyless authentication to Azure services.
444+
# This assumes you use 'azd auth login' locally, and managed identity when deployed on Azure.
445+
# The managed identity is setup in the infra/ folder.
446+
azure_credential: Union[AzureDeveloperCliCredential, ManagedIdentityCredential]
447+
if os.getenv("WEBSITE_HOSTNAME"): # Environment variable set on Azure Web Apps
448+
current_app.logger.info("Setting up Azure credential using ManagedIdentityCredential")
449+
azure_credential = ManagedIdentityCredential()
450+
elif AZURE_TENANT_ID:
451+
current_app.logger.info(
452+
"Setting up Azure credential using AzureDeveloperCliCredential with tenant_id %s", AZURE_TENANT_ID
453+
)
454+
azure_credential = AzureDeveloperCliCredential(tenant_id=AZURE_TENANT_ID, process_timeout=60)
455+
else:
456+
current_app.logger.info("Setting up Azure credential using AzureDeveloperCliCredential for home tenant")
457+
azure_credential = AzureDeveloperCliCredential(process_timeout=60)
441458

442459
# Set up clients for AI Search and Storage
443460
search_client = SearchClient(
@@ -576,6 +593,7 @@ async def setup_clients():
576593
current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED] = AZURE_SEARCH_SEMANTIC_RANKER != "disabled"
577594
current_app.config[CONFIG_VECTOR_SEARCH_ENABLED] = os.getenv("USE_VECTORS", "").lower() != "false"
578595
current_app.config[CONFIG_USER_UPLOAD_ENABLED] = bool(USE_USER_UPLOAD)
596+
current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED] = ENABLE_LANGUAGE_PICKER
579597
current_app.config[CONFIG_SPEECH_INPUT_ENABLED] = USE_SPEECH_INPUT_BROWSER
580598
current_app.config[CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED] = USE_SPEECH_OUTPUT_BROWSER
581599
current_app.config[CONFIG_SPEECH_OUTPUT_AZURE_ENABLED] = USE_SPEECH_OUTPUT_AZURE

app/backend/approaches/chatreadretrieveread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def run_until_final_call(
197197
"thoughts": [
198198
ThoughtStep(
199199
"Prompt to generate search query",
200-
[str(message) for message in query_messages],
200+
query_messages,
201201
(
202202
{"model": self.chatgpt_model, "deployment": self.chatgpt_deployment}
203203
if self.chatgpt_deployment
@@ -222,7 +222,7 @@ async def run_until_final_call(
222222
),
223223
ThoughtStep(
224224
"Prompt to generate answer",
225-
[str(message) for message in messages],
225+
messages,
226226
(
227227
{"model": self.chatgpt_model, "deployment": self.chatgpt_deployment}
228228
if self.chatgpt_deployment

app/backend/approaches/chatreadretrievereadvision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def run_until_final_call(
200200
"thoughts": [
201201
ThoughtStep(
202202
"Prompt to generate search query",
203-
[str(message) for message in query_messages],
203+
query_messages,
204204
(
205205
{"model": query_model, "deployment": query_deployment}
206206
if query_deployment
@@ -225,7 +225,7 @@ async def run_until_final_call(
225225
),
226226
ThoughtStep(
227227
"Prompt to generate answer",
228-
[str(message) for message in messages],
228+
messages,
229229
(
230230
{"model": self.gpt4v_model, "deployment": self.gpt4v_deployment}
231231
if self.gpt4v_deployment

app/backend/approaches/retrievethenread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async def run(
155155
),
156156
ThoughtStep(
157157
"Prompt to generate answer",
158-
[str(message) for message in updated_messages],
158+
updated_messages,
159159
(
160160
{"model": self.chatgpt_model, "deployment": self.chatgpt_deployment}
161161
if self.chatgpt_deployment

app/backend/approaches/retrievethenreadvision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async def run(
177177
),
178178
ThoughtStep(
179179
"Prompt to generate answer",
180-
[str(message) for message in updated_messages],
180+
updated_messages,
181181
(
182182
{"model": self.gpt4v_model, "deployment": self.gpt4v_deployment}
183183
if self.gpt4v_deployment

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"

0 commit comments

Comments
 (0)