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

[OpenAPI] Add endpoint for list of deployment models #294

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ public static class PlaygroundEndpointUrls
/// - GET method for listing all events
/// </remarks>
public const string Events = "/events";

/// <summary>
/// Declares the deployment models list endpoint.
/// </summary>
/// <remarks>
/// - GET method for listing all deployment models
/// </remarks>
public const string DeploymentModels = "/events/{eventId}/deployment-models";
}
33 changes: 33 additions & 0 deletions src/AzureOpenAIProxy.ApiApp/Endpoints/PlaygroundEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.AspNetCore.Mvc;
justinyoo marked this conversation as resolved.
Show resolved Hide resolved

namespace AzureOpenAIProxy.ApiApp.Endpoints;

/// <summary>
Expand Down Expand Up @@ -32,4 +34,35 @@ public static RouteHandlerBuilder AddListEvents(this WebApplication app)

return builder;
}


/// <summary>
/// Adds the get deployment models
/// </summary>
/// <param name="app"><see cref="WebApplication"/> instance.</param>
/// <returns>Returns <see cref="RouteHandlerBuilder"/> instance.</returns>
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
) =>
{
return Results.Ok();
})
.Produces<List<DeploymentModelDetails>>(statusCode: StatusCodes.Status200OK, contentType: "application/json")
.Produces(statusCode: StatusCodes.Status401Unauthorized)
jihyunmoon16 marked this conversation as resolved.
Show resolved Hide resolved
.Produces<string>(statusCode: StatusCodes.Status500InternalServerError, contentType: "text/plain")
.WithTags("events")
.WithName("GetDeploymentModels")
.WithOpenApi(operation =>
{
operation.Summary = "Gets all deployment models";
operation.Description = "This endpoint gets all deployment models avaliable";

return operation;
});

return builder;
}
}
23 changes: 23 additions & 0 deletions src/AzureOpenAIProxy.ApiApp/Models/DeploymentModelDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Text.Json.Serialization;

/// <summary>
/// This represent the event detail data for response by admin event endpoint.
/// </summary>
public class DeploymentModelDetails
{
/// <summary>
/// Gets or sets the deployment id of the model.
/// </summary>
[JsonRequired]
public int? Id { get; set; }

/// <summary>
/// Gets or sets the deployment model name.
/// </summary>
public string? Name { get; set; }

/// <summary>
/// Gets or sets the version of deployment model.
/// </summary>
public string? version { get; set; }
}
jihyunmoon16 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/AzureOpenAIProxy.ApiApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

// Playground endpoints
app.AddListEvents();
app.AddListDeploymentModels();

// Admin endpoints
app.AddNewAdminEvent();
Expand Down
Loading