Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Enhance LangSmith library with improvements to ChartsClient and API handling #26

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,336 changes: 674 additions & 662 deletions src/libs/LangSmith/Generated/JsonSerializerContextTypes.g.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

#nullable enable

namespace LangSmith
{
public partial class ChartsClient
{
partial void PrepareReadSectionsApiV1ChartsSectionGetArguments(
global::System.Net.Http.HttpClient httpClient,
ref int limit,
ref int offset,
ref global::System.AnyOf<string?, object>? titleContains);
partial void PrepareReadSectionsApiV1ChartsSectionGetRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
int limit,
int offset,
global::System.AnyOf<string?, object>? titleContains);
partial void ProcessReadSectionsApiV1ChartsSectionGetResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

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

/// <summary>
/// Read Sections<br/>
/// Get all sections for the tenant.
/// </summary>
/// <param name="limit">
/// Default Value: 100
/// </param>
/// <param name="offset">
/// Default Value: 0
/// </param>
/// <param name="titleContains"></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::System.Collections.Generic.IList<global::LangSmith.CustomChartsSectionResponse>> ReadSectionsApiV1ChartsSectionGetAsync(
int limit,
int offset,
global::System.AnyOf<string?, object>? titleContains,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareReadSectionsApiV1ChartsSectionGetArguments(
httpClient: _httpClient,
limit: ref limit,
offset: ref offset,
titleContains: ref titleContains);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Get,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/api/v1/charts/section?limit={limit}&offset={offset}&title_contains={titleContains}", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareReadSectionsApiV1ChartsSectionGetRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
limit: limit,
offset: offset,
titleContains: titleContains);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessReadSectionsApiV1ChartsSectionGetResponse(
httpClient: _httpClient,
httpResponseMessage: response);

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

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessReadSectionsApiV1ChartsSectionGetResponseContent(
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::System.Text.Json.JsonSerializer.Deserialize(__content, global::LangSmith.SourceGenerationContext.Default.IListCustomChartsSectionResponse) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,39 +99,44 @@ partial void ProcessCreateExampleApiV1ExamplesPostResponseContent(
/// Create Example<br/>
/// Create a new example.
/// </summary>
/// <param name="inputs"></param>
/// <param name="outputs"></param>
/// <param name="datasetId"></param>
/// <param name="sourceRunId"></param>
/// <param name="metadata"></param>
/// <param name="createdAt"></param>
/// <param name="id"></param>
/// <param name="inputs"></param>
/// <param name="split">
/// Default Value: base
/// </param>
/// <param name="id"></param>
/// <param name="useSourceRunIo">
/// Default Value: false
/// </param>
/// <param name="createdAt"></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::LangSmith.Example> CreateExampleApiV1ExamplesPostAsync(
global::LangSmith.ExampleCreateInputs inputs,
string datasetId,
global::System.AnyOf<global::LangSmith.ExampleCreateOutputs, object>? outputs = default,
global::System.AnyOf<string, object>? sourceRunId = default,
global::System.AnyOf<global::LangSmith.ExampleCreateMetadata, object>? metadata = default,
global::System.DateTime createdAt = default,
global::System.AnyOf<string, object>? id = default,
global::System.AnyOf<global::LangSmith.ExampleCreateInputs, object>? inputs = default,
global::System.AnyOf<global::System.Collections.Generic.IList<string>, string?, object>? split = default,
global::System.AnyOf<string, object>? id = default,
bool useSourceRunIo = false,
global::System.DateTime createdAt = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::LangSmith.ExampleCreate
{
Inputs = inputs,
Outputs = outputs,
DatasetId = datasetId,
SourceRunId = sourceRunId,
Metadata = metadata,
CreatedAt = createdAt,
Id = id,
Inputs = inputs,
Split = split,
Id = id,
UseSourceRunIo = useSourceRunIo,
CreatedAt = createdAt,
};

return await CreateExampleApiV1ExamplesPostAsync(
Expand Down
14 changes: 7 additions & 7 deletions src/libs/LangSmith/Generated/LangSmith.Models.Example.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace LangSmith
/// </summary>
public sealed partial class Example
{
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -45,6 +38,13 @@ public sealed partial class Example
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::LangSmith.ExampleMetadata, object>? Metadata { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace LangSmith
/// </summary>
public sealed partial class ExampleBulkCreate
{
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleBulkCreateInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -48,9 +41,9 @@ public sealed partial class ExampleBulkCreate
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("created_at")]
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::System.DateTime?, object>? CreatedAt { get; set; }
public global::System.AnyOf<global::LangSmith.ExampleBulkCreateInputs, object>? Inputs { get; set; }

/// <summary>
/// Default Value: base
Expand All @@ -66,6 +59,19 @@ public sealed partial class ExampleBulkCreate
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<string, object>? Id { get; set; }

/// <summary>
/// Default Value: false
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("use_source_run_io")]
public bool UseSourceRunIo { get; set; } = false;

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("created_at")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::System.DateTime?, object>? CreatedAt { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand Down
32 changes: 19 additions & 13 deletions src/libs/LangSmith/Generated/LangSmith.Models.ExampleCreate.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace LangSmith
/// </summary>
public sealed partial class ExampleCreate
{
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleCreateInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -48,8 +41,16 @@ public sealed partial class ExampleCreate
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("created_at")]
public global::System.DateTime CreatedAt { get; set; }
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::LangSmith.ExampleCreateInputs, object>? Inputs { get; set; }

/// <summary>
/// Default Value: base
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("split")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory3))]
public global::System.AnyOf<global::System.Collections.Generic.IList<string>, string?, object>? Split { get; set; } = "base";

/// <summary>
///
Expand All @@ -59,11 +60,16 @@ public sealed partial class ExampleCreate
public global::System.AnyOf<string, object>? Id { get; set; }

/// <summary>
/// Default Value: base
/// Default Value: false
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("split")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory3))]
public global::System.AnyOf<global::System.Collections.Generic.IList<string>, string?, object>? Split { get; set; } = "base";
[global::System.Text.Json.Serialization.JsonPropertyName("use_source_run_io")]
public bool UseSourceRunIo { get; set; } = false;

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("created_at")]
public global::System.DateTime CreatedAt { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace LangSmith
/// </summary>
public sealed partial class ExampleWithRuns
{
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleWithRunsInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -45,6 +38,13 @@ public sealed partial class ExampleWithRuns
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::LangSmith.ExampleWithRunsMetadata, object>? Metadata { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleWithRunsInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace LangSmith
/// </summary>
public sealed partial class ExampleWithRunsCH
{
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleWithRunsCHInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -45,6 +38,13 @@ public sealed partial class ExampleWithRunsCH
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::LangSmith.ExampleWithRunsCHMetadata, object>? Metadata { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.ExampleWithRunsCHInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace LangSmith
/// </summary>
public sealed partial class PublicExampleWithRuns
{
/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.PublicExampleWithRunsInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -45,6 +38,13 @@ public sealed partial class PublicExampleWithRuns
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2))]
public global::System.AnyOf<global::LangSmith.PublicExampleWithRunsMetadata, object>? Metadata { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("inputs")]
[global::System.Text.Json.Serialization.JsonRequired]
public required global::LangSmith.PublicExampleWithRunsInputs Inputs { get; set; }

/// <summary>
///
/// </summary>
Expand Down
Loading
Loading