Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -0,0 +1,244 @@

#nullable enable

namespace Together
{
public partial class FineTuningClient
{
partial void PrepareDeleteFineTunesByIdArguments(
global::System.Net.Http.HttpClient httpClient,
ref string id,
ref bool force);
partial void PrepareDeleteFineTunesByIdRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string id,
bool force);
partial void ProcessDeleteFineTunesByIdResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

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

/// <summary>
/// Delete a fine-tune job<br/>
/// Delete a fine-tuning job.
/// </summary>
/// <param name="id"></param>
/// <param name="force"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Together.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Together.FinetuneDeleteResponse> DeleteFineTunesByIdAsync(
string id,
bool force,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
PrepareDeleteFineTunesByIdArguments(
httpClient: HttpClient,
id: ref id,
force: ref force);

var __pathBuilder = new global::Together.PathBuilder(
path: $"/fine-tunes/{id}",
baseUri: HttpClient.BaseAddress);
__pathBuilder
.AddRequiredParameter("force", force.ToString())
;
var __path = __pathBuilder.ToString();
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Delete,
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
__httpRequest.Version = global::System.Net.HttpVersion.Version11;
__httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif

foreach (var __authorization in Authorizations)
{
if (__authorization.Type == "Http" ||
__authorization.Type == "OAuth2")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
parameter: __authorization.Value);
}
else if (__authorization.Type == "ApiKey" &&
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}

PrepareRequest(
client: HttpClient,
request: __httpRequest);
PrepareDeleteFineTunesByIdRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
id: id,
force: force);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: HttpClient,
response: __response);
ProcessDeleteFineTunesByIdResponse(
httpClient: HttpClient,
httpResponseMessage: __response);
// Fine-tune job not found
if ((int)__response.StatusCode == 404)
{
string? __content_404 = null;
global::System.Exception? __exception_404 = null;
global::Together.ErrorData? __value_404 = null;
try
{
if (ReadResponseAsString)
{
__content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
__value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext);
}
else
{
var __contentStream_404 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_404 = await global::Together.ErrorData.FromJsonStreamAsync(__contentStream_404, JsonSerializerContext).ConfigureAwait(false);
}
}
catch (global::System.Exception __ex)
{
__exception_404 = __ex;
}

throw new global::Together.ApiException<global::Together.ErrorData>(
message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_404,
statusCode: __response.StatusCode)
{
ResponseBody = __content_404,
ResponseObject = __value_404,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
// Internal server error
if ((int)__response.StatusCode == 500)
{
string? __content_500 = null;
global::System.Exception? __exception_500 = null;
global::Together.ErrorData? __value_500 = null;
try
{
if (ReadResponseAsString)
{
__content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
__value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext);
}
else
{
var __contentStream_500 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_500 = await global::Together.ErrorData.FromJsonStreamAsync(__contentStream_500, JsonSerializerContext).ConfigureAwait(false);
}
}
catch (global::System.Exception __ex)
{
__exception_500 = __ex;
}

throw new global::Together.ApiException<global::Together.ErrorData>(
message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_500,
statusCode: __response.StatusCode)
{
ResponseBody = __content_500,
ResponseObject = __value_500,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}

if (ReadResponseAsString)
{
var __content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

ProcessResponseContent(
client: HttpClient,
response: __response,
content: ref __content);
ProcessDeleteFineTunesByIdResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response,
content: ref __content);

try
{
__response.EnsureSuccessStatusCode();

return
global::Together.FinetuneDeleteResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
catch (global::System.Exception __ex)
{
throw new global::Together.ApiException(
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
else
{
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

return
await global::Together.FinetuneDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
catch (global::System.Exception __ex)
{
throw new global::Together.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#nullable enable

namespace Together
{
public partial interface IFineTuningClient
{
/// <summary>
/// Delete a fine-tune job<br/>
/// Delete a fine-tuning job.
/// </summary>
/// <param name="id"></param>
/// <param name="force"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Together.ApiException"></exception>
global::System.Threading.Tasks.Task<global::Together.FinetuneDeleteResponse> DeleteFineTunesByIdAsync(
string id,
bool force,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Loading
Loading