diff --git a/Directory.Build.props b/Directory.Build.props index 1854c7b9..79fc5503 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,29 +1,29 @@ - - - - net8.0 - latest - - enable - enable - - 8.2.1 - 2.*-* - 8.* - 8.* - 1.* - 1.* - 1.* - 6.* - 8.* - 4.* - - 6.* - 6.* - 17.* - 5.* - 4.* - 1.* - 2.* - - + + + + net8.0 + latest + + enable + enable + + 8.2.1 + 2.*-* + 8.* + 8.* + 1.* + 1.* + 1.* + 6.* + 8.* + 4.* + + 6.* + 6.* + 17.* + 5.* + 4.* + 1.* + 2.* + + diff --git a/src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpoints.cs b/src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpoints.cs index 5a55fe77..803240df 100644 --- a/src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpoints.cs +++ b/src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpoints.cs @@ -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>(statusCode: StatusCodes.Status200OK, contentType: "application/json") .Produces(statusCode: StatusCodes.Status401Unauthorized) @@ -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; }); diff --git a/src/AzureOpenAIProxy.ApiApp/Services/PlaygroundService.cs b/src/AzureOpenAIProxy.ApiApp/Services/PlaygroundService.cs index 5d9ef331..aac15902 100644 --- a/src/AzureOpenAIProxy.ApiApp/Services/PlaygroundService.cs +++ b/src/AzureOpenAIProxy.ApiApp/Services/PlaygroundService.cs @@ -11,7 +11,7 @@ public interface IPlaygroundService /// Get the list of deployment model. /// /// Returns the list of deployment models. - Task> GetDeploymentModels(string eventId); + Task> GetDeploymentModels(Guid eventId); /// /// Get the list of events. @@ -23,9 +23,14 @@ public interface IPlaygroundService public class PlaygroundService(IEventRepository eventRepository) : IPlaygroundService { private readonly IEventRepository _eventRepository = eventRepository ?? throw new ArgumentNullException(nameof(eventRepository)); + /// - public async Task> GetDeploymentModels(string eventId) + public async Task> GetDeploymentModels(Guid eventId) { + // var result = await _eventRepository.GetDeploymentModels(eventId).ConfigureAwait(false); + + // return result; + throw new NotImplementedException(); } diff --git a/test/AzureOpenAIProxy.ApiApp.Tests/Services/PlaygroundServiceTests.cs b/test/AzureOpenAIProxy.ApiApp.Tests/Services/PlaygroundServiceTests.cs index 38e93879..f810a14c 100644 --- a/test/AzureOpenAIProxy.ApiApp.Tests/Services/PlaygroundServiceTests.cs +++ b/test/AzureOpenAIProxy.ApiApp.Tests/Services/PlaygroundServiceTests.cs @@ -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(); var service = new PlaygroundService(repository);