Skip to content

Commit

Permalink
Merge pull request #31 from tryAGI/bot/update-openapi_202410010150
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 1, 2024
2 parents 10c1c07 + 185d644 commit e96014a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 7 deletions.
48 changes: 48 additions & 0 deletions src/libs/HuggingFace/Generated/AnyOf.2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,54 @@ public bool Validate()
return IsValue1 || IsValue2;
}

/// <summary>
///
/// </summary>
public TResult? Match<TResult>(
global::System.Func<T1, TResult>? value1 = null,
global::System.Func<T2, TResult>? value2 = null,
bool validate = true)
{
if (validate)
{
Validate();
}

if (IsValue1 && value1 != null)
{
return value1(Value1!);
}
else if (IsValue2 && value2 != null)
{
return value2(Value2!);
}

return default(TResult);
}

/// <summary>
///
/// </summary>
public void Match(
global::System.Action<T1>? value1 = null,
global::System.Action<T2>? value2 = null,
bool validate = true)
{
if (validate)
{
Validate();
}

if (IsValue1)
{
value1?.Invoke(Value1!);
}
else if (IsValue2)
{
value2?.Invoke(Value2!);
}
}

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public void AuthorizeUsingBearer(
{
apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey));

_httpClient.DefaultRequestHeaders.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: "Bearer",
parameter: apiKey);
_authorization = new global::HuggingFace.EndPointAuthorization
{
Name = "Bearer",
Value = apiKey,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ namespace HuggingFace
{
public sealed partial class HuggingFaceApi
{
/// <inheritdoc cref="HuggingFaceApi(global::System.Net.Http.HttpClient?, global::System.Uri?)"/>
/// <inheritdoc cref="HuggingFaceApi(global::System.Net.Http.HttpClient?, global::System.Uri?, global::HuggingFace.EndPointAuthorization?)"/>
public HuggingFaceApi(
string apiKey,
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
global::System.Uri? baseUri = null,
global::HuggingFace.EndPointAuthorization? authorization = null) : this(httpClient, baseUri, authorization)
{
Authorizing(_httpClient, ref apiKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ partial void ProcessGenerateTextResponseContent(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));

if (_authorization != null)
{{
httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: _authorization.Name,
parameter: _authorization.Value);
}}
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), JsonSerializerContext);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public sealed partial class HuggingFaceApi : global::HuggingFace.IHuggingFaceApi
public const string BaseUrl = "https://api-inference.huggingface.co/";

private readonly global::System.Net.Http.HttpClient _httpClient;
private global::HuggingFace.EndPointAuthorization? _authorization;

/// <summary>
///
Expand All @@ -29,13 +30,16 @@ public sealed partial class HuggingFaceApi : global::HuggingFace.IHuggingFaceApi
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
/// <param name="httpClient"></param>
/// <param name="baseUri"></param>
/// <param name="baseUri"></param>
/// <param name="authorization"></param>
public HuggingFaceApi(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null)
global::System.Uri? baseUri = null,
global::HuggingFace.EndPointAuthorization? authorization = null)
{
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_authorization = authorization;

Initialized(_httpClient);
}
Expand Down
16 changes: 16 additions & 0 deletions src/libs/HuggingFace/Generated/HuggingFace.PathBuilder.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,20 @@ public PathBuilder AddOptionalParameter<T>(
/// <returns>The constructed URL.</returns>
public override string ToString() => _stringBuilder.ToString();
}

/// <summary>
///
/// </summary>
public class EndPointAuthorization
{
/// <summary>
///
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
///
/// </summary>
public string Value { get; set; } = string.Empty;
}
}

0 comments on commit e96014a

Please sign in to comment.