Skip to content

Commit

Permalink
fix: Fixed issue with non letter/non digit symbols in Tag name.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 30, 2024
1 parent fa4e39a commit 873bcac
Show file tree
Hide file tree
Showing 1,053 changed files with 46,937 additions and 46,933 deletions.
6 changes: 5 additions & 1 deletion src/libs/AutoSDK/Naming/Clients/ClientNameGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public static string GeneratePropertyName(
{
tag = tag ?? throw new ArgumentNullException(nameof(tag));

return PropertyData.SanitizeName(tag.Name.ToClassName(), settings.ClsCompliantEnumPrefix);
var name = new string(tag.Name
.SkipWhile(c => !char.IsDigit(c) && !char.IsLetter(c))
.ToArray());

return PropertyData.SanitizeName(name.ToClassName(), settings.ClsCompliantEnumPrefix);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,55 @@ public sealed partial class Api : global::G.IApi, global::System.IDisposable
/// <summary>
/// Namespaces (e.g. User, Organization) that structure the resource hierarchy.
/// </summary>
public x__NamespaceClient x__Namespace => new x__NamespaceClient(HttpClient, authorizations: Authorizations)
public NamespaceClient Namespace => new NamespaceClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// Pipeline orchestration in VDP (Versatile Data Pipeline).
/// </summary>
public x__VDPClient x__VDP => new x__VDPClient(HttpClient, authorizations: Authorizations)
public VDPClient VDP => new VDPClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// AI Model resources for MLOps/LLMOps.
/// </summary>
public x__ModelClient x__Model => new x__ModelClient(HttpClient, authorizations: Authorizations)
public ModelClient Model => new ModelClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// Data orchestration for unified unstructured data representation.
/// </summary>
public x__ArtifactClient x__Artifact => new x__ArtifactClient(HttpClient, authorizations: Authorizations)
public ArtifactClient Artifact => new ArtifactClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// Ready-to-use AI applications.
/// </summary>
public x__AppClient x__App => new x__AppClient(HttpClient, authorizations: Authorizations)
public AppClient App => new AppClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// Resource usage metrics.
/// </summary>
public x__MetricsClient x__Metrics => new x__MetricsClient(HttpClient, authorizations: Authorizations)
public MetricsClient Metrics => new MetricsClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};

/// <summary>
/// Pricing plans on Instill Cloud.
/// </summary>
public x__SubscriptionClient x__Subscription => new x__SubscriptionClient(HttpClient, authorizations: Authorizations)
public SubscriptionClient Subscription => new SubscriptionClient(HttpClient, authorizations: Authorizations)
{
JsonSerializerOptions = JsonSerializerOptions,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
//HintName: G.AppClient.AppPublicServiceChat.g.cs

#nullable enable

namespace G
{
public partial class AppClient
{
partial void PrepareAppPublicServiceChatArguments(
global::System.Net.Http.HttpClient httpClient,
ref string namespaceId,
ref string appId,
global::G.ChatBody request);
partial void PrepareAppPublicServiceChatRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string namespaceId,
string appId,
global::G.ChatBody request);
partial void ProcessAppPublicServiceChatResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

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

/// <summary>
/// Chat<br/>
/// Chat sends a message asynchronously and streams back the response.<br/>
/// This method is intended for real-time conversation with a chatbot<br/>
/// and the response needs to be processed incrementally.
/// </summary>
/// <param name="namespaceId"></param>
/// <param name="appId"></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::G.ChatResponse> AppPublicServiceChatAsync(
string namespaceId,
string appId,
global::G.ChatBody request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: HttpClient);
PrepareAppPublicServiceChatArguments(
httpClient: HttpClient,
namespaceId: ref namespaceId,
appId: ref appId,
request: request);

var __pathBuilder = new PathBuilder(
path: $"/v1alpha/namespaces/{namespaceId}/apps/{appId}/chat",
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
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));

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);
}
}
var __httpRequestContentBody = request.ToJson(JsonSerializerOptions);
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);
PrepareAppPublicServiceChatRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
namespaceId: namespaceId,
appId: appId,
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);
ProcessAppPublicServiceChatResponse(
httpClient: HttpClient,
httpResponseMessage: __response);

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

ProcessResponseContent(
client: HttpClient,
response: __response,
content: ref __content);
ProcessAppPublicServiceChatResponseContent(
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::G.ChatResponse.FromJson(__content, JsonSerializerOptions) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}

/// <summary>
/// Chat<br/>
/// Chat sends a message asynchronously and streams back the response.<br/>
/// This method is intended for real-time conversation with a chatbot<br/>
/// and the response needs to be processed incrementally.
/// </summary>
/// <param name="namespaceId"></param>
/// <param name="appId"></param>
/// <param name="catalogId"></param>
/// <param name="conversationUid"></param>
/// <param name="message"></param>
/// <param name="topK"></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::G.ChatResponse> AppPublicServiceChatAsync(
string namespaceId,
string appId,
string catalogId,
string conversationUid,
string message,
long? topK = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::G.ChatBody
{
CatalogId = catalogId,
ConversationUid = conversationUid,
Message = message,
TopK = topK,
};

return await AppPublicServiceChatAsync(
namespaceId: namespaceId,
appId: appId,
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Loading

0 comments on commit 873bcac

Please sign in to comment.