Skip to content

Commit 57fcc94

Browse files
committed
Always enable integrated vectorization at query time
1 parent de64620 commit 57fcc94

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

src/Azure.AISearch.WebApp/Models/SearchRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class SearchRequest
1010
public QuerySyntax QuerySyntax { get; set; } = QuerySyntax.Simple;
1111
public DataSourceType DataSource { get; set; } = DataSourceType.None;
1212
public string? OpenAIGptDeployment { get; set; }
13-
public bool UseIntegratedVectorization { get; set; }
13+
public bool UseIntegratedVectorization { get; set; } = true;
1414
public int? VectorNearestNeighborsCount { get; set; } = Constants.Defaults.VectorNearestNeighborsCount;
1515
public bool LimitToDataSource { get; set; } = true; // "Limit responses to your data content"
1616
public string? SystemRoleInformation { get; set; } // Give the model instructions about how it should behave and any context it should reference when generating a response. You can describe the assistant’s personality, tell it what it should and shouldn’t answer, and tell it how to format responses. There’s no token limit for this section, but it will be included with every API call, so it counts against the overall token limit.

src/Azure.AISearch.WebApp/Services/AzureCognitiveSearchConfigurationService.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,8 @@ private async Task CreateChunksIndex(AppSettingsOverride? settingsOverride, stri
397397

398398
private SearchIndex GetChunksSearchIndex(string chunkIndexName, AppSettingsOverride? settingsOverride)
399399
{
400-
var chunksSearchIndex = new SearchIndex(chunkIndexName)
400+
ArgumentNullException.ThrowIfNull(this.settings.OpenAIEndpoint);
401+
return new SearchIndex(chunkIndexName)
401402
{
402403
Fields =
403404
{
@@ -434,6 +435,9 @@ private SearchIndex GetChunksSearchIndex(string chunkIndexName, AppSettingsOverr
434435
Profiles =
435436
{
436437
new VectorSearchProfile(Constants.ConfigurationNames.VectorSearchProfileNameDefault, Constants.ConfigurationNames.VectorSearchAlgorithNameDefault)
438+
{
439+
Vectorizer = Constants.ConfigurationNames.VectorSearchVectorizerNameDefault
440+
}
437441
},
438442
Algorithms =
439443
{
@@ -447,28 +451,21 @@ private SearchIndex GetChunksSearchIndex(string chunkIndexName, AppSettingsOverr
447451
Metric = Constants.Defaults.HnswParametersMetric
448452
}
449453
}
454+
},
455+
Vectorizers =
456+
{
457+
new AzureOpenAIVectorizer(Constants.ConfigurationNames.VectorSearchVectorizerNameDefault)
458+
{
459+
AzureOpenAIParameters = new AzureOpenAIParameters
460+
{
461+
ResourceUri = new Uri(this.settings.OpenAIEndpoint),
462+
DeploymentId = this.settings.OpenAIEmbeddingDeployment,
463+
ApiKey = this.settings.OpenAIApiKey
464+
}
465+
}
450466
}
451467
}
452468
};
453-
454-
var searchIndexerSkillType = GetSearchIndexerSkillType(settingsOverride);
455-
if (string.Equals(searchIndexerSkillType, Constants.SearchIndexerSkillTypes.Integrated, StringComparison.InvariantCultureIgnoreCase))
456-
{
457-
// For integrated vectorization, use the OpenAI vectorizer to generate the embeddings for the search query itself.
458-
ArgumentNullException.ThrowIfNull(this.settings.OpenAIEndpoint);
459-
chunksSearchIndex.VectorSearch.Vectorizers.Add(new AzureOpenAIVectorizer(Constants.ConfigurationNames.VectorSearchVectorizerNameDefault)
460-
{
461-
AzureOpenAIParameters = new AzureOpenAIParameters
462-
{
463-
ResourceUri = new Uri(this.settings.OpenAIEndpoint),
464-
DeploymentId = this.settings.OpenAIEmbeddingDeployment,
465-
ApiKey = this.settings.OpenAIApiKey
466-
}
467-
});
468-
chunksSearchIndex.VectorSearch.Profiles[0].Vectorizer = Constants.ConfigurationNames.VectorSearchVectorizerNameDefault;
469-
}
470-
471-
return chunksSearchIndex;
472469
}
473470

474471
private TimeSpan GetIndexingSchedule(AppSettingsOverride? settingsOverride)

0 commit comments

Comments
 (0)