From 79cb03daf6444ad200399b29f9cf168513f2bf93 Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Sun, 9 Mar 2025 23:10:35 -0700 Subject: [PATCH 01/10] adding option --- app/backend/app.py | 4 ++++ app/backend/approaches/approach.py | 2 ++ .../approaches/chatreadretrieveread.py | 2 ++ .../approaches/chatreadretrievereadvision.py | 2 ++ app/backend/approaches/retrievethenread.py | 2 ++ .../approaches/retrievethenreadvision.py | 2 ++ app/backend/config.py | 1 + app/backend/requirements.in | 2 +- app/backend/requirements.txt | 2 +- app/frontend/src/api/models.ts | 2 ++ .../src/components/Settings/Settings.tsx | 20 +++++++++++++++++++ app/frontend/src/locales/en/translation.json | 3 +++ app/frontend/src/pages/ask/Ask.tsx | 10 ++++++++++ app/frontend/src/pages/chat/Chat.tsx | 10 ++++++++++ 14 files changed, 62 insertions(+), 2 deletions(-) diff --git a/app/backend/app.py b/app/backend/app.py index 275bce9de4..ec3533b45a 100644 --- a/app/backend/app.py +++ b/app/backend/app.py @@ -71,6 +71,7 @@ CONFIG_OPENAI_CLIENT, CONFIG_SEARCH_CLIENT, CONFIG_SEMANTIC_RANKER_DEPLOYED, + CONFIG_QUERY_REWRITING_ENABLED, CONFIG_SPEECH_INPUT_ENABLED, CONFIG_SPEECH_OUTPUT_AZURE_ENABLED, CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED, @@ -291,6 +292,7 @@ def config(): { "showGPT4VOptions": current_app.config[CONFIG_GPT4V_DEPLOYED], "showSemanticRankerOption": current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED], + "showQueryRewritingOption": current_app.config[CONFIG_QUERY_REWRITING_ENABLED], "showVectorOption": current_app.config[CONFIG_VECTOR_SEARCH_ENABLED], "showUserUpload": current_app.config[CONFIG_USER_UPLOAD_ENABLED], "showLanguagePicker": current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED], @@ -453,6 +455,7 @@ async def setup_clients(): AZURE_SEARCH_QUERY_LANGUAGE = os.getenv("AZURE_SEARCH_QUERY_LANGUAGE") or "en-us" AZURE_SEARCH_QUERY_SPELLER = os.getenv("AZURE_SEARCH_QUERY_SPELLER") or "lexicon" AZURE_SEARCH_SEMANTIC_RANKER = os.getenv("AZURE_SEARCH_SEMANTIC_RANKER", "free").lower() + AZURE_SEARCH_QUERY_REWRITING = os.getenv("AZURE_SEARCH_QUERY_REWRITING", "false").lower() AZURE_SPEECH_SERVICE_ID = os.getenv("AZURE_SPEECH_SERVICE_ID") AZURE_SPEECH_SERVICE_LOCATION = os.getenv("AZURE_SPEECH_SERVICE_LOCATION") @@ -634,6 +637,7 @@ async def setup_clients(): current_app.config[CONFIG_GPT4V_DEPLOYED] = bool(USE_GPT4V) current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED] = AZURE_SEARCH_SEMANTIC_RANKER != "disabled" + current_app.config[CONFIG_QUERY_REWRITING_ENABLED] = AZURE_SEARCH_QUERY_REWRITING == "true" and AZURE_SEARCH_SEMANTIC_RANKER != "disabled" current_app.config[CONFIG_VECTOR_SEARCH_ENABLED] = os.getenv("USE_VECTORS", "").lower() != "false" current_app.config[CONFIG_USER_UPLOAD_ENABLED] = bool(USE_USER_UPLOAD) current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED] = ENABLE_LANGUAGE_PICKER diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index 44a1d6380a..a65b5cfd1c 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -149,6 +149,7 @@ async def search( use_semantic_captions: bool, minimum_search_score: Optional[float], minimum_reranker_score: Optional[float], + use_query_rewriting: Optional[bool] ) -> List[Document]: search_text = query_text if use_text_search else "" search_vectors = vectors if use_vector_search else [] @@ -158,6 +159,7 @@ async def search( filter=filter, top=top, query_caption="extractive|highlight-false" if use_semantic_captions else None, + query_rewrites="generative" if use_query_rewriting else None, vector_queries=search_vectors, query_type=QueryType.SEMANTIC, query_language=self.query_language, diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index 7777b9a741..b24269689b 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -89,6 +89,7 @@ async def run_until_final_call( use_vector_search = overrides.get("retrieval_mode") in ["vectors", "hybrid", None] use_semantic_ranker = True if overrides.get("semantic_ranker") else False use_semantic_captions = True if overrides.get("semantic_captions") else False + use_query_rewriting = True if overrides.get("query_rewriting") else False top = overrides.get("top", 3) minimum_search_score = overrides.get("minimum_search_score", 0.0) minimum_reranker_score = overrides.get("minimum_reranker_score", 0.0) @@ -147,6 +148,7 @@ async def run_until_final_call( use_semantic_captions, minimum_search_score, minimum_reranker_score, + use_query_rewriting ) # STEP 3: Generate a contextual and content specific answer using the search results and chat history diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index 3c05d22180..ff1a5458d5 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -81,6 +81,7 @@ async def run_until_final_call( use_text_search = overrides.get("retrieval_mode") in ["text", "hybrid", None] use_vector_search = overrides.get("retrieval_mode") in ["vectors", "hybrid", None] use_semantic_ranker = True if overrides.get("semantic_ranker") else False + use_query_rewriting = True if overrides.get("query_rewriting") else False use_semantic_captions = True if overrides.get("semantic_captions") else False top = overrides.get("top", 3) minimum_search_score = overrides.get("minimum_search_score", 0.0) @@ -151,6 +152,7 @@ async def run_until_final_call( use_semantic_captions, minimum_search_score, minimum_reranker_score, + use_query_rewriting ) # STEP 3: Generate a contextual and content specific answer using the search results and chat history diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index f3c9331e36..d8b1506cda 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -67,6 +67,7 @@ async def run( use_text_search = overrides.get("retrieval_mode") in ["text", "hybrid", None] use_vector_search = overrides.get("retrieval_mode") in ["vectors", "hybrid", None] use_semantic_ranker = True if overrides.get("semantic_ranker") else False + use_query_rewriting = True if overrides.get("query_rewriting") else False use_semantic_captions = True if overrides.get("semantic_captions") else False top = overrides.get("top", 3) minimum_search_score = overrides.get("minimum_search_score", 0.0) @@ -89,6 +90,7 @@ async def run( use_semantic_captions, minimum_search_score, minimum_reranker_score, + use_query_rewriting ) # Process results diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index 14318d83fa..f69fd17fa0 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -76,6 +76,7 @@ async def run( use_text_search = overrides.get("retrieval_mode") in ["text", "hybrid", None] use_vector_search = overrides.get("retrieval_mode") in ["vectors", "hybrid", None] use_semantic_ranker = True if overrides.get("semantic_ranker") else False + use_query_rewriting = True if overrides.get("query_rewriting") else False use_semantic_captions = True if overrides.get("semantic_captions") else False top = overrides.get("top", 3) minimum_search_score = overrides.get("minimum_search_score", 0.0) @@ -108,6 +109,7 @@ async def run( use_semantic_captions, minimum_search_score, minimum_reranker_score, + use_query_rewriting ) # Process results diff --git a/app/backend/config.py b/app/backend/config.py index a9315df6c0..a4abf5a0e6 100644 --- a/app/backend/config.py +++ b/app/backend/config.py @@ -10,6 +10,7 @@ CONFIG_AUTH_CLIENT = "auth_client" CONFIG_GPT4V_DEPLOYED = "gpt4v_deployed" CONFIG_SEMANTIC_RANKER_DEPLOYED = "semantic_ranker_deployed" +CONFIG_QUERY_REWRITING_ENABLED = "query_rewriting_enabled" CONFIG_VECTOR_SEARCH_ENABLED = "vector_search_enabled" CONFIG_SEARCH_CLIENT = "search_client" CONFIG_OPENAI_CLIENT = "openai_client" diff --git a/app/backend/requirements.in b/app/backend/requirements.in index 66aa504dd3..7df2a0f9cd 100644 --- a/app/backend/requirements.in +++ b/app/backend/requirements.in @@ -7,7 +7,7 @@ tenacity azure-ai-documentintelligence==1.0.0b4 azure-cognitiveservices-speech azure-cosmos -azure-search-documents==11.6.0b6 +azure-search-documents==11.6.0b9 azure-storage-blob azure-storage-file-datalake uvicorn diff --git a/app/backend/requirements.txt b/app/backend/requirements.txt index 545065ef80..67c3e12eef 100644 --- a/app/backend/requirements.txt +++ b/app/backend/requirements.txt @@ -57,7 +57,7 @@ azure-monitor-opentelemetry==1.6.1 # via -r requirements.in azure-monitor-opentelemetry-exporter==1.0.0b32 # via azure-monitor-opentelemetry -azure-search-documents==11.6.0b6 +azure-search-documents==11.6.0b9 # via -r requirements.in azure-storage-blob==12.22.0 # via diff --git a/app/frontend/src/api/models.ts b/app/frontend/src/api/models.ts index f560271325..4acbd2e8da 100644 --- a/app/frontend/src/api/models.ts +++ b/app/frontend/src/api/models.ts @@ -20,6 +20,7 @@ export type ChatAppRequestOverrides = { retrieval_mode?: RetrievalMode; semantic_ranker?: boolean; semantic_captions?: boolean; + query_rewriting?: boolean; include_category?: string; exclude_category?: string; seed?: number; @@ -84,6 +85,7 @@ export type ChatAppRequest = { export type Config = { showGPT4VOptions: boolean; showSemanticRankerOption: boolean; + showQueryRewritingOption: boolean; showVectorOption: boolean; showUserUpload: boolean; showLanguagePicker: boolean; diff --git a/app/frontend/src/components/Settings/Settings.tsx b/app/frontend/src/components/Settings/Settings.tsx index de404297ab..49f7aec5c9 100644 --- a/app/frontend/src/components/Settings/Settings.tsx +++ b/app/frontend/src/components/Settings/Settings.tsx @@ -19,6 +19,7 @@ export interface SettingsProps { minimumRerankerScore: number; useSemanticRanker: boolean; useSemanticCaptions: boolean; + useQueryRewriting: boolean; excludeCategory: string; includeCategory: string; retrievalMode: RetrievalMode; @@ -26,6 +27,7 @@ export interface SettingsProps { gpt4vInput: GPT4VInput; vectorFieldList: VectorFieldOptions[]; showSemanticRankerOption: boolean; + showQueryRewritingOption: boolean; showGPT4VOptions: boolean; showVectorOption: boolean; useOidSecurityFilter: boolean; @@ -51,6 +53,7 @@ export const Settings = ({ minimumRerankerScore, useSemanticRanker, useSemanticCaptions, + useQueryRewriting, excludeCategory, includeCategory, retrievalMode, @@ -58,6 +61,7 @@ export const Settings = ({ gpt4vInput, vectorFieldList, showSemanticRankerOption, + showQueryRewritingOption, showGPT4VOptions, showVectorOption, useOidSecurityFilter, @@ -94,6 +98,7 @@ export const Settings = ({ const excludeCategoryFieldId = useId("excludeCategoryField"); const semanticRankerId = useId("semanticRanker"); const semanticRankerFieldId = useId("semanticRankerField"); + const queryRewritingFieldId = useId("queryRewritingField"); const semanticCaptionsId = useId("semanticCaptions"); const semanticCaptionsFieldId = useId("semanticCaptionsField"); const useOidSecurityFilterId = useId("useOidSecurityFilter"); @@ -239,6 +244,21 @@ export const Settings = ({ )} + {showQueryRewritingOption && ( + <> + onChange("useQueryRewriting", !!checked)} + aria-labelledby={queryRewritingFieldId} + onRenderLabel={props => renderLabel(props, queryRewritingFieldId, queryRewritingFieldId, t("helpTexts.useQueryRewriting"))} + /> + + )} + {useLogin && ( <> (3); const [useSemanticRanker, setUseSemanticRanker] = useState(true); const [useSemanticCaptions, setUseSemanticCaptions] = useState(false); + const [useQueryRewriting, setUseQueryRewriting] = useState(false); const [useGPT4V, setUseGPT4V] = useState(false); const [gpt4vInput, setGPT4VInput] = useState(GPT4VInput.TextAndImages); const [includeCategory, setIncludeCategory] = useState(""); @@ -42,6 +43,7 @@ export function Component(): JSX.Element { const [useGroupsSecurityFilter, setUseGroupsSecurityFilter] = useState(false); const [showGPT4VOptions, setShowGPT4VOptions] = useState(false); const [showSemanticRankerOption, setShowSemanticRankerOption] = useState(false); + const [showQueryRewritingOption, setShowQueryRewritingOption] = useState(false); const [showVectorOption, setShowVectorOption] = useState(false); const [showUserUpload, setShowUserUpload] = useState(false); const [showLanguagePicker, setshowLanguagePicker] = useState(false); @@ -78,6 +80,8 @@ export function Component(): JSX.Element { setShowGPT4VOptions(config.showGPT4VOptions); setUseSemanticRanker(config.showSemanticRankerOption); setShowSemanticRankerOption(config.showSemanticRankerOption); + setUseQueryRewriting(config.showQueryRewritingOption); + setShowQueryRewritingOption(config.showQueryRewritingOption); setShowVectorOption(config.showVectorOption); if (!config.showVectorOption) { setRetrievalMode(RetrievalMode.Text); @@ -126,6 +130,7 @@ export function Component(): JSX.Element { retrieval_mode: retrievalMode, semantic_ranker: useSemanticRanker, semantic_captions: useSemanticCaptions, + query_rewriting: useQueryRewriting, use_oid_security_filter: useOidSecurityFilter, use_groups_security_filter: useGroupsSecurityFilter, vector_fields: vectorFieldList, @@ -180,6 +185,9 @@ export function Component(): JSX.Element { case "useSemanticCaptions": setUseSemanticCaptions(value); break; + case "useQueryRewriting": + setUseQueryRewriting(value); + break; case "excludeCategory": setExcludeCategory(value); break; @@ -321,6 +329,7 @@ export function Component(): JSX.Element { minimumRerankerScore={minimumRerankerScore} useSemanticRanker={useSemanticRanker} useSemanticCaptions={useSemanticCaptions} + useQueryRewriting={useQueryRewriting} excludeCategory={excludeCategory} includeCategory={includeCategory} retrievalMode={retrievalMode} @@ -328,6 +337,7 @@ export function Component(): JSX.Element { gpt4vInput={gpt4vInput} vectorFieldList={vectorFieldList} showSemanticRankerOption={showSemanticRankerOption} + showQueryRewritingOption={showQueryRewritingOption} showGPT4VOptions={showGPT4VOptions} showVectorOption={showVectorOption} useOidSecurityFilter={useOidSecurityFilter} diff --git a/app/frontend/src/pages/chat/Chat.tsx b/app/frontend/src/pages/chat/Chat.tsx index e3c0cfd77f..97995df926 100644 --- a/app/frontend/src/pages/chat/Chat.tsx +++ b/app/frontend/src/pages/chat/Chat.tsx @@ -48,6 +48,7 @@ const Chat = () => { const [retrieveCount, setRetrieveCount] = useState(3); const [retrievalMode, setRetrievalMode] = useState(RetrievalMode.Hybrid); const [useSemanticRanker, setUseSemanticRanker] = useState(true); + const [useQueryRewriting, setUseQueryRewriting] = useState(false); const [shouldStream, setShouldStream] = useState(true); const [useSemanticCaptions, setUseSemanticCaptions] = useState(false); const [includeCategory, setIncludeCategory] = useState(""); @@ -76,6 +77,7 @@ const Chat = () => { const [showGPT4VOptions, setShowGPT4VOptions] = useState(false); const [showSemanticRankerOption, setShowSemanticRankerOption] = useState(false); + const [showQueryRewritingOption, setShowQueryRewritingOption] = useState(false); const [showVectorOption, setShowVectorOption] = useState(false); const [showUserUpload, setShowUserUpload] = useState(false); const [showLanguagePicker, setshowLanguagePicker] = useState(false); @@ -100,6 +102,8 @@ const Chat = () => { setShowGPT4VOptions(config.showGPT4VOptions); setUseSemanticRanker(config.showSemanticRankerOption); setShowSemanticRankerOption(config.showSemanticRankerOption); + setUseQueryRewriting(config.showQueryRewritingOption); + setShowQueryRewritingOption(config.showQueryRewritingOption); setShowVectorOption(config.showVectorOption); if (!config.showVectorOption) { setRetrievalMode(RetrievalMode.Text); @@ -197,6 +201,7 @@ const Chat = () => { retrieval_mode: retrievalMode, semantic_ranker: useSemanticRanker, semantic_captions: useSemanticCaptions, + query_rewriting: useQueryRewriting, suggest_followup_questions: useSuggestFollowupQuestions, use_oid_security_filter: useOidSecurityFilter, use_groups_security_filter: useGroupsSecurityFilter, @@ -285,6 +290,9 @@ const Chat = () => { case "useSemanticRanker": setUseSemanticRanker(value); break; + case "useQueryRewriting": + setUseQueryRewriting(value); + break; case "useSemanticCaptions": setUseSemanticCaptions(value); break; @@ -500,6 +508,7 @@ const Chat = () => { minimumRerankerScore={minimumRerankerScore} useSemanticRanker={useSemanticRanker} useSemanticCaptions={useSemanticCaptions} + useQueryRewriting={useQueryRewriting} excludeCategory={excludeCategory} includeCategory={includeCategory} retrievalMode={retrievalMode} @@ -507,6 +516,7 @@ const Chat = () => { gpt4vInput={gpt4vInput} vectorFieldList={vectorFieldList} showSemanticRankerOption={showSemanticRankerOption} + showQueryRewritingOption={showQueryRewritingOption} showGPT4VOptions={showGPT4VOptions} showVectorOption={showVectorOption} useOidSecurityFilter={useOidSecurityFilter} From 2b570496e8284d32f1b54882a7bee2c2267500af Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Mon, 17 Mar 2025 22:10:25 -0700 Subject: [PATCH 02/10] update --- app/backend/approaches/approach.py | 2 +- .../approaches/chatreadretrieveread.py | 1 + .../approaches/chatreadretrievereadvision.py | 1 + app/backend/approaches/retrievethenread.py | 1 + .../approaches/retrievethenreadvision.py | 1 + infra/main.bicep | 3 +- infra/main.parameters.json | 3 ++ tests/test_chatapproach.py | 38 +++++++++++++++++++ 8 files changed, 48 insertions(+), 2 deletions(-) diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index a65b5cfd1c..d56a7d5544 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -149,7 +149,7 @@ async def search( use_semantic_captions: bool, minimum_search_score: Optional[float], minimum_reranker_score: Optional[float], - use_query_rewriting: Optional[bool] + use_query_rewriting: Optional[bool] = None ) -> List[Document]: search_text = query_text if use_text_search else "" search_vectors = vectors if use_vector_search else [] diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index b24269689b..6df77cf0f1 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -192,6 +192,7 @@ async def run_until_final_call( { "use_semantic_captions": use_semantic_captions, "use_semantic_ranker": use_semantic_ranker, + "use_query_rewriting": use_query_rewriting, "top": top, "filter": filter, "use_vector_search": use_vector_search, diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index ff1a5458d5..a107c73ada 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -209,6 +209,7 @@ async def run_until_final_call( { "use_semantic_captions": use_semantic_captions, "use_semantic_ranker": use_semantic_ranker, + "use_query_rewriting": use_query_rewriting, "top": top, "filter": filter, "vector_fields": vector_fields, diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index d8b1506cda..b931431ece 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -120,6 +120,7 @@ async def run( { "use_semantic_captions": use_semantic_captions, "use_semantic_ranker": use_semantic_ranker, + "use_query_rewriting": use_query_rewriting, "top": top, "filter": filter, "use_vector_search": use_vector_search, diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index f69fd17fa0..c14feb12e2 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -147,6 +147,7 @@ async def run( { "use_semantic_captions": use_semantic_captions, "use_semantic_ranker": use_semantic_ranker, + "use_query_rewriting": use_query_rewriting, "top": top, "filter": filter, "vector_fields": vector_fields, diff --git a/infra/main.bicep b/infra/main.bicep index b268ea36b7..06ccaefb67 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -30,7 +30,7 @@ param searchServiceSemanticRankerLevel string // Set in main.parameters.json var actualSearchServiceSemanticRankerLevel = (searchServiceSkuName == 'free') ? 'disabled' : searchServiceSemanticRankerLevel - +param searchServiceQueryRewriting string // Set in main.parameters.json param storageAccountName string = '' // Set in main.parameters.json param storageResourceGroupName string = '' // Set in main.parameters.json param storageResourceGroupLocation string = location @@ -375,6 +375,7 @@ var appEnvVariables = { AZURE_SEARCH_INDEX: searchIndexName AZURE_SEARCH_SERVICE: searchService.outputs.name AZURE_SEARCH_SEMANTIC_RANKER: actualSearchServiceSemanticRankerLevel + AZURE_SEARCH_QUERY_REWRITING: searchServiceQueryRewriting AZURE_VISION_ENDPOINT: useGPT4V ? computerVision.outputs.endpoint : '' AZURE_SEARCH_QUERY_LANGUAGE: searchQueryLanguage AZURE_SEARCH_QUERY_SPELLER: searchQuerySpeller diff --git a/infra/main.parameters.json b/infra/main.parameters.json index a28ac4a3d7..7bd1111afd 100644 --- a/infra/main.parameters.json +++ b/infra/main.parameters.json @@ -80,6 +80,9 @@ "searchServiceSemanticRankerLevel": { "value": "${AZURE_SEARCH_SEMANTIC_RANKER=free}" }, + "searchServiceQueryRewriting": { + "value": "${AZURE_SEARCH_QUERY_REWRITING}" + }, "storageAccountName": { "value": "${AZURE_STORAGE_ACCOUNT}" }, diff --git a/tests/test_chatapproach.py b/tests/test_chatapproach.py index 2fa845fec3..9f1c869db9 100644 --- a/tests/test_chatapproach.py +++ b/tests/test_chatapproach.py @@ -201,3 +201,41 @@ async def test_search_results_filtering_by_scores( assert ( len(filtered_results) == expected_result_count ), f"Expected {expected_result_count} results with minimum_search_score={minimum_search_score} and minimum_reranker_score={minimum_reranker_score}" + +async def test_search_results_query_rewriting(monkeypatch): + chat_approach = ChatReadRetrieveReadApproach( + search_client=SearchClient(endpoint="", index_name="", credential=AzureKeyCredential("")), + auth_helper=None, + openai_client=None, + chatgpt_model="gpt-35-turbo", + chatgpt_deployment="chat", + embedding_deployment="embeddings", + embedding_model=MOCK_EMBEDDING_MODEL_NAME, + embedding_dimensions=MOCK_EMBEDDING_DIMENSIONS, + sourcepage_field="", + content_field="", + query_language="en-us", + query_speller="lexicon", + prompt_manager=PromptyManager(), + ) + + query_rewrites = None + async def validate_qr_and_mock_search(*args, **kwargs): + nonlocal query_rewrites + query_rewrites = kwargs.get("query_rewrites") + return mock_search(*args, **kwargs) + + monkeypatch.setattr(SearchClient, "search", validate_qr_and_mock_search) + + results = await chat_approach.search( + top=10, + query_text="test query", + filter=None, + vectors=[], + use_text_search=True, + use_vector_search=True, + use_semantic_ranker=True, + use_semantic_captions=True, + use_query_rewrites=True) + assert len(results) == 1 + assert query_rewrites == "generative" \ No newline at end of file From 3dca1acdf0f7c206515313be9e835519def7620f Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Mon, 17 Mar 2025 22:14:43 -0700 Subject: [PATCH 03/10] run black --- app/backend/app.py | 4 +++- app/backend/approaches/approach.py | 2 +- app/backend/approaches/chatreadretrieveread.py | 2 +- app/backend/approaches/chatreadretrievereadvision.py | 2 +- app/backend/approaches/retrievethenread.py | 2 +- app/backend/approaches/retrievethenreadvision.py | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/backend/app.py b/app/backend/app.py index ec3533b45a..201f81a265 100644 --- a/app/backend/app.py +++ b/app/backend/app.py @@ -637,7 +637,9 @@ async def setup_clients(): current_app.config[CONFIG_GPT4V_DEPLOYED] = bool(USE_GPT4V) current_app.config[CONFIG_SEMANTIC_RANKER_DEPLOYED] = AZURE_SEARCH_SEMANTIC_RANKER != "disabled" - current_app.config[CONFIG_QUERY_REWRITING_ENABLED] = AZURE_SEARCH_QUERY_REWRITING == "true" and AZURE_SEARCH_SEMANTIC_RANKER != "disabled" + current_app.config[CONFIG_QUERY_REWRITING_ENABLED] = ( + AZURE_SEARCH_QUERY_REWRITING == "true" and AZURE_SEARCH_SEMANTIC_RANKER != "disabled" + ) current_app.config[CONFIG_VECTOR_SEARCH_ENABLED] = os.getenv("USE_VECTORS", "").lower() != "false" current_app.config[CONFIG_USER_UPLOAD_ENABLED] = bool(USE_USER_UPLOAD) current_app.config[CONFIG_LANGUAGE_PICKER_ENABLED] = ENABLE_LANGUAGE_PICKER diff --git a/app/backend/approaches/approach.py b/app/backend/approaches/approach.py index d56a7d5544..d8caa2083f 100644 --- a/app/backend/approaches/approach.py +++ b/app/backend/approaches/approach.py @@ -149,7 +149,7 @@ async def search( use_semantic_captions: bool, minimum_search_score: Optional[float], minimum_reranker_score: Optional[float], - use_query_rewriting: Optional[bool] = None + use_query_rewriting: Optional[bool] = None, ) -> List[Document]: search_text = query_text if use_text_search else "" search_vectors = vectors if use_vector_search else [] diff --git a/app/backend/approaches/chatreadretrieveread.py b/app/backend/approaches/chatreadretrieveread.py index 6df77cf0f1..a5c9810bda 100644 --- a/app/backend/approaches/chatreadretrieveread.py +++ b/app/backend/approaches/chatreadretrieveread.py @@ -148,7 +148,7 @@ async def run_until_final_call( use_semantic_captions, minimum_search_score, minimum_reranker_score, - use_query_rewriting + use_query_rewriting, ) # STEP 3: Generate a contextual and content specific answer using the search results and chat history diff --git a/app/backend/approaches/chatreadretrievereadvision.py b/app/backend/approaches/chatreadretrievereadvision.py index a107c73ada..8120a7215e 100644 --- a/app/backend/approaches/chatreadretrievereadvision.py +++ b/app/backend/approaches/chatreadretrievereadvision.py @@ -152,7 +152,7 @@ async def run_until_final_call( use_semantic_captions, minimum_search_score, minimum_reranker_score, - use_query_rewriting + use_query_rewriting, ) # STEP 3: Generate a contextual and content specific answer using the search results and chat history diff --git a/app/backend/approaches/retrievethenread.py b/app/backend/approaches/retrievethenread.py index b931431ece..bb068357e4 100644 --- a/app/backend/approaches/retrievethenread.py +++ b/app/backend/approaches/retrievethenread.py @@ -90,7 +90,7 @@ async def run( use_semantic_captions, minimum_search_score, minimum_reranker_score, - use_query_rewriting + use_query_rewriting, ) # Process results diff --git a/app/backend/approaches/retrievethenreadvision.py b/app/backend/approaches/retrievethenreadvision.py index c14feb12e2..5f307b49f9 100644 --- a/app/backend/approaches/retrievethenreadvision.py +++ b/app/backend/approaches/retrievethenreadvision.py @@ -109,7 +109,7 @@ async def run( use_semantic_captions, minimum_search_score, minimum_reranker_score, - use_query_rewriting + use_query_rewriting, ) # Process results From 960bcd8fd882d684998c8145966fda639fd8a95c Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Mon, 17 Mar 2025 22:15:02 -0700 Subject: [PATCH 04/10] run ruff --- app/backend/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/backend/app.py b/app/backend/app.py index 201f81a265..b5e4084f76 100644 --- a/app/backend/app.py +++ b/app/backend/app.py @@ -69,9 +69,9 @@ CONFIG_INGESTER, CONFIG_LANGUAGE_PICKER_ENABLED, CONFIG_OPENAI_CLIENT, + CONFIG_QUERY_REWRITING_ENABLED, CONFIG_SEARCH_CLIENT, CONFIG_SEMANTIC_RANKER_DEPLOYED, - CONFIG_QUERY_REWRITING_ENABLED, CONFIG_SPEECH_INPUT_ENABLED, CONFIG_SPEECH_OUTPUT_AZURE_ENABLED, CONFIG_SPEECH_OUTPUT_BROWSER_ENABLED, From cb85432b0a6b7765359f84fda9abce85dca12ed5 Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Mon, 17 Mar 2025 22:15:20 -0700 Subject: [PATCH 05/10] run ruff, black --- tests/test_chatapproach.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_chatapproach.py b/tests/test_chatapproach.py index 9f1c869db9..bb8f869804 100644 --- a/tests/test_chatapproach.py +++ b/tests/test_chatapproach.py @@ -202,6 +202,7 @@ async def test_search_results_filtering_by_scores( len(filtered_results) == expected_result_count ), f"Expected {expected_result_count} results with minimum_search_score={minimum_search_score} and minimum_reranker_score={minimum_reranker_score}" + async def test_search_results_query_rewriting(monkeypatch): chat_approach = ChatReadRetrieveReadApproach( search_client=SearchClient(endpoint="", index_name="", credential=AzureKeyCredential("")), @@ -220,6 +221,7 @@ async def test_search_results_query_rewriting(monkeypatch): ) query_rewrites = None + async def validate_qr_and_mock_search(*args, **kwargs): nonlocal query_rewrites query_rewrites = kwargs.get("query_rewrites") @@ -236,6 +238,7 @@ async def validate_qr_and_mock_search(*args, **kwargs): use_vector_search=True, use_semantic_ranker=True, use_semantic_captions=True, - use_query_rewrites=True) + use_query_rewrites=True, + ) assert len(results) == 1 - assert query_rewrites == "generative" \ No newline at end of file + assert query_rewrites == "generative" From 12066a2122fc95f359e6049d69a21be87713d220 Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Mon, 17 Mar 2025 22:27:30 -0700 Subject: [PATCH 06/10] update docs for query rewriting --- docs/deploy_features.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/deploy_features.md b/docs/deploy_features.md index e6d1503d40..d518afe09e 100644 --- a/docs/deploy_features.md +++ b/docs/deploy_features.md @@ -17,6 +17,7 @@ You should typically enable these features before running `azd up`. Once you've * [Enabling login and document level access control](#enabling-login-and-document-level-access-control) * [Enabling user document upload](#enabling-user-document-upload) * [Enabling CORS for an alternate frontend](#enabling-cors-for-an-alternate-frontend) +* [Enabling query rewriting](#enabling-query-rewriting) * [Adding an OpenAI load balancer](#adding-an-openai-load-balancer) * [Deploying with private endpoints](#deploying-with-private-endpoints) * [Using local parsers](#using-local-parsers) @@ -321,6 +322,13 @@ For an alternate frontend that's written in Web Components and deployed to Stati on [using a different backend](https://github.com/Azure-Samples/azure-search-openai-javascript#using-a-different-backend). Both these repositories adhere to the same [HTTP protocol for AI chat apps](https://aka.ms/chatprotocol). +## Enabling query rewriting + +By default, [query rewriting](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite) from the search service is not enabled. To enable query rewriting, set the following environment variables: + +1. Ensure semantic ranker is enabled. Query rewriting may only be used with semantic ranker. Run `azd env set AZURE_SEARCH_SEMANTIC_RANKER free` or `azd env set AZURE_SEARCH_SEMANTIC_RANKER standard` depending on your desired [semantic ranker tier](https://learn.microsoft.com/azure/search/semantic-how-to-configure). +1. Enable query rewriting. Run `azd env set AUZRE_SEARCH_QUERY_REWRITING true`. An option in developer settings will appear allowing you to toggle query rewriting on and off. It will be on by default. + ## Adding an OpenAI load balancer As discussed in more details in our [productionizing guide](./productionizing.md), you may want to consider implementing a load balancer between OpenAI instances if you are consistently going over the TPM limit. From 07b93943abce64ce8cc5a551a320b60f596ab2fe Mon Sep 17 00:00:00 2001 From: Matt Gotteiner Date: Tue, 18 Mar 2025 21:33:29 -0700 Subject: [PATCH 07/10] addressing feedback --- .azdo/pipelines/azure-dev.yml | 1 + .github/workflows/azure-dev.yml | 1 + app/frontend/src/locales/da/translation.json | 1 + app/frontend/src/locales/es/translation.json | 1 + app/frontend/src/locales/fr/translation.json | 1 + app/frontend/src/locales/it/translation.json | 1 + app/frontend/src/locales/ja/translation.json | 1 + app/frontend/src/locales/nl/translation.json | 1 + app/frontend/src/locales/ptBR/translation.json | 1 + app/frontend/src/locales/tr/translation.json | 1 + azure.yaml | 1 + docs/deploy_features.md | 4 ++-- .../test_app/test_ask_prompt_template/client0/result.json | 1 + .../test_app/test_ask_prompt_template/client1/result.json | 1 + .../test_ask_prompt_template_concat/client0/result.json | 1 + .../test_ask_prompt_template_concat/client1/result.json | 1 + .../test_app/test_ask_rtr_hybrid/client0/result.json | 1 + .../test_app/test_ask_rtr_hybrid/client1/result.json | 1 + .../snapshots/test_app/test_ask_rtr_text/client0/result.json | 1 + .../snapshots/test_app/test_ask_rtr_text/client1/result.json | 1 + .../test_ask_rtr_text_filter/auth_client0/result.json | 1 + .../auth_public_documents_client0/result.json | 1 + .../test_ask_rtr_text_semanticcaptions/client0/result.json | 1 + .../test_ask_rtr_text_semanticcaptions/client1/result.json | 1 + .../test_ask_rtr_text_semanticranker/client0/result.json | 1 + .../test_ask_rtr_text_semanticranker/client1/result.json | 1 + tests/snapshots/test_app/test_ask_vision/client0/result.json | 1 + tests/snapshots/test_app/test_ask_vision/client1/result.json | 1 + .../snapshots/test_app/test_chat_followup/client0/result.json | 1 + .../snapshots/test_app/test_chat_followup/client1/result.json | 1 + tests/snapshots/test_app/test_chat_hybrid/client0/result.json | 1 + tests/snapshots/test_app/test_chat_hybrid/client1/result.json | 1 + .../test_chat_hybrid_semantic_captions/client0/result.json | 1 + .../test_chat_hybrid_semantic_captions/client1/result.json | 1 + .../test_chat_hybrid_semantic_ranker/client0/result.json | 1 + .../test_chat_hybrid_semantic_ranker/client1/result.json | 1 + .../test_app/test_chat_prompt_template/client0/result.json | 1 + .../test_app/test_chat_prompt_template/client1/result.json | 1 + .../test_chat_prompt_template_concat/client0/result.json | 1 + .../test_chat_prompt_template_concat/client1/result.json | 1 + tests/snapshots/test_app/test_chat_seed/client0/result.json | 1 + tests/snapshots/test_app/test_chat_seed/client1/result.json | 1 + .../test_chat_session_state_persists/client0/result.json | 1 + .../test_chat_session_state_persists/client1/result.json | 1 + .../test_chat_stream_followup/client0/result.jsonlines | 2 +- .../test_chat_stream_followup/client1/result.jsonlines | 2 +- .../client0/result.jsonlines | 2 +- .../client1/result.jsonlines | 2 +- .../test_app/test_chat_stream_text/client0/result.jsonlines | 2 +- .../test_app/test_chat_stream_text/client1/result.jsonlines | 2 +- .../auth_client0/result.jsonlines | 2 +- .../test_app/test_chat_stream_vision/client0/result.jsonlines | 2 +- .../test_app/test_chat_stream_vision/client1/result.jsonlines | 2 +- tests/snapshots/test_app/test_chat_text/client0/result.json | 1 + tests/snapshots/test_app/test_chat_text/client1/result.json | 1 + .../test_app/test_chat_text_filter/auth_client0/result.json | 1 + .../auth_public_documents_client0/result.json | 1 + .../test_chat_text_semantic_ranker/client0/result.json | 1 + .../test_chat_text_semantic_ranker/client1/result.json | 1 + .../test_chat_text_semanticcaptions/client0/result.json | 1 + .../test_chat_text_semanticcaptions/client1/result.json | 1 + .../test_chat_text_semanticranker/client0/result.json | 1 + .../test_chat_text_semanticranker/client1/result.json | 1 + tests/snapshots/test_app/test_chat_vector/client0/result.json | 1 + tests/snapshots/test_app/test_chat_vector/client1/result.json | 1 + .../test_chat_vector_semantic_ranker/client0/result.json | 1 + .../test_chat_vector_semantic_ranker/client1/result.json | 1 + tests/snapshots/test_app/test_chat_vision/client0/result.json | 1 + tests/snapshots/test_app/test_chat_vision/client1/result.json | 1 + .../test_app/test_chat_vision_vectors/client0/result.json | 1 + .../test_app/test_chat_vision_vectors/client1/result.json | 1 + .../test_app/test_chat_with_history/client0/result.json | 1 + .../test_app/test_chat_with_history/client1/result.json | 1 + .../test_app/test_chat_with_long_history/client0/result.json | 1 + .../test_app/test_chat_with_long_history/client1/result.json | 1 + 75 files changed, 76 insertions(+), 11 deletions(-) diff --git a/.azdo/pipelines/azure-dev.yml b/.azdo/pipelines/azure-dev.yml index 9990df48ff..0e0b4ffef3 100644 --- a/.azdo/pipelines/azure-dev.yml +++ b/.azdo/pipelines/azure-dev.yml @@ -59,6 +59,7 @@ steps: AZURE_SEARCH_QUERY_LANGUAGE: $(AZURE_SEARCH_QUERY_LANGUAGE) AZURE_SEARCH_QUERY_SPELLER: $(AZURE_SEARCH_QUERY_SPELLER) AZURE_SEARCH_SEMANTIC_RANKER: $(AZURE_SEARCH_SEMANTIC_RANKER) + AZURE_SEARCH_QUERY_REWRITING: $(AZURE_SEARCH_QUERY_REWRITING) AZURE_STORAGE_ACCOUNT: $(AZURE_STORAGE_ACCOUNT) AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP) AZURE_STORAGE_SKU: $(AZURE_STORAGE_SKU) diff --git a/.github/workflows/azure-dev.yml b/.github/workflows/azure-dev.yml index 0a9fbb6c1c..37cb43b118 100644 --- a/.github/workflows/azure-dev.yml +++ b/.github/workflows/azure-dev.yml @@ -49,6 +49,7 @@ jobs: AZURE_SEARCH_QUERY_LANGUAGE: ${{ vars.AZURE_SEARCH_QUERY_LANGUAGE }} AZURE_SEARCH_QUERY_SPELLER: ${{ vars.AZURE_SEARCH_QUERY_SPELLER }} AZURE_SEARCH_SEMANTIC_RANKER: ${{ vars.AZURE_SEARCH_SEMANTIC_RANKER }} + AZURE_SEARCH_QUERY_REWRITING: ${{ vars.AZURE_SEARCH_QUERY_REWRITING }} AZURE_STORAGE_ACCOUNT: ${{ vars.AZURE_STORAGE_ACCOUNT }} AZURE_STORAGE_RESOURCE_GROUP: ${{ vars.AZURE_STORAGE_RESOURCE_GROUP }} AZURE_STORAGE_SKU: ${{ vars.AZURE_STORAGE_SKU }} diff --git a/app/frontend/src/locales/da/translation.json b/app/frontend/src/locales/da/translation.json index aa2b556135..13480a34e1 100644 --- a/app/frontend/src/locales/da/translation.json +++ b/app/frontend/src/locales/da/translation.json @@ -86,6 +86,7 @@ "excludeCategory": "Ekskludér kategori", "useSemanticRanker": "Brug semantisk ranking til søgning", "useSemanticCaptions": "Brug semantiske billedtekster", + "useQueryRewriting": "Brug forespørgselsomskrivning til informationsgenfinding", "useSuggestFollowupQuestions": "Foreslå opfølgende spørgsmål", "useGPT4V": "Brug GPT vision model", "gpt4VInput": { diff --git a/app/frontend/src/locales/es/translation.json b/app/frontend/src/locales/es/translation.json index 1833b63af5..0675b69f94 100644 --- a/app/frontend/src/locales/es/translation.json +++ b/app/frontend/src/locales/es/translation.json @@ -90,6 +90,7 @@ "excludeCategory": "Excluir categoría", "useSemanticRanker": "Usar clasificador semántico para la recuperación", "useSemanticCaptions": "Usar subtítulos semánticos", + "useQueryRewriting": "Utiliza la reescritura de consultas para la recuperación", "useSuggestFollowupQuestions": "Sugerir preguntas de seguimiento", "useGPT4V": "Usar modelo de visión GPT", "gpt4VInput": { diff --git a/app/frontend/src/locales/fr/translation.json b/app/frontend/src/locales/fr/translation.json index 26a9d1ffaf..90aec6da3a 100644 --- a/app/frontend/src/locales/fr/translation.json +++ b/app/frontend/src/locales/fr/translation.json @@ -91,6 +91,7 @@ "useSemanticRanker": "Utiliser le reclasseur sémantique", "useSemanticCaptions": "Utiliser les titres sémantiques", "useSuggestFollowupQuestions": "Suggérer des questions de suivi", + "useQueryRewriting": "Utilisez la réécriture des requêtes pour la récupération", "useGPT4V": "Utiliser le modèle GPT Vision", "gpt4VInput": { "label": "Entrées du modèle GPT Vision", diff --git a/app/frontend/src/locales/it/translation.json b/app/frontend/src/locales/it/translation.json index 2565bca9a2..ee1c2c25ba 100644 --- a/app/frontend/src/locales/it/translation.json +++ b/app/frontend/src/locales/it/translation.json @@ -90,6 +90,7 @@ "excludeCategory": "Escludi categoria", "useSemanticRanker": "Usa il reranker semantico", "useSemanticCaptions": "Usa didascalie semantiche", + "useQueryRewriting": "Usa la riscrittura delle query per il recupero", "useSuggestFollowupQuestions": "Suggerisci domande di follow-up", "useGPT4V": "Usa il modello GPT Vision", "gpt4VInput": { diff --git a/app/frontend/src/locales/ja/translation.json b/app/frontend/src/locales/ja/translation.json index a69c7cdc0f..f59593e3fb 100644 --- a/app/frontend/src/locales/ja/translation.json +++ b/app/frontend/src/locales/ja/translation.json @@ -90,6 +90,7 @@ "excludeCategory": "カテゴリを除外", "useSemanticRanker": "取得にセマンティック・ランカーを使用", "useSemanticCaptions": "セマンティック・キャプションを使用", + "useQueryRewriting": "検索のためにクエリの書き換えを使用する", "useSuggestFollowupQuestions": "フォローアップの質問を提案", "useGPT4V": "GPT Visionモデルを使用", "gpt4VInput": { diff --git a/app/frontend/src/locales/nl/translation.json b/app/frontend/src/locales/nl/translation.json index d871ea1bfe..b277096b28 100644 --- a/app/frontend/src/locales/nl/translation.json +++ b/app/frontend/src/locales/nl/translation.json @@ -90,6 +90,7 @@ "excludeCategory": "Categorie uitsluiten", "useSemanticRanker": "Semantische rangschikking gebruiken", "useSemanticCaptions": "Semantische bijschriften gebruiken", + "useQueryRewriting": "Gebruik de herformulering van zoekopdrachten om informatie op te halen", "useSuggestFollowupQuestions": "Vervolgvragen voorstellen", "useGPT4V": "GPT-visiemodel gebruiken", "gpt4VInput": { diff --git a/app/frontend/src/locales/ptBR/translation.json b/app/frontend/src/locales/ptBR/translation.json index 3a57581e07..326017e72e 100644 --- a/app/frontend/src/locales/ptBR/translation.json +++ b/app/frontend/src/locales/ptBR/translation.json @@ -91,6 +91,7 @@ "useSemanticRanker": "Usar rankeador semântico para recuperação", "useSemanticCaptions": "Usar legendas semânticas", "useSuggestFollowupQuestions": "Sugerir perguntas complementares", + "useQueryRewriting": "Utilize a reescrita de consultas para a recuperação", "useGPT4V": "Usar modelo de visão GPT", "gpt4VInput": { "label": "Entradas do modelo de visão GPT", diff --git a/app/frontend/src/locales/tr/translation.json b/app/frontend/src/locales/tr/translation.json index 25b9dc9fe2..1fc0f95f14 100644 --- a/app/frontend/src/locales/tr/translation.json +++ b/app/frontend/src/locales/tr/translation.json @@ -90,6 +90,7 @@ "excludeCategory": "Kategori hariç tut", "useSemanticRanker": "Anlamsal sıralayıcı kullan", "useSemanticCaptions": "Anlamsal altyazılar kullan", + "useQueryRewriting": "Bilgi erişimi için sorgu yeniden yazımını kullanın", "useSuggestFollowupQuestions": "Takip soruları öner", "useGPT4V": "GPT vizyon modelini kullan", "gpt4VInput": { diff --git a/azure.yaml b/azure.yaml index a1a116a0b1..0793545f3a 100644 --- a/azure.yaml +++ b/azure.yaml @@ -56,6 +56,7 @@ pipeline: - AZURE_SEARCH_QUERY_LANGUAGE - AZURE_SEARCH_QUERY_SPELLER - AZURE_SEARCH_SEMANTIC_RANKER + - AZURE_SEARCH_QUERY_REWRITING - AZURE_STORAGE_ACCOUNT - AZURE_STORAGE_RESOURCE_GROUP - AZURE_STORAGE_SKU diff --git a/docs/deploy_features.md b/docs/deploy_features.md index d518afe09e..c024c802a8 100644 --- a/docs/deploy_features.md +++ b/docs/deploy_features.md @@ -324,10 +324,10 @@ Both these repositories adhere to the same [HTTP protocol for AI chat apps](http ## Enabling query rewriting -By default, [query rewriting](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite) from the search service is not enabled. To enable query rewriting, set the following environment variables: +By default, [query rewriting](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite) from the search service is not enabled. Note that the search service query rewriting feature is different from the query rewriting step that is used by the Chat tab in the codebase. That query rewriting step also incorporates conversation history, while the search service query rewriting step only considers the query itself. To enable search service query rewriting, set the following environment variables: 1. Ensure semantic ranker is enabled. Query rewriting may only be used with semantic ranker. Run `azd env set AZURE_SEARCH_SEMANTIC_RANKER free` or `azd env set AZURE_SEARCH_SEMANTIC_RANKER standard` depending on your desired [semantic ranker tier](https://learn.microsoft.com/azure/search/semantic-how-to-configure). -1. Enable query rewriting. Run `azd env set AUZRE_SEARCH_QUERY_REWRITING true`. An option in developer settings will appear allowing you to toggle query rewriting on and off. It will be on by default. +1. Enable query rewriting. Run `azd env set AZURE_SEARCH_QUERY_REWRITING true`. An option in developer settings will appear allowing you to toggle query rewriting on and off. It will be on by default. ## Adding an OpenAI load balancer diff --git a/tests/snapshots/test_app/test_ask_prompt_template/client0/result.json b/tests/snapshots/test_app/test_ask_prompt_template/client0/result.json index 7a6c0435e2..a57f32f79b 100644 --- a/tests/snapshots/test_app/test_ask_prompt_template/client0/result.json +++ b/tests/snapshots/test_app/test_ask_prompt_template/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_prompt_template/client1/result.json b/tests/snapshots/test_app/test_ask_prompt_template/client1/result.json index 900b381d3d..b7c4772f2a 100644 --- a/tests/snapshots/test_app/test_ask_prompt_template/client1/result.json +++ b/tests/snapshots/test_app/test_ask_prompt_template/client1/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_prompt_template_concat/client0/result.json b/tests/snapshots/test_app/test_ask_prompt_template_concat/client0/result.json index 675eb64f2b..e36395f5e4 100644 --- a/tests/snapshots/test_app/test_ask_prompt_template_concat/client0/result.json +++ b/tests/snapshots/test_app/test_ask_prompt_template_concat/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_prompt_template_concat/client1/result.json b/tests/snapshots/test_app/test_ask_prompt_template_concat/client1/result.json index f99704a849..4d243875f4 100644 --- a/tests/snapshots/test_app/test_ask_prompt_template_concat/client1/result.json +++ b/tests/snapshots/test_app/test_ask_prompt_template_concat/client1/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json index 34c2d1d02f..bf1c6fbba4 100644 --- a/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_hybrid/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json index 329f9a5a2c..1b0bab44e1 100644 --- a/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_hybrid/client1/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json index aae67770d8..2c73e1e4a6 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json index bb81be6b62..954e111ae2 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text/client1/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json index 165d67c48b..d7d7d8d8ee 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_filter/auth_client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": "category ne 'excluded' and (oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z')))", "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json index 856cb1feb5..843dddf2ee 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_filter_public_documents/auth_public_documents_client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": "category ne 'excluded' and ((oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z'))) or (not oids/any() and not groups/any()))", "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json index 8dc3f5895f..e1fb37182d 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": true, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json index 40764515f1..e36857e680 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticcaptions/client1/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": true, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json index 3081b75a4f..ddeeaeb9dd 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json index b9b375020a..7c7ef578ad 100644 --- a/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json +++ b/tests/snapshots/test_app/test_ask_rtr_text_semanticranker/client1/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_vision/client0/result.json b/tests/snapshots/test_app/test_ask_vision/client0/result.json index 3a1af082f2..2256db9e36 100644 --- a/tests/snapshots/test_app/test_ask_vision/client0/result.json +++ b/tests/snapshots/test_app/test_ask_vision/client0/result.json @@ -11,6 +11,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_ask_vision/client1/result.json b/tests/snapshots/test_app/test_ask_vision/client1/result.json index e2a7bd383f..7cc4da207b 100644 --- a/tests/snapshots/test_app/test_ask_vision/client1/result.json +++ b/tests/snapshots/test_app/test_ask_vision/client1/result.json @@ -14,6 +14,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_followup/client0/result.json b/tests/snapshots/test_app/test_chat_followup/client0/result.json index 4d2bf0a1cf..633214ebf0 100644 --- a/tests/snapshots/test_app/test_chat_followup/client0/result.json +++ b/tests/snapshots/test_app/test_chat_followup/client0/result.json @@ -46,6 +46,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_followup/client1/result.json b/tests/snapshots/test_app/test_chat_followup/client1/result.json index cc69247ea0..f833b85235 100644 --- a/tests/snapshots/test_app/test_chat_followup/client1/result.json +++ b/tests/snapshots/test_app/test_chat_followup/client1/result.json @@ -47,6 +47,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_hybrid/client0/result.json b/tests/snapshots/test_app/test_chat_hybrid/client0/result.json index d19e9bebb2..857bfbfa4a 100644 --- a/tests/snapshots/test_app/test_chat_hybrid/client0/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_hybrid/client1/result.json b/tests/snapshots/test_app/test_chat_hybrid/client1/result.json index 176021189d..42b4d48fa5 100644 --- a/tests/snapshots/test_app/test_chat_hybrid/client1/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json index bee8251cab..d71b09faa2 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": true, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json index bbbf9c6690..82eae5f3c6 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_captions/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": true, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json index cbabece418..ee8e3a1fc3 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json index 8b3ef1be8f..72e687455c 100644 --- a/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_hybrid_semantic_ranker/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json b/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json index 0b767e18d6..dbae5a68d1 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json b/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json index 38ac425c85..96a422af0d 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json b/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json index 2bc59068c7..e1a11cb763 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template_concat/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json b/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json index 42a9cefe11..1b018413f6 100644 --- a/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json +++ b/tests/snapshots/test_app/test_chat_prompt_template_concat/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_seed/client0/result.json b/tests/snapshots/test_app/test_chat_seed/client0/result.json index d19e9bebb2..857bfbfa4a 100644 --- a/tests/snapshots/test_app/test_chat_seed/client0/result.json +++ b/tests/snapshots/test_app/test_chat_seed/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_seed/client1/result.json b/tests/snapshots/test_app/test_chat_seed/client1/result.json index 176021189d..42b4d48fa5 100644 --- a/tests/snapshots/test_app/test_chat_seed/client1/result.json +++ b/tests/snapshots/test_app/test_chat_seed/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json b/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json index d8c166fdfc..3b2e03c376 100644 --- a/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json +++ b/tests/snapshots/test_app/test_chat_session_state_persists/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json b/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json index af76ba74a4..bd208997e0 100644 --- a/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json +++ b/tests/snapshots/test_app/test_chat_session_state_persists/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines index 3a7a469b65..044dfd3c5a 100644 --- a/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_followup/client0/result.jsonlines @@ -1,4 +1,4 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\"."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\"."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf]. ", "role": "assistant"}} {"delta": {"role": "assistant"}, "context": {"followup_questions": ["What is the capital of Spain?"]}} diff --git a/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines index 375a1cc35a..e9ec795489 100644 --- a/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_followup/client1/result.jsonlines @@ -1,4 +1,4 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\"."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf].\n\n\n\n\nGenerate 3 very brief follow-up questions that the user would likely ask next.\nEnclose the follow-up questions in double angle brackets. Example:\n<>\n<>\n<>\nDo not repeat questions that have already been asked.\nMake sure the last question ends with \">>\"."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf]. ", "role": "assistant"}} {"delta": {"role": "assistant"}, "context": {"followup_questions": ["What is the capital of Spain?"]}} diff --git a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines index 6e8b58f105..88bc7395e6 100644 --- a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": {"conversation_id": 1234}} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": {"conversation_id": 1234}} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines index 0056df7d73..868e8e0503 100644 --- a/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_session_state_persists/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": {"conversation_id": 1234}} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": {"conversation_id": 1234}} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines index 3d9f7f4e6b..0d89bd18da 100644 --- a/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_text/client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines index 2c3576786d..dc2f71386b 100644 --- a/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_text/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines index 5ec86d73c0..e5db8bfdf5 100644 --- a/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_text_filter/auth_client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": "category ne 'excluded' and (oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z')))", "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Benefit_Options-2.pdf: There is a whistleblower policy."]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: What is the capital of France?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "capital of France", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": "category ne 'excluded' and (oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z')))", "use_vector_search": false, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2", "content": "There is a whistleblower policy.", "embedding": null, "imageEmbedding": null, "category": null, "sourcepage": "Benefit_Options-2.pdf", "sourcefile": "Benefit_Options.pdf", "oids": null, "groups": null, "captions": [{"additional_properties": {}, "text": "Caption: A whistleblower policy.", "highlights": []}], "score": 0.03279569745063782, "reranker_score": 3.4577205181121826}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "What is the capital of France?\n\nSources:\n\nBenefit_Options-2.pdf: There is a whistleblower policy."}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines index 7bdb90607d..07fb0e7ad7 100644 --- a/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_vision/client0/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "Are interest rates high?\n\nSources:\n\nFinancial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "use_vector_search": true, "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.\nAnswer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.\nIf the question is not in English, answer in the language used in the question.\nEach source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. Use square brackets to reference the source, for example [info1.txt]. Don't combine sources, list each source separately, for example [info1.txt][info2.pdf]."}, {"role": "user", "content": "Are interest rates high?\n\nSources:\n\nFinancial Market Analysis Report 2023.pdf#page=6: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}], "props": {"model": "gpt-35-turbo"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "The capital of France is Paris. [Benefit_Options-2.pdf].", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines b/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines index b8c73dfa3a..c16c74f5fd 100644 --- a/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines +++ b/tests/snapshots/test_app/test_chat_stream_vision/client1/result.jsonlines @@ -1,3 +1,3 @@ -{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "], "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "top": 3, "filter": null, "vector_fields": ["embedding", "imageEmbedding"], "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts."}, {"role": "user", "content": [{"type": "text", "text": "Are interest rates high?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="}}, {"type": "text", "text": "Sources:\n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}]}], "props": {"model": "gpt-4"}}]}, "session_state": null} +{"delta": {"role": "assistant"}, "context": {"data_points": {"text": ["Financial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions "], "images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="]}, "thoughts": [{"title": "Prompt to generate search query", "description": [{"role": "system", "content": "Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base.\nYou have access to Azure AI Search index with 100's of documents.\nGenerate a search query based on the conversation and the new question.\nDo not include cited source filenames and document names e.g. info.txt or doc.pdf in the search query terms.\nDo not include any text inside [] or <<>> in the search query terms.\nDo not include any special characters like '+'.\nIf the question is not in English, translate the question to English before generating the search query.\nIf you cannot generate a search query, return just the number 0."}, {"role": "user", "content": "How did crypto do last year?"}, {"role": "assistant", "content": "Summarize Cryptocurrency Market Dynamics from last year"}, {"role": "user", "content": "What are my health plans?"}, {"role": "assistant", "content": "Show available health plans"}, {"role": "user", "content": "Generate search query for: Are interest rates high?"}], "props": {"model": "gpt-35-turbo", "deployment": "test-chatgpt"}}, {"title": "Search using generated search query", "description": "interest rates", "props": {"use_semantic_captions": false, "use_semantic_ranker": false, "use_query_rewriting": false, "top": 3, "filter": null, "vector_fields": ["embedding", "imageEmbedding"], "use_text_search": true}}, {"title": "Search results", "description": [{"id": "file-Financial_Market_Analysis_Report_2023_pdf-46696E616E6369616C204D61726B657420416E616C79736973205265706F727420323032332E706466-page-14", "content": "31\nFinancial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors\nImpact of Interest Rates, Inflation, and GDP Growth on Financial Markets\n5\n4\n3\n2\n1\n0\n-1 2018 2019\n-2\n-3\n-4\n-5\n2020\n2021 2022 2023\nMacroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance.\n-Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends\nRelative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100)\n2028\nBased on historical data, current trends, and economic indicators, this section presents predictions ", "embedding": "[-0.012668486, -0.02251158 ...+8 more]", "imageEmbedding": null, "category": null, "sourcepage": "Financial Market Analysis Report 2023-6.png", "sourcefile": "Financial Market Analysis Report 2023.pdf", "oids": null, "groups": null, "captions": [], "score": 0.04972677677869797, "reranker_score": 3.1704962253570557}], "props": null}, {"title": "Prompt to generate answer", "description": [{"role": "system", "content": "You are an intelligent assistant helping analyze the Annual Financial Report of Contoso Ltd., The documents contain text, graphs, tables and images.\nEach image source has the file name in the top left corner of the image with coordinates (10,10) pixels and is in the format SourceFileName:\nEach text source starts in a new line and has the file name followed by colon and the actual information\nAlways include the source name from the image or text for each fact you use in the response in the format: [filename]\nAnswer the following question using only the data provided in the sources below.\nIf asking a clarifying question to the user would help, ask the question.\nBe brief in your answers.\nThe text and image source can be the same file name, don't use the image title when citing the image source, only use the file name as mentioned\nIf you cannot answer using the sources below, say you don't know. Return just the answer without any input texts."}, {"role": "user", "content": [{"type": "text", "text": "Are interest rates high?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg=="}}, {"type": "text", "text": "Sources:\n\nFinancial Market Analysis Report 2023-6.png: 31 Financial markets are interconnected, with movements in one segment often influencing others. This section examines the correlations between stock indices, cryptocurrency prices, and commodity prices, revealing how changes in one market can have ripple effects across the financial ecosystem.Impact of Macroeconomic Factors Impact of Interest Rates, Inflation, and GDP Growth on Financial Markets 5 4 3 2 1 0 -1 2018 2019 -2 -3 -4 -5 2020 2021 2022 2023 Macroeconomic factors such as interest rates, inflation, and GDP growth play a pivotal role in shaping financial markets. This section analyzes how these factors have influenced stock, cryptocurrency, and commodity markets over recent years, providing insights into the complex relationship between the economy and financial market performance. -Interest Rates % -Inflation Data % GDP Growth % :unselected: :unselected:Future Predictions and Trends Relative Growth Trends for S&P 500, Bitcoin, and Oil Prices (2024 Indexed to 100) 2028 Based on historical data, current trends, and economic indicators, this section presents predictions"}]}], "props": {"model": "gpt-4"}}]}, "session_state": null} {"delta": {"content": null, "role": "assistant"}} {"delta": {"content": "From the provided sources, the impact of interest rates and GDP growth on financial markets can be observed through the line graph. [Financial Market Analysis Report 2023-7.png]", "role": null}} diff --git a/tests/snapshots/test_app/test_chat_text/client0/result.json b/tests/snapshots/test_app/test_chat_text/client0/result.json index 924d129764..d66effe4e6 100644 --- a/tests/snapshots/test_app/test_chat_text/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text/client1/result.json b/tests/snapshots/test_app/test_chat_text/client1/result.json index 2b84988fd1..f7a2e013b8 100644 --- a/tests/snapshots/test_app/test_chat_text/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json b/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json index 1c885ab857..ca97d22306 100644 --- a/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_filter/auth_client0/result.json @@ -44,6 +44,7 @@ "props": { "filter": "category ne 'excluded' and (oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z')))", "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json b/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json index aabacbdb86..bdf21417f6 100644 --- a/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_filter_public_documents/auth_public_documents_client0/result.json @@ -44,6 +44,7 @@ "props": { "filter": "category ne 'excluded' and ((oids/any(g:search.in(g, 'OID_X')) or groups/any(g:search.in(g, 'GROUP_Y, GROUP_Z'))) or (not oids/any() and not groups/any()))", "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json index c025b2e54c..b0a6403902 100644 --- a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json index 558fb49910..93a8833902 100644 --- a/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text_semantic_ranker/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json index 6213e7cc02..72a60376fe 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": true, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json index d75153a6b3..1fc7c93957 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticcaptions/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": true, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json b/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json index c025b2e54c..b0a6403902 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticranker/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json b/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json index 558fb49910..93a8833902 100644 --- a/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_text_semanticranker/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_vector/client0/result.json b/tests/snapshots/test_app/test_chat_vector/client0/result.json index 7041676e83..6573c5b945 100644 --- a/tests/snapshots/test_app/test_chat_vector/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vector/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": false, diff --git a/tests/snapshots/test_app/test_chat_vector/client1/result.json b/tests/snapshots/test_app/test_chat_vector/client1/result.json index 2d745baadb..3fc20d32f0 100644 --- a/tests/snapshots/test_app/test_chat_vector/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vector/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": false, diff --git a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json index 31f43c5808..588a397a1f 100644 --- a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": false, diff --git a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json index f98540864c..c1e9ef14d2 100644 --- a/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vector_semantic_ranker/client1/result.json @@ -44,6 +44,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": true, "use_text_search": false, diff --git a/tests/snapshots/test_app/test_chat_vision/client0/result.json b/tests/snapshots/test_app/test_chat_vision/client0/result.json index 33767fae6f..00fdfc9201 100644 --- a/tests/snapshots/test_app/test_chat_vision/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vision/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_vision/client1/result.json b/tests/snapshots/test_app/test_chat_vision/client1/result.json index ec9dc5fa8f..33c03e28bf 100644 --- a/tests/snapshots/test_app/test_chat_vision/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vision/client1/result.json @@ -47,6 +47,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json b/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json index 7b4d85a69b..9dedc6c9bb 100644 --- a/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json +++ b/tests/snapshots/test_app/test_chat_vision_vectors/client0/result.json @@ -43,6 +43,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": false, diff --git a/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json b/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json index f1817e3475..8be46e5f57 100644 --- a/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json +++ b/tests/snapshots/test_app/test_chat_vision_vectors/client1/result.json @@ -47,6 +47,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": false, diff --git a/tests/snapshots/test_app/test_chat_with_history/client0/result.json b/tests/snapshots/test_app/test_chat_with_history/client0/result.json index 7c183e306a..83120be851 100644 --- a/tests/snapshots/test_app/test_chat_with_history/client0/result.json +++ b/tests/snapshots/test_app/test_chat_with_history/client0/result.json @@ -51,6 +51,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_with_history/client1/result.json b/tests/snapshots/test_app/test_chat_with_history/client1/result.json index 3a0e189894..3d4f28a5e1 100644 --- a/tests/snapshots/test_app/test_chat_with_history/client1/result.json +++ b/tests/snapshots/test_app/test_chat_with_history/client1/result.json @@ -52,6 +52,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json b/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json index 31de3f31f7..04236d396a 100644 --- a/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json +++ b/tests/snapshots/test_app/test_chat_with_long_history/client0/result.json @@ -51,6 +51,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, diff --git a/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json b/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json index 68dd8cdbef..a394beb355 100644 --- a/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json +++ b/tests/snapshots/test_app/test_chat_with_long_history/client1/result.json @@ -52,6 +52,7 @@ "props": { "filter": null, "top": 3, + "use_query_rewriting": false, "use_semantic_captions": false, "use_semantic_ranker": false, "use_text_search": true, From 606ee94b913bfe980e37162c25c73c0f73bfb891 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Wed, 19 Mar 2025 10:35:00 -0700 Subject: [PATCH 08/10] Default query rewriting to false --- infra/main.parameters.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/main.parameters.json b/infra/main.parameters.json index 7bd1111afd..6f825b99fd 100644 --- a/infra/main.parameters.json +++ b/infra/main.parameters.json @@ -81,7 +81,7 @@ "value": "${AZURE_SEARCH_SEMANTIC_RANKER=free}" }, "searchServiceQueryRewriting": { - "value": "${AZURE_SEARCH_QUERY_REWRITING}" + "value": "${AZURE_SEARCH_QUERY_REWRITING=false}" }, "storageAccountName": { "value": "${AZURE_STORAGE_ACCOUNT}" From 0e71301a5244d33f4fae905f9f086ea81be6a30c Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Wed, 19 Mar 2025 10:36:50 -0700 Subject: [PATCH 09/10] Docs tweaks --- docs/deploy_features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deploy_features.md b/docs/deploy_features.md index c024c802a8..653d7e0162 100644 --- a/docs/deploy_features.md +++ b/docs/deploy_features.md @@ -324,7 +324,7 @@ Both these repositories adhere to the same [HTTP protocol for AI chat apps](http ## Enabling query rewriting -By default, [query rewriting](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite) from the search service is not enabled. Note that the search service query rewriting feature is different from the query rewriting step that is used by the Chat tab in the codebase. That query rewriting step also incorporates conversation history, while the search service query rewriting step only considers the query itself. To enable search service query rewriting, set the following environment variables: +By default, the [query rewriting feature](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite) from the Azure AI Search service is not enabled. Note that the search service query rewriting feature is different from the query rewriting step that is used by the Chat tab in the codebase. The in-repo query rewriting step also incorporates conversation history, while the search service query rewriting feature only considers the query itself. To enable search service query rewriting, set the following environment variables: 1. Ensure semantic ranker is enabled. Query rewriting may only be used with semantic ranker. Run `azd env set AZURE_SEARCH_SEMANTIC_RANKER free` or `azd env set AZURE_SEARCH_SEMANTIC_RANKER standard` depending on your desired [semantic ranker tier](https://learn.microsoft.com/azure/search/semantic-how-to-configure). 1. Enable query rewriting. Run `azd env set AZURE_SEARCH_QUERY_REWRITING true`. An option in developer settings will appear allowing you to toggle query rewriting on and off. It will be on by default. From 5eefb2d8fd3f566e7d44cca228e4048b452f8ac9 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Wed, 19 Mar 2025 11:10:49 -0700 Subject: [PATCH 10/10] Add region note --- docs/deploy_features.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/deploy_features.md b/docs/deploy_features.md index 653d7e0162..4fb3a2e93b 100644 --- a/docs/deploy_features.md +++ b/docs/deploy_features.md @@ -326,6 +326,7 @@ Both these repositories adhere to the same [HTTP protocol for AI chat apps](http By default, the [query rewriting feature](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite) from the Azure AI Search service is not enabled. Note that the search service query rewriting feature is different from the query rewriting step that is used by the Chat tab in the codebase. The in-repo query rewriting step also incorporates conversation history, while the search service query rewriting feature only considers the query itself. To enable search service query rewriting, set the following environment variables: +1. Check that your Azure AI Search service is using one of the [supported regions](https://learn.microsoft.com/azure/search/semantic-how-to-query-rewrite#prerequisites) for query rewriting. 1. Ensure semantic ranker is enabled. Query rewriting may only be used with semantic ranker. Run `azd env set AZURE_SEARCH_SEMANTIC_RANKER free` or `azd env set AZURE_SEARCH_SEMANTIC_RANKER standard` depending on your desired [semantic ranker tier](https://learn.microsoft.com/azure/search/semantic-how-to-configure). 1. Enable query rewriting. Run `azd env set AZURE_SEARCH_QUERY_REWRITING true`. An option in developer settings will appear allowing you to toggle query rewriting on and off. It will be on by default.