Skip to content

Commit

Permalink
Merge pull request #76 from tryAGI/bot/update-openapi_202411121510
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 12, 2024
2 parents 4ce608a + 27ada62 commit d900b21
Show file tree
Hide file tree
Showing 99 changed files with 5,321 additions and 3,536 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ partial void ProcessCreateMessageResponseContent(
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
/// <exception cref="global::Anthropic.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Anthropic.Message> CreateMessageAsync(
global::Anthropic.CreateMessageRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -93,29 +93,70 @@ partial void ProcessCreateMessageResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response);

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

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

try
{
__response.EnsureSuccessStatusCode();
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Anthropic.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),
};
}

return
global::Anthropic.Message.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
catch (global::System.Net.Http.HttpRequestException __ex)
else
{
throw new global::System.InvalidOperationException(__content, __ex);
}
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Anthropic.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),
};
}

using var __responseStream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);

return
global::Anthropic.Message.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
var __responseValue = await global::Anthropic.Message.FromJsonStreamAsync(__responseStream, JsonSerializerContext).ConfigureAwait(false);

return
__responseValue ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ partial void ProcessCreateMessageBatchResponseContent(
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
/// <exception cref="global::Anthropic.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Anthropic.MessageBatch> CreateMessageBatchAsync(
global::Anthropic.CreateMessageBatchRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -90,29 +90,70 @@ partial void ProcessCreateMessageBatchResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response);

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

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

try
if (ReadResponseAsString)
{
__response.EnsureSuccessStatusCode();
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

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

try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Anthropic.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),
};
}

return
global::Anthropic.MessageBatch.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
catch (global::System.Net.Http.HttpRequestException __ex)
else
{
throw new global::System.InvalidOperationException(__content, __ex);
}
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Anthropic.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),
};
}

using var __responseStream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);

return
global::Anthropic.MessageBatch.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
var __responseValue = await global::Anthropic.MessageBatch.FromJsonStreamAsync(__responseStream, JsonSerializerContext).ConfigureAwait(false);

return
__responseValue ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ partial void ProcessRetrieveMessageBatchResponseContent(
/// </summary>
/// <param name="id"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
/// <exception cref="global::Anthropic.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Anthropic.MessageBatch> RetrieveMessageBatchAsync(
string id,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -84,29 +84,70 @@ partial void ProcessRetrieveMessageBatchResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response);

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

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

try
{
__response.EnsureSuccessStatusCode();
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Anthropic.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),
};
}

return
global::Anthropic.MessageBatch.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
catch (global::System.Net.Http.HttpRequestException __ex)
else
{
throw new global::System.InvalidOperationException(__content, __ex);
}
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Anthropic.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),
};
}

using var __responseStream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);

return
global::Anthropic.MessageBatch.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
var __responseValue = await global::Anthropic.MessageBatch.FromJsonStreamAsync(__responseStream, JsonSerializerContext).ConfigureAwait(false);

return
__responseValue ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
}
}
}
5 changes: 5 additions & 0 deletions src/libs/Anthropic/Generated/Anthropic.AnthropicClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public sealed partial class AnthropicClient : global::Anthropic.IAnthropicClient
/// <inheritdoc/>
public global::System.Collections.Generic.List<global::Anthropic.EndPointAuthorization> Authorizations { get; }

/// <inheritdoc/>
public bool ReadResponseAsString { get; set; }
#if DEBUG
= true;
#endif
/// <summary>
///
/// </summary>
Expand Down
90 changes: 90 additions & 0 deletions src/libs/Anthropic/Generated/Anthropic.Exceptions.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#nullable enable

namespace Anthropic
{
/// <summary>
/// Represents an exception thrown by the API.
/// </summary>
[global::System.Serializable]
public partial class ApiException : global::System.Exception
{
/// <summary>
/// The HTTP status code of the response.
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }
/// <summary>
/// The response body.
/// </summary>
public string? ResponseBody { get; set; }
/// <summary>
/// The response headers.
/// </summary>
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>>? ResponseHeaders { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
public ApiException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message.
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="statusCode">The HTTP status code of the response.</param>
public ApiException(string message, global::System.Net.HttpStatusCode statusCode) : base(message)
{
StatusCode = statusCode;
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
/// <param name="statusCode">The HTTP status code of the response.</param>
public ApiException(string message, global::System.Exception innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException)
{
StatusCode = statusCode;
}
}

/// <summary>
/// Represents an exception thrown by the API.
/// </summary>
/// <typeparam name="T"></typeparam>
[global::System.Serializable]
public partial class ApiException<T> : ApiException
{
/// <summary>
/// The response object.
/// </summary>
public T? ResponseObject { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
public ApiException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message.
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="statusCode">The HTTP status code of the response.</param>
public ApiException(string message, global::System.Net.HttpStatusCode statusCode) : base(message, statusCode)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
/// <param name="statusCode">The HTTP status code of the response.</param>
public ApiException(string message, global::System.Exception innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException, statusCode)
{
}
}
}
Loading

0 comments on commit d900b21

Please sign in to comment.