Skip to content

Commit eccd758

Browse files
Merge branch 'main' into dev
2 parents 74e1d6c + f1030fa commit eccd758

File tree

6 files changed

+105
-18
lines changed

6 files changed

+105
-18
lines changed

code/backend/batch/utilities/helpers/azure_search_helper.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,27 @@ def get_conversation_logger(self):
265265
),
266266
]
267267

268-
return AzureSearch(
269-
azure_search_endpoint=self.env_helper.AZURE_SEARCH_SERVICE,
270-
azure_search_key=(
271-
self.env_helper.AZURE_SEARCH_KEY
272-
if self.env_helper.is_auth_type_keys()
273-
else None
274-
),
275-
index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX,
276-
embedding_function=self.llm_helper.get_embedding_model().embed_query,
277-
fields=fields,
278-
user_agent="langchain chatwithyourdata-sa",
279-
)
268+
if self.env_helper.AZURE_AUTH_TYPE == "rbac":
269+
credential = DefaultAzureCredential()
270+
return AzureSearch(
271+
azure_search_endpoint=self.env_helper.AZURE_SEARCH_SERVICE,
272+
azure_search_key=None, # Remove API key
273+
index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX,
274+
embedding_function=self.llm_helper.get_embedding_model().embed_query,
275+
fields=fields,
276+
user_agent="langchain chatwithyourdata-sa",
277+
credential=credential # Add token credential or send none so it is auto handled by AzureSearch library
278+
)
279+
else:
280+
return AzureSearch(
281+
azure_search_endpoint=self.env_helper.AZURE_SEARCH_SERVICE,
282+
azure_search_key=(
283+
self.env_helper.AZURE_SEARCH_KEY
284+
if self.env_helper.is_auth_type_keys()
285+
else None
286+
),
287+
index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX,
288+
embedding_function=self.llm_helper.get_embedding_model().embed_query,
289+
fields=fields,
290+
user_agent="langchain chatwithyourdata-sa",
291+
)

docs/create_new_app_registration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
![Add Details](images/AddDetails.png)
1818

19-
5. After application is created sucessfully, then click on `Add a Redirect URL`.
19+
5. After application is created successfully, then click on `Add a Redirect URL`.
2020

2121
![Redirect URL](images/AddRedirectURL.png)
2222

tests/e2e-test/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Write end-to-end tests for your web apps with [Playwright](https://github.com/mi
88
- Support for **headless and headed** execution.
99
- **Built-in fixtures** that provide browser primitives to test functions.
1010

11+
1112
Pre-Requisites:
1213
- Install Visual Studio Code: Download and Install Visual Studio Code(VSCode).
1314
- Install NodeJS: Download and Install Node JS
@@ -21,21 +22,19 @@ This will create a virtual environment directory named microsoft inside your cur
2122
Installing Playwright Pytest from Virtual Environment
2223
- To install libraries run "pip install -r requirements.txt"
2324

24-
2525
Run test cases
2626
- To run test cases from your 'tests\e2e-test' folder : "pytest --headed --html=report/report.html"
2727

28-
Steps need to be followed to enable Access Token and Client Credentials
28+
Steps need to be followed to enable Access Token and Client Credentials
2929
- Go to App Service from the resource group and select the Access Tokens check box in 'Manage->Authentication' tab
3030
![img.png](img.png)
3131
- Go to Manage->Certificates & secrets tab to generate Client Secret value
3232
![img_1.png](img_1.png)
3333
- Go to Overview tab to get the client id and tenant id.
3434

3535
Create .env file in project root level with web app url and client credentials
36-
- create a .env file in project root level and add your user_name, pass_word, client_id,client_secret,
36+
- create a .env file in project root level and add your user_name, pass_word, client_id,client_secret,
3737
tenant_id, web_url and admin_url for the resource group. please refer 'sample_dotenv_file.txt' file.
3838

3939
## Documentation
40-
4140
See on [playwright.dev](https://playwright.dev/python/docs/test-runners) for examples and more detailed information.

tests/e2e-test/pages/webUserPage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class WebUserPage(BasePage):
1919
CHAT_CLOSE_ICON = "button[title='Hide']"
2020
CHAT_HISTORY_OPTIONS = "//button[@id='moreButton']"
2121
CHAT_HISTORY_DELETE = "//button[@role='menuitem']"
22-
2322
TOGGLE_CITATIONS_LIST = "[data-testid='toggle-citations-list']"
2423
CITATIONS_CONTAINER = "[data-testid='citations-container']"
2524
CITATION_BLOCK = "[data-testid='citation-block']"

tests/e2e-test/sample_dotenv_file.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
web_url = 'web app url'
22
admin_url = 'admin url'
3+
user_name = 'user name'
4+
pass_word = 'pass word'
5+
client_id = 'client id'
6+
client_secret = 'client secret'
7+
tenant_id = 'tenant id'
8+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import logging
2+
3+
from config.constants import *
4+
from pages.adminPage import AdminPage
5+
from pages.webUserPage import WebUserPage
6+
7+
logger = logging.getLogger(__name__)
8+
9+
10+
def test_golden_path_web_page_demo_script(login_logout):
11+
"""Validate Golden path test case for Chat with your Data"""
12+
page = login_logout
13+
page.goto(ADMIN_URL)
14+
logger.info("Step 1: Validate Admin page is loaded.")
15+
admin_page = AdminPage(page)
16+
assert (
17+
admin_page_title == page.locator(admin_page.ADMIN_PAGE_TITLE).text_content()
18+
), "page title not found"
19+
logger.info("Step 2: Validate Files are uploaded or not")
20+
admin_page.click_delete_data_tab()
21+
assert (
22+
page.locator(admin_page.DELETE_CHECK_BOXES).count() >= 1
23+
), "Files are not uploaded."
24+
logger.info("Step 3: Validate Web page is loaded.")
25+
page.goto(WEB_URL)
26+
home_page = WebUserPage(page)
27+
logger.info("Step 5: Validate Chat history has been deleted.")
28+
home_page.delete_chat_history()
29+
30+
failed_questions = []
31+
logger.info("Step 6: Validate Golden Path prompts response")
32+
33+
def ask_question_and_check(question, attempt):
34+
home_page.wait_for_load(4000)
35+
home_page.enter_a_question(question)
36+
home_page.click_send_button()
37+
home_page.validate_response_status(question)
38+
39+
response_text = page.locator(home_page.ANSWER_TEXT)
40+
response_count = response_text.count()
41+
42+
if response_count == 0:
43+
return False # no response found
44+
45+
response_text_content = response_text.nth(response_count - 1).text_content()
46+
47+
if response_text_content == invalid_response:
48+
print(f"[Attempt {attempt}] Invalid response for prompt: {question}")
49+
return False
50+
return True
51+
52+
# First run through all questions
53+
for question in questions:
54+
if not ask_question_and_check(question, attempt=1):
55+
failed_questions.append(question)
56+
57+
# Retry failed questions once more
58+
if failed_questions:
59+
logger.info("Step 7: Retry failed question one more time.")
60+
for question in failed_questions:
61+
if not ask_question_and_check(question, attempt=2):
62+
home_page.soft_assert(
63+
False,
64+
f"Failed after retry- Invalid response for prompt: {question}",
65+
)
66+
67+
logger.info("Step 8: Validate chat history.")
68+
home_page.show_chat_history()
69+
logger.info("Step 9: Validate chat history closed.")
70+
home_page.close_chat_history()
71+
home_page.assert_all()

0 commit comments

Comments
 (0)