Skip to content

Commit

Permalink
Merge pull request #413 from solliancenet/aa-gatekeeper-api
Browse files Browse the repository at this point in the history
Fix double string replacement and updated config docs
  • Loading branch information
ciprianjichici authored Dec 22, 2023
2 parents 945ba20 + de2778f commit 8aef194
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
3 changes: 2 additions & 1 deletion docs/deployment/app-configuration-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ FoundationaLLM uses Azure App Configuration to store configuration values, Key V
| `FoundationaLLM:APIs:GatekeeperAPI:APIKey` | Key Vault secret name: `foundationallm-apis-gatekeeperapi-apikey` | This is a Key Vault reference. |
| `FoundationaLLM:APIs:GatekeeperAPI:APIUrl` | Enter the URL to the service. | |
| `FoundationaLLM:APIs:GatekeeperAPI:AppInsightsConnectionString` | Key Vault secret name: `foundationallm-app-insights-connection-string` | This is a Key Vault reference. |
| `FoundationaLLM:APIs:GatekeeperAPI:Configuration` | `{"EnableAzureContentSafety":true,"EnableMicrosoftPresidio":true}` | This is JSON object. |
| `FoundationaLLM:APIs:GatekeeperAPI:Configuration:EnableAzureContentSafety` | true | By default, the Gatekeeper API has Azure Content Safety integration enabled. To disable this feature, set this value to false. |
| `FoundationaLLM:APIs:GatekeeperAPI:Configuration:EnableMicrosoftPresidio` | true | By default, the Gatekeeper API has Microsoft Presidio integration enabled. To disable this feature, set this value to false. |
| `FoundationaLLM:APIs:GatekeeperAPI:ForceHttpsRedirection` | true | By default, the Gatekeeper API forces HTTPS redirection. To override this behavior and allow it to handle HTTP requests, set this value to false. |
| `FoundationaLLM:APIs:GatekeeperIntegrationAPI:APIKey` | Key Vault secret name: `foundationallm-apis-gatekeeperintegrationapi-apikey` | This is a Key Vault reference. |
| `FoundationaLLM:APIs:GatekeeperIntegrationAPI:APIUrl` | Enter the URL to the service. | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ public async Task<string> AnonymizeText(string text)
var responseContent = await responseMessage.Content.ReadAsStringAsync();
var analysisResults = JsonConvert.DeserializeObject<AnonymizeResponse>(responseContent);

var anonymizedText = text;

foreach (var result in analysisResults!.Results)
{
anonymizedText = anonymizedText.Remove(result.StartIndex, (result.EndIndex - result.StartIndex + 1));
anonymizedText = anonymizedText.Insert(result.StartIndex, result.AnonymizedText);
}

return anonymizedText;
return analysisResults!.Content;
}
else
return "A problem on my side prevented me from responding.";
Expand Down
10 changes: 0 additions & 10 deletions src/dotnet/Gatekeeper/Services/GatekeeperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ public async Task<CompletionResponse> GetCompletion(CompletionRequest completion
var completionResponse = await _agentFactoryAPIService.GetCompletion(completionRequest);

if (_gatekeeperServiceSettings.EnableMicrosoftPresidio)
{
//var textAnalysisResults = await _gatekeeperIntegrationAPIService.AnalyzeText(completionResponse.Completion);
//if (textAnalysisResults.Count > 0)

completionResponse.Completion = await _gatekeeperIntegrationAPIService.AnonymizeText(completionResponse.Completion);
}

return completionResponse;
}
Expand All @@ -90,12 +85,7 @@ public async Task<SummaryResponse> GetSummary(SummaryRequest summaryRequest)
var summaryResponse = await _agentFactoryAPIService.GetSummary(summaryRequest);

if (_gatekeeperServiceSettings.EnableMicrosoftPresidio)
{
//var textAnalysisResults = await _gatekeeperIntegrationAPIService.AnalyzeText(summaryResponse.Summary!);
//if (textAnalysisResults.Count > 0)

summaryResponse.Summary = await _gatekeeperIntegrationAPIService.AnonymizeText(summaryResponse.Summary!);
}

return summaryResponse;
}
Expand Down

0 comments on commit 8aef194

Please sign in to comment.