Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .azdo/pipelines/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions app/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
CONFIG_INGESTER,
CONFIG_LANGUAGE_PICKER_ENABLED,
CONFIG_OPENAI_CLIENT,
CONFIG_QUERY_REWRITING_ENABLED,
CONFIG_SEARCH_CLIENT,
CONFIG_SEMANTIC_RANKER_DEPLOYED,
CONFIG_SPEECH_INPUT_ENABLED,
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -634,6 +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_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
Expand Down
2 changes: 2 additions & 0 deletions app/backend/approaches/approach.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = None,
) -> List[Document]:
search_text = query_text if use_text_search else ""
search_vectors = vectors if use_vector_search else []
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions app/backend/approaches/chatreadretrieveread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -190,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,
Expand Down
3 changes: 3 additions & 0 deletions app/backend/approaches/chatreadretrievereadvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -207,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,
Expand Down
3 changes: 3 additions & 0 deletions app/backend/approaches/retrievethenread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -89,6 +90,7 @@ async def run(
use_semantic_captions,
minimum_search_score,
minimum_reranker_score,
use_query_rewriting,
)

# Process results
Expand Down Expand Up @@ -118,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,
Expand Down
3 changes: 3 additions & 0 deletions app/backend/approaches/retrievethenreadvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -108,6 +109,7 @@ async def run(
use_semantic_captions,
minimum_search_score,
minimum_reranker_score,
use_query_rewriting,
)

# Process results
Expand Down Expand Up @@ -145,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,
Expand Down
1 change: 1 addition & 0 deletions app/backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/backend/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/frontend/src/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,6 +85,7 @@ export type ChatAppRequest = {
export type Config = {
showGPT4VOptions: boolean;
showSemanticRankerOption: boolean;
showQueryRewritingOption: boolean;
showVectorOption: boolean;
showUserUpload: boolean;
showLanguagePicker: boolean;
Expand Down
20 changes: 20 additions & 0 deletions app/frontend/src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ export interface SettingsProps {
minimumRerankerScore: number;
useSemanticRanker: boolean;
useSemanticCaptions: boolean;
useQueryRewriting: boolean;
excludeCategory: string;
includeCategory: string;
retrievalMode: RetrievalMode;
useGPT4V: boolean;
gpt4vInput: GPT4VInput;
vectorFieldList: VectorFieldOptions[];
showSemanticRankerOption: boolean;
showQueryRewritingOption: boolean;
showGPT4VOptions: boolean;
showVectorOption: boolean;
useOidSecurityFilter: boolean;
Expand All @@ -51,13 +53,15 @@ export const Settings = ({
minimumRerankerScore,
useSemanticRanker,
useSemanticCaptions,
useQueryRewriting,
excludeCategory,
includeCategory,
retrievalMode,
useGPT4V,
gpt4vInput,
vectorFieldList,
showSemanticRankerOption,
showQueryRewritingOption,
showGPT4VOptions,
showVectorOption,
useOidSecurityFilter,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -239,6 +244,21 @@ export const Settings = ({
</>
)}

{showQueryRewritingOption && (
<>
<Checkbox
id={queryRewritingFieldId}
className={styles.settingsSeparator}
checked={useQueryRewriting}
disabled={!useSemanticRanker}
label={t("labels.useQueryRewriting")}
onChange={(_ev, checked) => onChange("useQueryRewriting", !!checked)}
aria-labelledby={queryRewritingFieldId}
onRenderLabel={props => renderLabel(props, queryRewritingFieldId, queryRewritingFieldId, t("helpTexts.useQueryRewriting"))}
/>
</>
)}

{useLogin && (
<>
<Checkbox
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/da/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions app/frontend/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"excludeCategory": "Exclude category",
"useSemanticRanker": "Use semantic ranker for retrieval",
"useSemanticCaptions": "Use semantic captions",
"useQueryRewriting": "Use query rewriting for retrieval",
"useSuggestFollowupQuestions": "Suggest follow-up questions",
"useGPT4V": "Use GPT vision model",
"gpt4VInput": {
Expand Down Expand Up @@ -139,6 +140,8 @@
"Specifies a category to exclude from the search results. There are no categories used in the default data set.",
"useSemanticReranker":
"Enables the Azure AI Search semantic ranker, a model that re-ranks search results based on semantic similarity to the user's query.",
"useQueryRewriting":
"Enables Azure AI Search query rewriting, a process that modifies the user's query to improve search results. Requires semantic ranker to be enabled.",
"useSemanticCaptions":
"Sends semantic captions to the LLM instead of the full search result. A semantic caption is extracted from a search result during the process of semantic ranking.",
"suggestFollowupQuestions": "Asks the LLM to suggest follow-up questions based on the user's query.",
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"excludeCategory": "カテゴリを除外",
"useSemanticRanker": "取得にセマンティック・ランカーを使用",
"useSemanticCaptions": "セマンティック・キャプションを使用",
"useQueryRewriting": "検索のためにクエリの書き換えを使用する",
"useSuggestFollowupQuestions": "フォローアップの質問を提案",
"useGPT4V": "GPT Visionモデルを使用",
"gpt4VInput": {
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/ptBR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/locales/tr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading
Loading