Skip to content

Commit

Permalink
feat: Updated OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 28, 2024
1 parent f982118 commit 75a27d2
Show file tree
Hide file tree
Showing 35 changed files with 1,672 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ public partial class CompletionClient
{
partial void PrepareV1J2JumboCompleteArguments(
global::System.Net.Http.HttpClient httpClient,
ref string customModelName,
ref string? customModelType,
ref string? model,
global::AI21.CompletionBody request);
partial void PrepareV1J2JumboCompleteRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string customModelName,
string? customModelType,
string? model,
global::AI21.CompletionBody request);
partial void ProcessV1J2JumboCompleteResponse(
global::System.Net.Http.HttpClient httpClient,
Expand All @@ -26,18 +24,16 @@ partial void ProcessV1J2JumboCompleteResponseContent(
ref string content);

/// <summary>
/// Custom j2-jumbo complete
/// j2-jumbo complete
/// </summary>
/// <param name="customModelName"></param>
/// <param name="customModelType">
/// <param name="model">
/// Default Value: j2-jumbo
/// </param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::AI21.V1J2JumboCompleteResponse2> V1J2JumboCompleteAsync(
string customModelName,
string? customModelType,
public async global::System.Threading.Tasks.Task<global::AI21.V1J2JumboCompleteResponse> V1J2JumboCompleteAsync(
string? model,
global::AI21.CompletionBody request,
global::System.Threading.CancellationToken cancellationToken = default)
{
Expand All @@ -47,13 +43,12 @@ partial void ProcessV1J2JumboCompleteResponseContent(
client: _httpClient);
PrepareV1J2JumboCompleteArguments(
httpClient: _httpClient,
customModelName: ref customModelName,
customModelType: ref customModelType,
model: ref model,
request: request);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/studio/v1/j2-jumbo/{customModelName}/complete?custom_model_type={customModelType}", global::System.UriKind.RelativeOrAbsolute));
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/studio/v1/j2-jumbo/complete?model={model}", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::AI21.SourceGenerationContext.Default.CompletionBody);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
Expand All @@ -67,8 +62,7 @@ partial void ProcessV1J2JumboCompleteResponseContent(
PrepareV1J2JumboCompleteRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
customModelName: customModelName,
customModelType: customModelType,
model: model,
request: request);

using var response = await _httpClient.SendAsync(
Expand Down Expand Up @@ -104,15 +98,14 @@ partial void ProcessV1J2JumboCompleteResponseContent(
}

return
global::System.Text.Json.JsonSerializer.Deserialize(__content, global::AI21.SourceGenerationContext.Default.V1J2JumboCompleteResponse2) ??
global::System.Text.Json.JsonSerializer.Deserialize(__content, global::AI21.SourceGenerationContext.Default.V1J2JumboCompleteResponse) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}

/// <summary>
/// Custom j2-jumbo complete
/// j2-jumbo complete
/// </summary>
/// <param name="customModelName"></param>
/// <param name="customModelType">
/// <param name="model">
/// Default Value: j2-jumbo
/// </param>
/// <param name="prompt"></param>
Expand Down Expand Up @@ -145,10 +138,9 @@ partial void ProcessV1J2JumboCompleteResponseContent(
/// <param name="epoch"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::AI21.V1J2JumboCompleteResponse2> V1J2JumboCompleteAsync(
string customModelName,
public async global::System.Threading.Tasks.Task<global::AI21.V1J2JumboCompleteResponse> V1J2JumboCompleteAsync(
string prompt,
string? customModelType = "j2-jumbo",
string? model = "j2-jumbo",
int numResults = 1,
int maxTokens = 16,
int minTokens = 0,
Expand Down Expand Up @@ -183,8 +175,7 @@ partial void ProcessV1J2JumboCompleteResponseContent(
};

return await V1J2JumboCompleteAsync(
customModelName: customModelName,
customModelType: customModelType,
model: model,
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
192 changes: 192 additions & 0 deletions src/libs/AI21/Generated/AI21.CompletionClient.V1J2JumboComplete2.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@

#nullable enable

namespace AI21
{
public partial class CompletionClient
{
partial void PrepareV1J2JumboComplete2Arguments(
global::System.Net.Http.HttpClient httpClient,
ref string customModelName,
ref string? customModelType,
global::AI21.CompletionBody request);
partial void PrepareV1J2JumboComplete2Request(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string customModelName,
string? customModelType,
global::AI21.CompletionBody request);
partial void ProcessV1J2JumboComplete2Response(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessV1J2JumboComplete2ResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// Custom j2-jumbo complete
/// </summary>
/// <param name="customModelName"></param>
/// <param name="customModelType">
/// Default Value: j2-jumbo
/// </param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::AI21.V1J2JumboCompleteResponse2> V1J2JumboComplete2Async(
string customModelName,
string? customModelType,
global::AI21.CompletionBody request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareV1J2JumboComplete2Arguments(
httpClient: _httpClient,
customModelName: ref customModelName,
customModelType: ref customModelType,
request: request);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/studio/v1/j2-jumbo/{customModelName}/complete?custom_model_type={customModelType}", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::AI21.SourceGenerationContext.Default.CompletionBody);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareV1J2JumboComplete2Request(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
customModelName: customModelName,
customModelType: customModelType,
request: request);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessV1J2JumboComplete2Response(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessV1J2JumboComplete2ResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException ex)
{
throw new global::System.InvalidOperationException(__content, ex);
}

return
global::System.Text.Json.JsonSerializer.Deserialize(__content, global::AI21.SourceGenerationContext.Default.V1J2JumboCompleteResponse2) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}

/// <summary>
/// Custom j2-jumbo complete
/// </summary>
/// <param name="customModelName"></param>
/// <param name="customModelType">
/// Default Value: j2-jumbo
/// </param>
/// <param name="prompt"></param>
/// <param name="numResults">
/// Default Value: 1
/// </param>
/// <param name="maxTokens">
/// Default Value: 16
/// </param>
/// <param name="minTokens">
/// Default Value: 0
/// </param>
/// <param name="temperature">
/// Default Value: 1
/// </param>
/// <param name="topP">
/// Default Value: 1
/// </param>
/// <param name="minP">
/// Default Value: 0
/// </param>
/// <param name="stopSequences"></param>
/// <param name="topKReturn">
/// Default Value: 0
/// </param>
/// <param name="logitBias"></param>
/// <param name="frequencyPenalty"></param>
/// <param name="presencePenalty"></param>
/// <param name="countPenalty"></param>
/// <param name="epoch"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::AI21.V1J2JumboCompleteResponse2> V1J2JumboComplete2Async(
string customModelName,
string prompt,
string? customModelType = "j2-jumbo",
int numResults = 1,
int maxTokens = 16,
int minTokens = 0,
double temperature = 1,
double topP = 1,
double minP = 0,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int topKReturn = 0,
global::AI21.CompletionBodyLogitBias? logitBias = default,
global::System.AllOf<global::AI21.Penalty>? frequencyPenalty = default,
global::System.AllOf<global::AI21.Penalty>? presencePenalty = default,
global::System.AllOf<global::AI21.Penalty>? countPenalty = default,
int epoch = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::AI21.CompletionBody
{
Prompt = prompt,
NumResults = numResults,
MaxTokens = maxTokens,
MinTokens = minTokens,
Temperature = temperature,
TopP = topP,
MinP = minP,
StopSequences = stopSequences,
TopKReturn = topKReturn,
LogitBias = logitBias,
FrequencyPenalty = frequencyPenalty,
PresencePenalty = presencePenalty,
CountPenalty = countPenalty,
Epoch = epoch,
};

return await V1J2JumboComplete2Async(
customModelName: customModelName,
customModelType: customModelType,
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Loading

0 comments on commit 75a27d2

Please sign in to comment.