Skip to content

Commit

Permalink
OpenAI-DotNet-Proxy 7.7.10 (#296)
Browse files Browse the repository at this point in the history
- Updated EndpointRouteBuilder with optional route prefix parameter
  • Loading branch information
StephenHodgson authored May 9, 2024
1 parent cbfbabb commit 03bdded
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions OpenAI-DotNet-Proxy/OpenAI-DotNet-Proxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
<PackageTags>OpenAI, AI, ML, API, gpt, gpt-4, gpt-3.5-turbo, gpt-3, chatGPT, api-proxy, proxy, gateway</PackageTags>
<Title>OpenAI API Proxy</Title>
<PackageId>OpenAI-DotNet-Proxy</PackageId>
<Version>7.7.9</Version>
<Version>7.7.10</Version>
<Company>RageAgainstThePixel</Company>
<RootNamespace>OpenAI.Proxy</RootNamespace>
<PackageIcon>OpenAI-DotNet-Icon.png</PackageIcon>
<PackageReleaseNotes>Version 7.7.9
<PackageReleaseNotes>Version 7.7.10
- Updated EndpointRouteBuilder with optional route prefix parameter
Version 7.7.9
- Slight refactor of OpenAIProxyStartup to remove duplicate code
- Added OpenAI.Proxy.EndpointRouteBuilder
Version 7.7.8
Expand Down
11 changes: 9 additions & 2 deletions OpenAI-DotNet-Proxy/Proxy/EndpointRouteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ public static class EndpointRouteBuilder
#endif
};

public static void MapOpenAIEndpoints(this IEndpointRouteBuilder endpoints, OpenAIClient openAIClient, IAuthenticationFilter authenticationFilter)
/// <summary>
/// Maps the <see cref="OpenAIClient"/> endpoints.
/// </summary>
/// <param name="endpoints"><see cref="IEndpointRouteBuilder"/>.</param>
/// <param name="openAIClient"><see cref="OpenAIClient"/>.</param>
/// <param name="authenticationFilter"><see cref="IAuthenticationFilter"/>.</param>
/// <param name="routePrefix">Optional, custom route prefix. i.e. '/openai'.</param>
public static void MapOpenAIEndpoints(this IEndpointRouteBuilder endpoints, OpenAIClient openAIClient, IAuthenticationFilter authenticationFilter, string routePrefix = "")
{
endpoints.Map($"{openAIClient.OpenAIClientSettings.BaseRequest}{{**endpoint}}", HandleRequest);
endpoints.Map($"{routePrefix}{openAIClient.OpenAIClientSettings.BaseRequest}{{**endpoint}}", HandleRequest);

async Task HandleRequest(HttpContext httpContext, string endpoint)
{
Expand Down

0 comments on commit 03bdded

Please sign in to comment.