Skip to content

Commit d366ea4

Browse files
committed
Add app setting for default system role information
1 parent 8ed1eba commit d366ea4

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

azuredeploy-webapp.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"searchIndexNameBlobDocuments": "blob-documents",
5656
"searchIndexNameBlobChunks": "blob-chunks",
5757
"searchIndexerScheduleMinutes": 5,
58+
"defaultSystemRoleInformation": "You are an AI assistant that helps people find information.",
5859
"disableUploadDocuments": false,
5960
"disableResetSearchConfiguration": false
6061
},
@@ -364,6 +365,10 @@
364365
"name": "InitialDocumentUrls",
365366
"value": "[parameters('initialDocumentUrls')]"
366367
},
368+
{
369+
"name": "DefaultSystemRoleInformation",
370+
"value": "[variables('defaultSystemRoleInformation')]"
371+
},
367372
{
368373
"name": "DisableUploadDocuments",
369374
"value": "[variables('disableUploadDocuments')]"
@@ -458,6 +463,10 @@
458463
"type": "string",
459464
"value": "[parameters('initialDocumentUrls')]"
460465
},
466+
"defaultSystemRoleInformation": {
467+
"type": "string",
468+
"value": "[variables('defaultSystemRoleInformation')]"
469+
},
461470
"disableUploadDocuments": {
462471
"type": "bool",
463472
"value": "[variables('disableUploadDocuments')]"

src/Azure.AISearch.WebApp/AppSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class AppSettings
2222
public string? SearchIndexNameBlobChunks { get; set; }
2323
public int? SearchIndexerScheduleMinutes { get; set; } // If unspecified, will be set to 5 minutes.
2424
public string? InitialDocumentUrls { get; set; }
25+
public string? DefaultSystemRoleInformation { get; set; } = "You are an AI assistant that helps people find information.";
2526
public bool DisableUploadDocuments { get; set; } // If true, the Upload Documents functionality will be disabled.
2627
public bool DisableResetSearchConfiguration { get; set; } // If true, the Reset Search Configuration functionality will be disabled.
2728
}

src/Azure.AISearch.WebApp/Constants.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@ public static class ConfigurationNames
1515
public const string SemanticConfigurationNameDefault = "default";
1616
public const string VectorSearchConfigurationNameDefault = "default";
1717
}
18-
19-
public static class SystemRoleInformations
20-
{
21-
public const string Default = "You are an AI assistant that helps people find information.";
22-
}
2318
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class SearchRequest
99
public QueryType QueryType { get; set; } = QueryType.TextStandard;
1010
public DataSourceType DataSource { get; set; } = DataSourceType.None;
1111
public bool LimitToDataSource { get; set; } = true; // "Limit responses to your data content"
12-
public string SystemRoleInformation { get; set; } = Constants.SystemRoleInformations.Default; // 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.
12+
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.
1313

1414
public bool IsVectorSearch => QueryType == Models.QueryType.Vector || QueryType == Models.QueryType.HybridStandard || QueryType == Models.QueryType.HybridSemantic;
1515
public bool IsSemanticSearch => QueryType == Models.QueryType.TextSemantic || QueryType == Models.QueryType.HybridSemantic;

src/Azure.AISearch.WebApp/Pages/Index.cshtml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@ namespace Azure.AISearch.WebApp.Pages;
66

77
public class IndexModel : PageModel
88
{
9+
private readonly AppSettings settings;
910
private readonly SearchRequestHandler searchRequestHandler;
1011
private readonly SearchScenarioProvider searchScenarioProvider;
1112

1213
public IList<SearchScenario> Scenarios { get; set; }
1314
public SearchRequest SearchRequest { get; set; }
1415
public SearchResponse? SearchResponse { get; set; }
1516

16-
public IndexModel(SearchRequestHandler searchRequestHandler, SearchScenarioProvider searchScenarioProvider)
17+
public IndexModel(AppSettings settings, SearchRequestHandler searchRequestHandler, SearchScenarioProvider searchScenarioProvider)
1718
{
19+
this.settings = settings;
1820
this.searchRequestHandler = searchRequestHandler;
1921
this.searchScenarioProvider = searchScenarioProvider;
2022
this.Scenarios = this.searchScenarioProvider.GetSearchScenarios();
21-
this.SearchRequest = new SearchRequest();
23+
this.SearchRequest = new SearchRequest
24+
{
25+
SystemRoleInformation = this.settings.DefaultSystemRoleInformation
26+
};
2227
}
2328

2429
public async Task OnPost(SearchRequest searchRequest)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public IList<SearchScenario> GetSearchScenarios()
109109
SearchRequest = new SearchRequest
110110
{
111111
Engine = EngineType.AzureOpenAI,
112-
DataSource = DataSourceType.None
112+
DataSource = DataSourceType.None,
113+
SystemRoleInformation = this.settings.DefaultSystemRoleInformation
113114
}
114115
},
115116
new SearchScenario
@@ -120,9 +121,10 @@ public IList<SearchScenario> GetSearchScenarios()
120121
SearchRequest = new SearchRequest
121122
{
122123
Engine = EngineType.AzureOpenAI,
124+
DataSource = DataSourceType.AzureCognitiveSearch,
125+
SystemRoleInformation = this.settings.DefaultSystemRoleInformation,
123126
SearchIndex = SearchIndexType.Chunks, // As a built-in scenario, always use the chunks index for best results
124127
QueryType = QueryType.TextSemantic, // As a built-in scenario, always use semantic search for best results
125-
DataSource = DataSourceType.AzureCognitiveSearch,
126128
LimitToDataSource = true
127129
}
128130
}

0 commit comments

Comments
 (0)