Skip to content

Commit

Permalink
Merge pull request #53 from tryAGI/bot/update-openapi_202411251822
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 25, 2024
2 parents f27c875 + 2d425d2 commit a6d5cb7
Show file tree
Hide file tree
Showing 55 changed files with 3,902 additions and 843 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ partial void PrepareAppPublicServiceChatArguments(
global::System.Net.Http.HttpClient httpClient,
ref string namespaceId,
ref string appId,
global::Instill.ChatBody request);
global::Instill.AppPublicServiceChatBody request);
partial void PrepareAppPublicServiceChatRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string namespaceId,
string appId,
global::Instill.ChatBody request);
global::Instill.AppPublicServiceChatBody request);
partial void ProcessAppPublicServiceChatResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
Expand All @@ -40,7 +40,7 @@ partial void ProcessAppPublicServiceChatResponseContent(
public async global::System.Threading.Tasks.Task<global::Instill.ChatResponse> AppPublicServiceChatAsync(
string namespaceId,
string appId,
global::Instill.ChatBody request,
global::Instill.AppPublicServiceChatBody request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -253,7 +253,7 @@ partial void ProcessAppPublicServiceChatResponseContent(
string? userInstruction = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Instill.ChatBody
var __request = new global::Instill.AppPublicServiceChatBody
{
CatalogId = catalogId,
ConversationUid = conversationUid,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@

#nullable enable

namespace Instill
{
public partial class AppClient
{
partial void PrepareAppPublicServiceCreateChatArguments(
global::System.Net.Http.HttpClient httpClient,
ref string namespaceId,
global::Instill.CreateChatBody request);
partial void PrepareAppPublicServiceCreateChatRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string namespaceId,
global::Instill.CreateChatBody request);
partial void ProcessAppPublicServiceCreateChatResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

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

/// <summary>
/// Create a chat<br/>
/// Creates a chat.
/// </summary>
/// <param name="namespaceId"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Instill.ApiException"></exception>
[global::System.Diagnostics.CodeAnalysis.Experimental(diagnosticId: "INSTILL_ALPHA_001")]
public async global::System.Threading.Tasks.Task<global::Instill.CreateChatResponse> AppPublicServiceCreateChatAsync(
string namespaceId,
global::Instill.CreateChatBody request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

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

var __pathBuilder = new PathBuilder(
path: $"/v1alpha/namespaces/{namespaceId}/chats",
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(JsonSerializerContext);
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);
PrepareAppPublicServiceCreateChatRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
namespaceId: namespaceId,
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);
ProcessAppPublicServiceCreateChatResponse(
httpClient: HttpClient,
httpResponseMessage: __response);
// Returned when the client credentials are not valid.
if ((int)__response.StatusCode == 401)
{
string? __content_401 = null;
string? __value_401 = null;
if (ReadResponseAsString)
{
__content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
__value_401 = global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext) as string;
}
else
{
var __contentStream_401 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_401 = await global::System.Text.Json.JsonSerializer.DeserializeAsync(__contentStream_401, typeof(string), JsonSerializerContext).ConfigureAwait(false) as string;
}

throw new global::Instill.ApiException<string>(
message: __response.ReasonPhrase ?? string.Empty,
statusCode: __response.StatusCode)
{
ResponseBody = __content_401,
ResponseObject = __value_401,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
// An unexpected error response.
if (!__response.IsSuccessStatusCode)
{
string? __content_default = null;
global::Instill.RpcStatus? __value_default = null;
if (ReadResponseAsString)
{
__content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
__value_default = global::Instill.RpcStatus.FromJson(__content_default, JsonSerializerContext);
}
else
{
var __contentStream_default = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_default = await global::Instill.RpcStatus.FromJsonStreamAsync(__contentStream_default, JsonSerializerContext).ConfigureAwait(false);
}

throw new global::Instill.ApiException<global::Instill.RpcStatus>(
message: __response.ReasonPhrase ?? string.Empty,
statusCode: __response.StatusCode)
{
ResponseBody = __content_default,
ResponseObject = __value_default,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}

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

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

try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Instill.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::Instill.CreateChatResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
else
{
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Instill.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 __content = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);

return
await global::Instill.CreateChatResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
}

/// <summary>
/// Create a chat<br/>
/// Creates a chat.
/// </summary>
/// <param name="namespaceId"></param>
/// <param name="chatDisplayName"></param>
/// <param name="aiAgentApp"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
[global::System.Diagnostics.CodeAnalysis.Experimental(diagnosticId: "INSTILL_ALPHA_001")]
public async global::System.Threading.Tasks.Task<global::Instill.CreateChatResponse> AppPublicServiceCreateChatAsync(
string namespaceId,
string? chatDisplayName = default,
global::Instill.AIAgentAppMetadata? aiAgentApp = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Instill.CreateChatBody
{
ChatDisplayName = chatDisplayName,
AiAgentApp = aiAgentApp,
};

return await AppPublicServiceCreateChatAsync(
namespaceId: namespaceId,
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,27 +230,18 @@ partial void ProcessAppPublicServiceCreateConversationResponseContent(
/// <param name="namespaceId"></param>
/// <param name="appId"></param>
/// <param name="conversationId"></param>
/// <param name="chatWith"></param>
/// <param name="conversationDisplayName"></param>
/// <param name="aiAgentApp"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
[global::System.Diagnostics.CodeAnalysis.Experimental(diagnosticId: "INSTILL_ALPHA_001")]
public async global::System.Threading.Tasks.Task<global::Instill.CreateConversationResponse> AppPublicServiceCreateConversationAsync(
string namespaceId,
string appId,
string conversationId,
global::Instill.ChatWith? chatWith = default,
string? conversationDisplayName = default,
global::Instill.AIAgentAppMetadata? aiAgentApp = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Instill.CreateConversationBody
{
ConversationId = conversationId,
ChatWith = chatWith,
ConversationDisplayName = conversationDisplayName,
AiAgentApp = aiAgentApp,
};

return await AppPublicServiceCreateConversationAsync(
Expand Down
Loading

0 comments on commit a6d5cb7

Please sign in to comment.