Skip to content

Commit

Permalink
Fix #135 & #161 & #140 (#162)
Browse files Browse the repository at this point in the history
## Purpose
<!-- Describe the intention of the changes being proposed. What problem
does it solve or functionality does it add? -->
Clean services that used by /ask

Related issue:
- #135 
- #161 
- #140 
This PR also remove `ApproachServiceResponseFactory` and GPT model that
used for text completion

## Does this introduce a breaking change?
<!-- Mark one with an "x". -->
```
[ ] Yes
[ ] No
```

## Pull Request Type
What kind of change does this Pull Request introduce?

<!-- Please check the one that applies to this PR using "x". -->
```
[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:
```

## How to Test
*  Get the code

```
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
```

* Test the code
<!-- Add steps to run the tests suite and/or manually test -->
```
```

## What to Check
Verify that the following are valid
* ...

## Other Information
<!-- Add any other helpful information that may be needed here. -->
  • Loading branch information
LittleLittleCloud authored Sep 25, 2023
1 parent 92ae671 commit 19ae117
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 678 deletions.
21 changes: 0 additions & 21 deletions app/backend/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,11 @@ internal static IServiceCollection AddAzureServices(this IServiceCollection serv
return openAIClient;
});

services.AddSingleton<IKernel>(sp =>
{
// Semantic Kernel doesn't support Azure AAD credential for now
// so we implement our own text completion backend
var config = sp.GetRequiredService<IConfiguration>();
var azureOpenAiGptDeployment = config["AzureOpenAiGptDeployment"];

var openAITextService = sp.GetRequiredService<AzureOpenAITextCompletionService>();
var kernel = Kernel.Builder.Build();
kernel.Config.AddTextCompletionService(azureOpenAiGptDeployment!, _ => openAITextService);

return kernel;
});

services.AddSingleton<AzureBlobStorageService>();

services.AddSingleton<AzureOpenAITextCompletionService>();
services.AddSingleton<AzureOpenAIChatCompletionService>();
services.AddSingleton<ReadRetrieveReadChatService>();

services.AddSingleton<IApproachBasedService, RetrieveThenReadApproachService>();
services.AddSingleton<IApproachBasedService, ReadRetrieveReadApproachService>();
services.AddSingleton<IApproachBasedService, ReadDecomposeAskApproachService>();

services.AddSingleton<ApproachServiceResponseFactory>();

return services;
}

Expand Down
3 changes: 0 additions & 3 deletions app/backend/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
global using Azure.Storage.Blobs.Models;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Mvc.RazorPages;
global using Microsoft.Extensions.Caching.Distributed;
global using Microsoft.ML;
global using Microsoft.ML.Transforms.Text;
global using Microsoft.SemanticKernel;
Expand All @@ -22,10 +21,8 @@
global using Microsoft.SemanticKernel.AI.TextCompletion;
global using Microsoft.SemanticKernel.Memory;
global using Microsoft.SemanticKernel.Orchestration;
global using Microsoft.SemanticKernel.SkillDefinition;
global using MinimalApi.Extensions;
global using MinimalApi.Services;
global using MinimalApi.Services.Skills;
global using PdfSharpCore.Pdf;
global using PdfSharpCore.Pdf.IO;
global using Shared;
Expand Down
96 changes: 0 additions & 96 deletions app/backend/Services/ApproachServiceResponseFactory.cs

This file was deleted.

4 changes: 2 additions & 2 deletions app/backend/Services/AzureOpenAIChatCompletionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public async Task<string> CompleteAsync(
var response =
await _openAIClient.GetCompletionsAsync(
_deployedModelName, option, cancellationToken);
return response.Value is Completions completions && completions.Choices.Count > 0
? completions.Choices[0].Text
return response.Value is Completions completions && completions.Choices.Count > 0
? completions.Choices[0].Text
: throw new AIException(AIException.ErrorCodes.InvalidConfiguration, "completion not found");
}
}
43 changes: 0 additions & 43 deletions app/backend/Services/AzureOpenAITextCompletionService.cs

This file was deleted.

13 changes: 0 additions & 13 deletions app/backend/Services/IApproachBasedService.cs

This file was deleted.

Loading

0 comments on commit 19ae117

Please sign in to comment.