Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backend API] Implement endpoint for list of deployment models #170 #334

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5a716e2
Update GHA workflow
justinyoo Aug 18, 2024
cd02479
Merge branch 'aliencube:main' into main
yjchun626 Aug 19, 2024
8a0e04f
Merge branch 'aliencube:main' into main
yjchun626 Aug 20, 2024
eaaa3cc
Up to date with upstream/main branch
yjchun626 Sep 6, 2024
8b25658
Merge branch 'aliencube:main' into main
yjchun626 Sep 6, 2024
65406a1
Merge branch 'aliencube:main' into main
yjchun626 Sep 7, 2024
36a9455
Merge branch 'aliencube:main' into main
yjchun626 Sep 16, 2024
5771516
Merge branch 'aliencube:main' into main
yjchun626 Sep 19, 2024
db49368
Merge branch 'aliencube:main' into main
yjchun626 Sep 20, 2024
98a5121
Merge branch 'aliencube:main' into main
yjchun626 Sep 24, 2024
0a52171
Merge branch 'aliencube:main' into main
yjchun626 Oct 5, 2024
e8e5c0a
feat: EventRepository, PlaygroundService 추가 및 PlaygroundEndpoint 수정
yjchun626 Oct 6, 2024
d38d28c
Merge branch 'aliencube:main' into main
yjchun626 Oct 6, 2024
2b41bda
Merge branch 'aliencube:main' into feature/170-deployment-model-list-…
yjchun626 Oct 6, 2024
1d92e8e
refactor: PlaygroundEndpoints - Logger 명 수정
yjchun626 Oct 6, 2024
7a843ea
feat: EventRepository에 GetDeploymentModels 추가
yjchun626 Oct 6, 2024
4fc1450
refactor: PlaygroundEndpoints 리팩토링
yjchun626 Oct 6, 2024
fd9ca79
Merge branch 'aliencube:main' into main
yjchun626 Oct 16, 2024
4da7b24
Merge branch 'main' of https://github.com/yjchun626/azure-openai-sdk-…
yjchun626 Oct 16, 2024
9c8c6d7
chore: PlaygroundService.cs
yjchun626 Oct 16, 2024
8033776
test: PlaygroundServiceTests - GetDeploymentModels 관련 테스트 수
yjchun626 Oct 16, 2024
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
58 changes: 29 additions & 29 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AspireVersion>8.2.1</AspireVersion>
<AzureOpenAIVersion>2.*-*</AzureOpenAIVersion>
<AspNetCoreVersion>8.*</AspNetCoreVersion>
<MicrosoftExtensionsVersion>8.*</MicrosoftExtensionsVersion>
<OpenTelemetryExporterVersion>1.*</OpenTelemetryExporterVersion>
<OpenTelemetryExtensionsVersion>1.*</OpenTelemetryExtensionsVersion>
<OpenTelemetryInstrumentationVersion>1.*</OpenTelemetryInstrumentationVersion>
<SwashbuckleVersion>6.*</SwashbuckleVersion>
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
<FluentUIVersion>4.*</FluentUIVersion>
<CoverletVersion>6.*</CoverletVersion>
<FluentAssertionsVersion>6.*</FluentAssertionsVersion>
<MicrosoftTestSdkVersion>17.*</MicrosoftTestSdkVersion>
<NSubstituteVersion>5.*</NSubstituteVersion>
<NUnitVersion>4.*</NUnitVersion>
<PlaywrightVersion>1.*</PlaywrightVersion>
<XunitVersion>2.*</XunitVersion>
</PropertyGroup>
</Project>
<Project>
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<AspireVersion>8.2.1</AspireVersion>
<AzureOpenAIVersion>2.*-*</AzureOpenAIVersion>
<AspNetCoreVersion>8.*</AspNetCoreVersion>
<MicrosoftExtensionsVersion>8.*</MicrosoftExtensionsVersion>
<OpenTelemetryExporterVersion>1.*</OpenTelemetryExporterVersion>
<OpenTelemetryExtensionsVersion>1.*</OpenTelemetryExtensionsVersion>
<OpenTelemetryInstrumentationVersion>1.*</OpenTelemetryInstrumentationVersion>
<SwashbuckleVersion>6.*</SwashbuckleVersion>
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
<FluentUIVersion>4.*</FluentUIVersion>

<CoverletVersion>6.*</CoverletVersion>
<FluentAssertionsVersion>6.*</FluentAssertionsVersion>
<MicrosoftTestSdkVersion>17.*</MicrosoftTestSdkVersion>
<NSubstituteVersion>5.*</NSubstituteVersion>
<NUnitVersion>4.*</NUnitVersion>
<PlaywrightVersion>1.*</PlaywrightVersion>
<XunitVersion>2.*</XunitVersion>
</PropertyGroup>
</Project>
33 changes: 29 additions & 4 deletions src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,36 @@ public static RouteHandlerBuilder AddListEvents(this WebApplication app)
public static RouteHandlerBuilder AddListDeploymentModels(this WebApplication app)
{
// Todo: Issue #170 https://github.com/aliencube/azure-openai-sdk-proxy/issues/170
var builder = app.MapGet(PlaygroundEndpointUrls.DeploymentModels, (
[FromRoute] string eventId
var builder = app.MapGet(PlaygroundEndpointUrls.DeploymentModels, async (
[FromRoute] Guid eventId,
IPlaygroundService service,
ILoggerFactory loggerFactory
) =>
{
return Results.Ok();
var logger = loggerFactory.CreateLogger(nameof(PlaygroundEndpoints));
logger.LogInformation($"Received request to fetch deployment models list for event with ID: {eventId}");

try
{
var deploymentModelsList = await service.GetDeploymentModels(eventId);
return Results.Ok(deploymentModelsList);
}
catch (RequestFailedException ex)
{
if(ex.Status == 404)
{
logger.LogError($"Failed to fetch deployment models list of {eventId}");
return Results.NotFound();
}

logger.LogError(ex, $"Failed to fetch deployment models list of {eventId} with status {ex.Status}");
return Results.Problem(ex.Message, statusCode: StatusCodes.Status500InternalServerError);
}
catch (Exception ex)
{
logger.LogError(ex, $"Failed to fetch deployment models list of {eventId}");
return Results.Problem(ex.Message, statusCode: StatusCodes.Status500InternalServerError);
}
})
.Produces<List<DeploymentModelDetails>>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
.Produces(statusCode: StatusCodes.Status401Unauthorized)
Expand All @@ -77,7 +102,7 @@ [FromRoute] string eventId
.WithOpenApi(operation =>
{
operation.Summary = "Gets all deployment models";
operation.Description = "This endpoint gets all deployment models avaliable";
operation.Description = "This endpoint gets all deployment models available";

return operation;
});
Expand Down
9 changes: 7 additions & 2 deletions src/AzureOpenAIProxy.ApiApp/Services/PlaygroundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// Get the list of deployment model.
/// </summary>
/// <returns>Returns the list of deployment models.</returns>
Task<List<DeploymentModelDetails>> GetDeploymentModels(string eventId);
Task<List<DeploymentModelDetails>> GetDeploymentModels(Guid eventId);

/// <summary>
/// Get the list of events.
Expand All @@ -23,9 +23,14 @@
public class PlaygroundService(IEventRepository eventRepository) : IPlaygroundService
{
private readonly IEventRepository _eventRepository = eventRepository ?? throw new ArgumentNullException(nameof(eventRepository));

/// <inheritdoc/>
public async Task<List<DeploymentModelDetails>> GetDeploymentModels(string eventId)
public async Task<List<DeploymentModelDetails>> GetDeploymentModels(Guid eventId)

Check warning on line 28 in src/AzureOpenAIProxy.ApiApp/Services/PlaygroundService.cs

View workflow job for this annotation

GitHub Actions / build-test

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
// var result = await _eventRepository.GetDeploymentModels(eventId).ConfigureAwait(false);

// return result;

throw new NotImplementedException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Given_ServiceCollection_When_AddPlaygroundService_Invoked_Then_It_Sh
public void Given_Instance_When_GetDeploymentModels_Invoked_Then_It_Should_Throw_Exception()
{
// Arrange
string eventId = "test-id";
var eventId = Guid.NewGuid();
var repository = Substitute.For<IEventRepository>();
var service = new PlaygroundService(repository);

Expand Down
Loading