From 6dce52f14e6f3faf0413278fbdeaa75c0dc9e34e Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 5 Jan 2025 21:40:08 +0100 Subject: [PATCH] Added ERI server v1 client --- app/ERIClientV1/Client.Generated.cs | 1281 +++++++++++++++++ app/ERIClientV1/ERIClientV1.csproj | 10 + app/MindWork AI Studio.sln | 11 + .../MindWork AI Studio.csproj | 4 + app/MindWork AI Studio/packages.lock.json | 3 + 5 files changed, 1309 insertions(+) create mode 100644 app/ERIClientV1/Client.Generated.cs create mode 100644 app/ERIClientV1/ERIClientV1.csproj diff --git a/app/ERIClientV1/Client.Generated.cs b/app/ERIClientV1/Client.Generated.cs new file mode 100644 index 00000000..d090ebac --- /dev/null +++ b/app/ERIClientV1/Client.Generated.cs @@ -0,0 +1,1281 @@ +//---------------------- +// +// Generated using the NSwag toolchain v14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) +// +//---------------------- + +#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." +#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." +#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' +#pragma warning disable 612 // Disable "CS0612 '...' is obsolete" +#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... +#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." +#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" +#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" +#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" +#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter" +#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type" + +namespace ERI_Client.V1 +{ + using System = global::System; + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class Client + { + #pragma warning disable 8618 + private string _baseUrl; + #pragma warning restore 8618 + + private System.Net.Http.HttpClient _httpClient; + private static System.Lazy _settings = new System.Lazy(CreateSerializerSettings, true); + + public Client(System.Net.Http.HttpClient httpClient) + { + _httpClient = httpClient; + } + + private static System.Text.Json.JsonSerializerOptions CreateSerializerSettings() + { + var settings = new System.Text.Json.JsonSerializerOptions(); + UpdateJsonSerializerSettings(settings); + return settings; + } + + protected System.Text.Json.JsonSerializerOptions JsonSerializerSettings { get { return _settings.Value; } } + + static partial void UpdateJsonSerializerSettings(System.Text.Json.JsonSerializerOptions settings); + + partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); + partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); + partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); + + /// + /// Get the available authentication methods. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task> GetAuthMethodsAsync() + { + return GetAuthMethodsAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get the available authentication methods. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task> GetAuthMethodsAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "auth/methods" + urlBuilder_.Append("auth/methods"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Authenticate with the data source to get a token for further requests. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task AuthenticateAsync(AuthMethod authMethod) + { + return AuthenticateAsync(authMethod, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Authenticate with the data source to get a token for further requests. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task AuthenticateAsync(AuthMethod authMethod, System.Threading.CancellationToken cancellationToken) + { + if (authMethod == null) + throw new System.ArgumentNullException("authMethod"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); + request_.Method = new System.Net.Http.HttpMethod("POST"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "auth" + urlBuilder_.Append("auth"); + urlBuilder_.Append('?'); + urlBuilder_.Append(System.Uri.EscapeDataString("authMethod")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(authMethod, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Length--; + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Get information about the data source. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetDataSourceInfoAsync() + { + return GetDataSourceInfoAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get information about the data source. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetDataSourceInfoAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "dataSource" + urlBuilder_.Append("dataSource"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Get information about the used embedding(s). + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task> GetEmbeddingInfoAsync() + { + return GetEmbeddingInfoAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get information about the used embedding(s). + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task> GetEmbeddingInfoAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "embedding/info" + urlBuilder_.Append("embedding/info"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Get information about the retrieval processes implemented by this data source. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task> GetRetrievalInfoAsync() + { + return GetRetrievalInfoAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get information about the retrieval processes implemented by this data source. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task> GetRetrievalInfoAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "retrieval/info" + urlBuilder_.Append("retrieval/info"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Retrieve information from the data source. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task> RetrieveAsync(RetrievalRequest body) + { + return RetrieveAsync(body, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Retrieve information from the data source. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task> RetrieveAsync(RetrievalRequest body, System.Threading.CancellationToken cancellationToken) + { + if (body == null) + throw new System.ArgumentNullException("body"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + var json_ = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(body, _settings.Value); + var content_ = new System.Net.Http.ByteArrayContent(json_); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; + request_.Method = new System.Net.Http.HttpMethod("POST"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "retrieval" + urlBuilder_.Append("retrieval"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Get the security requirements for this data source. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetSecurityRequirementsAsync() + { + return GetSecurityRequirementsAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get the security requirements for this data source. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetSecurityRequirementsAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + + // Operation Path: "security/requirements" + urlBuilder_.Append("security/requirements"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + protected struct ObjectResponseResult + { + public ObjectResponseResult(T responseObject, string responseText) + { + this.Object = responseObject; + this.Text = responseText; + } + + public T Object { get; } + + public string Text { get; } + } + + public bool ReadResponseAsString { get; set; } + + protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) + { + if (response == null || response.Content == null) + { + return new ObjectResponseResult(default(T), string.Empty); + } + + if (ReadResponseAsString) + { + var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + var typedBody = System.Text.Json.JsonSerializer.Deserialize(responseText, JsonSerializerSettings); + return new ObjectResponseResult(typedBody, responseText); + } + catch (System.Text.Json.JsonException exception) + { + var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; + throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); + } + } + else + { + try + { + using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) + { + var typedBody = await System.Text.Json.JsonSerializer.DeserializeAsync(responseStream, JsonSerializerSettings, cancellationToken).ConfigureAwait(false); + return new ObjectResponseResult(typedBody, string.Empty); + } + } + catch (System.Text.Json.JsonException exception) + { + var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; + throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); + } + } + } + + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) + { + if (value == null) + { + return ""; + } + + if (value is System.Enum) + { + var name = System.Enum.GetName(value.GetType(), value); + if (name != null) + { + var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); + if (field != null) + { + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + as System.Runtime.Serialization.EnumMemberAttribute; + if (attribute != null) + { + return attribute.Value != null ? attribute.Value : name; + } + } + + var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); + return converted == null ? string.Empty : converted; + } + } + else if (value is bool) + { + return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); + } + else if (value is byte[]) + { + return System.Convert.ToBase64String((byte[]) value); + } + else if (value is string[]) + { + return string.Join(",", (string[])value); + } + else if (value.GetType().IsArray) + { + var valueArray = (System.Array)value; + var valueTextArray = new string[valueArray.Length]; + for (var i = 0; i < valueArray.Length; i++) + { + valueTextArray[i] = ConvertToString(valueArray.GetValue(i), cultureInfo); + } + return string.Join(",", valueTextArray); + } + + var result = System.Convert.ToString(value, cultureInfo); + return result == null ? "" : result; + } + } + + /// + /// An authentication field. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public enum AuthField + { + + [System.Runtime.Serialization.EnumMember(Value = @"NONE")] + NONE = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"USERNAME")] + USERNAME = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"PASSWORD")] + PASSWORD = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"TOKEN")] + TOKEN = 3, + + [System.Runtime.Serialization.EnumMember(Value = @"KERBEROS_TICKET")] + KERBEROS_TICKET = 4, + + } + + /// + /// The mapping between an AuthField and the field name in the authentication request. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class AuthFieldMapping + { + + [System.Text.Json.Serialization.JsonPropertyName("authField")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public AuthField AuthField { get; set; } + + /// + /// The field name in the authentication request. + /// + + [System.Text.Json.Serialization.JsonPropertyName("fieldName")] + public string FieldName { get; set; } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public enum AuthMethod + { + + [System.Runtime.Serialization.EnumMember(Value = @"NONE")] + NONE = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"KERBEROS")] + KERBEROS = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"USERNAME_PASSWORD")] + USERNAME_PASSWORD = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"TOKEN")] + TOKEN = 3, + + } + + /// + /// The response to an authentication request. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class AuthResponse + { + /// + /// True, when the authentication was successful. + /// + + [System.Text.Json.Serialization.JsonPropertyName("success")] + public bool Success { get; set; } + + /// + /// The token to use for further requests. + /// + + [System.Text.Json.Serialization.JsonPropertyName("token")] + public string Token { get; set; } + + /// + /// When the authentication was not successful, this contains the reason. + /// + + [System.Text.Json.Serialization.JsonPropertyName("message")] + public string Message { get; set; } + + } + + /// + /// Describes one authentication scheme for this data source. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class AuthScheme + { + + [System.Text.Json.Serialization.JsonPropertyName("authMethod")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public AuthMethod AuthMethod { get; set; } + + /// + /// A list of field mappings for the authentication method. The client must know, + ///
e.g., how the password field is named in the request. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("authFieldMappings")] + public System.Collections.Generic.ICollection AuthFieldMappings { get; set; } + + } + + /// + /// A chat thread, which is a list of content blocks. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ChatThread + { + /// + /// The content blocks in this chat thread. + /// + + [System.Text.Json.Serialization.JsonPropertyName("contentBlocks")] + public System.Collections.Generic.ICollection ContentBlocks { get; set; } + + } + + /// + /// A block of content of a chat thread. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ContentBlock + { + /// + /// The content of the block. Remember that images and other media are base64 encoded. + /// + + [System.Text.Json.Serialization.JsonPropertyName("content")] + public string Content { get; set; } + + [System.Text.Json.Serialization.JsonPropertyName("role")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public Role Role { get; set; } + + [System.Text.Json.Serialization.JsonPropertyName("type")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ContentType Type { get; set; } + + } + + /// + /// The type of content. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public enum ContentType + { + + [System.Runtime.Serialization.EnumMember(Value = @"NONE")] + NONE = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"UNKNOWN")] + UNKNOWN = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"TEXT")] + TEXT = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"IMAGE")] + IMAGE = 3, + + [System.Runtime.Serialization.EnumMember(Value = @"VIDEO")] + VIDEO = 4, + + [System.Runtime.Serialization.EnumMember(Value = @"AUDIO")] + AUDIO = 5, + + [System.Runtime.Serialization.EnumMember(Value = @"SPEECH")] + SPEECH = 6, + + } + + /// + /// Matching context returned by the data source as a result of a retrieval request. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class Context + { + /// + /// The name of the source, e.g., a document name, database name, + ///
collection name, etc. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// What are the contents of the source? For example, is it a + ///
dictionary, a book chapter, business concept, a paper, etc. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("category")] + public string Category { get; set; } + + /// + /// The path to the content, e.g., a URL, a file path, a path in a + ///
graph database, etc. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("path")] + public string Path { get; set; } + + [System.Text.Json.Serialization.JsonPropertyName("type")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ContentType Type { get; set; } + + /// + /// The content that matched the user prompt. For text, you + ///
return the matched text and, e.g., three words before and after it. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("matchedContent")] + public string MatchedContent { get; set; } + + /// + /// The surrounding content of the matched content. + ///
For text, you may return, e.g., one sentence or paragraph before and after + ///
the matched content. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("surroundingContent")] + public System.Collections.Generic.ICollection SurroundingContent { get; set; } + + /// + /// Links to related content, e.g., links to Wikipedia articles, + ///
links to sources, etc. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("links")] + public System.Collections.Generic.ICollection Links { get; set; } + + } + + /// + /// Information about the data source. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class DataSourceInfo + { + /// + /// The name of the data source, e.g., "Internal Organization Documents." + /// + + [System.Text.Json.Serialization.JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// A short description of the data source. What kind of data does it contain? + ///
What is the data source used for? + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("description")] + public string Description { get; set; } + + } + + /// + /// Represents information about the used embedding for this data source. The purpose of this information is to give the + ///
interested user an idea of what kind of embedding is used and what it does. + ///
+ [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class EmbeddingInfo + { + /// + /// What kind of embedding is used. For example, "Transformer Embedding," "Contextual Word + ///
Embedding," "Graph Embedding," etc. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("embeddingType")] + public string EmbeddingType { get; set; } + + /// + /// Name the embedding used. This can be a library, a framework, or the name of the used + ///
algorithm. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("embeddingName")] + public string EmbeddingName { get; set; } + + /// + /// A short description of the embedding. Describe what the embedding is doing. + /// + + [System.Text.Json.Serialization.JsonPropertyName("description")] + public string Description { get; set; } + + /// + /// Describe when the embedding is used. For example, when the user prompt contains certain + ///
keywords, or anytime? + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("usedWhen")] + public string UsedWhen { get; set; } + + /// + /// A link to the embedding's documentation or the source code. Might be null. + /// + + [System.Text.Json.Serialization.JsonPropertyName("link")] + public string Link { get; set; } + + } + + /// + /// Known types of providers that can process data. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public enum ProviderType + { + + [System.Runtime.Serialization.EnumMember(Value = @"NONE")] + NONE = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"ANY")] + ANY = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"SELF_HOSTED")] + SELF_HOSTED = 2, + + } + + /// + /// Information about a retrieval process, which this data source implements. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class RetrievalInfo + { + /// + /// A unique identifier for the retrieval process. This can be a GUID, a unique name, or an increasing integer. + /// + + [System.Text.Json.Serialization.JsonPropertyName("id")] + public string Id { get; set; } + + /// + /// The name of the retrieval process, e.g., "Keyword-Based Wikipedia Article Retrieval". + /// + + [System.Text.Json.Serialization.JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// A short description of the retrieval process. What kind of retrieval process is it? + /// + + [System.Text.Json.Serialization.JsonPropertyName("description")] + public string Description { get; set; } + + /// + /// A link to the retrieval process's documentation, paper, Wikipedia article, or the source code. Might be null. + /// + + [System.Text.Json.Serialization.JsonPropertyName("link")] + public string Link { get; set; } + + /// + /// A dictionary that describes the parameters of the retrieval process. The key is the parameter name, + ///
and the value is a description of the parameter. Although each parameter will be sent as a string, the description should indicate the + ///
expected type and range, e.g., 0.0 to 1.0 for a float parameter. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("parametersDescription")] + public System.Collections.Generic.IDictionary ParametersDescription { get; set; } + + /// + /// A list of embeddings used in this retrieval process. It might be empty in case no embedding is used. + /// + + [System.Text.Json.Serialization.JsonPropertyName("embeddings")] + public System.Collections.Generic.ICollection Embeddings { get; set; } + + } + + /// + /// The retrieval request sent by AI Studio. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class RetrievalRequest + { + /// + /// The latest user prompt that AI Studio received. + /// + + [System.Text.Json.Serialization.JsonPropertyName("latestUserPrompt")] + public string LatestUserPrompt { get; set; } + + [System.Text.Json.Serialization.JsonPropertyName("latestUserPromptType")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ContentType LatestUserPromptType { get; set; } + + [System.Text.Json.Serialization.JsonPropertyName("thread")] + public ChatThread Thread { get; set; } + + /// + /// Optional. The ID of the retrieval process that the data source should use. + ///
When null, the data source chooses an appropriate retrieval process. Selecting a retrieval process is optional + ///
for AI Studio users. Most users do not specify a retrieval process. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("retrievalProcessId")] + public string RetrievalProcessId { get; set; } + + /// + /// A dictionary of parameters that the data source should use for the retrieval process. + ///
Although each parameter will be sent as a string, the retrieval process specifies the expected type and range. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("parameters")] + public System.Collections.Generic.IDictionary Parameters { get; set; } + + /// + /// The maximum number of matches that the data source should return. AI Studio uses + ///
any value below 1 to indicate that the data source should return as many matches as appropriate. + ///
+ + [System.Text.Json.Serialization.JsonPropertyName("maxMatches")] + public int MaxMatches { get; set; } + + } + + /// + /// Possible roles of any chat thread. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public enum Role + { + + [System.Runtime.Serialization.EnumMember(Value = @"NONE")] + NONE = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"UNKNOW")] + UNKNOW = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"SYSTEM")] + SYSTEM = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"USER")] + USER = 3, + + [System.Runtime.Serialization.EnumMember(Value = @"AI")] + AI = 4, + + [System.Runtime.Serialization.EnumMember(Value = @"AGENT")] + AGENT = 5, + + } + + /// + /// Represents the security requirements for this data source. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class SecurityRequirements + { + + [System.Text.Json.Serialization.JsonPropertyName("allowedProviderType")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ProviderType AllowedProviderType { get; set; } + + } + + + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ApiException : System.Exception + { + public int StatusCode { get; private set; } + + public string Response { get; private set; } + + public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } + + public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) + { + StatusCode = statusCode; + Response = response; + Headers = headers; + } + + public override string ToString() + { + return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); + } + } + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ApiException : ApiException + { + public TResult Result { get; private set; } + + public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) + : base(message, statusCode, response, headers, innerException) + { + Result = result; + } + } + +} + +#pragma warning restore 108 +#pragma warning restore 114 +#pragma warning restore 472 +#pragma warning restore 612 +#pragma warning restore 1573 +#pragma warning restore 1591 +#pragma warning restore 8073 +#pragma warning restore 3016 +#pragma warning restore 8603 +#pragma warning restore 8604 +#pragma warning restore 8625 \ No newline at end of file diff --git a/app/ERIClientV1/ERIClientV1.csproj b/app/ERIClientV1/ERIClientV1.csproj new file mode 100644 index 00000000..8ca0662e --- /dev/null +++ b/app/ERIClientV1/ERIClientV1.csproj @@ -0,0 +1,10 @@ + + + + net8.0 + latest + enable + enable + + + diff --git a/app/MindWork AI Studio.sln b/app/MindWork AI Studio.sln index 696edae2..6bf20b24 100644 --- a/app/MindWork AI Studio.sln +++ b/app/MindWork AI Studio.sln @@ -2,6 +2,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MindWork AI Studio", "MindWork AI Studio\MindWork AI Studio.csproj", "{059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ERIClients", "ERIClients", "{5C2AF789-287B-4FCB-B675-7273D8CD4579}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ERIClientV1", "ERIClientV1\ERIClientV1.csproj", "{9E35A273-0FA6-4BD5-8880-A1DDAC106926}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +16,12 @@ Global {059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}.Debug|Any CPU.Build.0 = Debug|Any CPU {059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}.Release|Any CPU.ActiveCfg = Release|Any CPU {059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}.Release|Any CPU.Build.0 = Release|Any CPU + {9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {9E35A273-0FA6-4BD5-8880-A1DDAC106926} = {5C2AF789-287B-4FCB-B675-7273D8CD4579} EndGlobalSection EndGlobal diff --git a/app/MindWork AI Studio/MindWork AI Studio.csproj b/app/MindWork AI Studio/MindWork AI Studio.csproj index 0d6fc288..ccc96dff 100644 --- a/app/MindWork AI Studio/MindWork AI Studio.csproj +++ b/app/MindWork AI Studio/MindWork AI Studio.csproj @@ -53,6 +53,10 @@ + + + + diff --git a/app/MindWork AI Studio/packages.lock.json b/app/MindWork AI Studio/packages.lock.json index 8ad3bbb5..d1c6dae4 100644 --- a/app/MindWork AI Studio/packages.lock.json +++ b/app/MindWork AI Studio/packages.lock.json @@ -205,6 +205,9 @@ "type": "Transitive", "resolved": "0.16.9", "contentHash": "7WaVMHklpT3Ye2ragqRIwlFRsb6kOk63BOGADV0fan3ulVfGLUYkDi5yNUsZS/7FVNkWbtHAlDLmu4WnHGfqvQ==" + }, + "ericlientv1": { + "type": "Project" } }, "net8.0/osx-arm64": {}