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:Add API endpoint to populate annotation queue and update RunRulesSchema #157

Merged
merged 1 commit into from
Dec 13, 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
456 changes: 230 additions & 226 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
Expand Up @@ -205,6 +205,7 @@ partial void ProcessCreateAnnotationQueueResponseContent(
/// <param name="id"></param>
/// <param name="rubricItems"></param>
/// <param name="rubricInstructions"></param>
/// <param name="sessionIds"></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.AnnotationQueueSchema> CreateAnnotationQueueAsync(
Expand All @@ -219,6 +220,7 @@ partial void ProcessCreateAnnotationQueueResponseContent(
global::System.Guid? id = default,
global::System.Collections.Generic.IList<global::LangSmith.AnnotationQueueRubricItemSchema>? rubricItems = default,
string? rubricInstructions = default,
global::System.Collections.Generic.IList<global::System.Guid>? sessionIds = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::LangSmith.AnnotationQueueCreateSchema
Expand All @@ -234,6 +236,7 @@ partial void ProcessCreateAnnotationQueueResponseContent(
Id = id,
RubricItems = rubricItems,
RubricInstructions = rubricInstructions,
SessionIds = sessionIds,
};

return await CreateAnnotationQueueAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@

#nullable enable

namespace LangSmith
{
public partial class AnnotationQueuesClient
{
partial void PreparePopulateAnnotationQueueArguments(
global::System.Net.Http.HttpClient httpClient,
global::LangSmith.PopulateAnnotationQueueSchema request);
partial void PreparePopulateAnnotationQueueRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::LangSmith.PopulateAnnotationQueueSchema request);
partial void ProcessPopulateAnnotationQueueResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

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

/// <summary>
/// Populate Annotation Queue<br/>
/// Populate annotation queue with runs from an experiment.
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::LangSmith.ApiException"></exception>
public async global::System.Threading.Tasks.Task<string> PopulateAnnotationQueueAsync(
global::LangSmith.PopulateAnnotationQueueSchema request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: HttpClient);
PreparePopulateAnnotationQueueArguments(
httpClient: HttpClient,
request: request);

var __pathBuilder = new PathBuilder(
path: "/api/v1/annotation-queues/populate",
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));
#if NET6_0_OR_GREATER
__httpRequest.Version = global::System.Net.HttpVersion.Version11;
__httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif

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);
PreparePopulateAnnotationQueueRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
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);
ProcessPopulateAnnotationQueueResponse(
httpClient: HttpClient,
httpResponseMessage: __response);
// Validation Error
if ((int)__response.StatusCode == 422)
{
string? __content_422 = null;
global::LangSmith.HTTPValidationError? __value_422 = null;
if (ReadResponseAsString)
{
__content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
__value_422 = global::LangSmith.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
}
else
{
var __contentStream_422 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
__value_422 = await global::LangSmith.HTTPValidationError.FromJsonStreamAsync(__contentStream_422, JsonSerializerContext).ConfigureAwait(false);
}

throw new global::LangSmith.ApiException<global::LangSmith.HTTPValidationError>(
message: __response.ReasonPhrase ?? string.Empty,
statusCode: __response.StatusCode)
{
ResponseBody = __content_422,
ResponseObject = __value_422,
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);
ProcessPopulateAnnotationQueueResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response,
content: ref __content);

try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::LangSmith.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 __content;
}
else
{
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::LangSmith.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),
};
}

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

return __content;
}
}

/// <summary>
/// Populate Annotation Queue<br/>
/// Populate annotation queue with runs from an experiment.
/// </summary>
/// <param name="queueId"></param>
/// <param name="sessionIds"></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<string> PopulateAnnotationQueueAsync(
global::System.Guid queueId,
global::System.Collections.Generic.IList<global::System.Guid> sessionIds,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::LangSmith.PopulateAnnotationQueueSchema
{
QueueId = queueId,
SessionIds = sessionIds,
};

return await PopulateAnnotationQueueAsync(
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public partial interface IAnnotationQueuesClient
/// <param name="id"></param>
/// <param name="rubricItems"></param>
/// <param name="rubricInstructions"></param>
/// <param name="sessionIds"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::LangSmith.AnnotationQueueSchema> CreateAnnotationQueueAsync(
Expand All @@ -48,6 +49,7 @@ public partial interface IAnnotationQueuesClient
global::System.Guid? id = default,
global::System.Collections.Generic.IList<global::LangSmith.AnnotationQueueRubricItemSchema>? rubricItems = default,
string? rubricInstructions = default,
global::System.Collections.Generic.IList<global::System.Guid>? sessionIds = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#nullable enable

namespace LangSmith
{
public partial interface IAnnotationQueuesClient
{
/// <summary>
/// Populate Annotation Queue<br/>
/// Populate annotation queue with runs from an experiment.
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::LangSmith.ApiException"></exception>
global::System.Threading.Tasks.Task<string> PopulateAnnotationQueueAsync(
global::LangSmith.PopulateAnnotationQueueSchema request,
global::System.Threading.CancellationToken cancellationToken = default);

/// <summary>
/// Populate Annotation Queue<br/>
/// Populate annotation queue with runs from an experiment.
/// </summary>
/// <param name="queueId"></param>
/// <param name="sessionIds"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<string> PopulateAnnotationQueueAsync(
global::System.Guid queueId,
global::System.Collections.Generic.IList<global::System.Guid> sessionIds,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public partial interface IRunClient
/// <param name="extendOnly">
/// Default Value: false
/// </param>
/// <param name="transient">
/// Default Value: false
/// </param>
/// <param name="addToAnnotationQueueId"></param>
/// <param name="addToDatasetId"></param>
/// <param name="addToDatasetPreferCorrection">
Expand All @@ -61,6 +64,7 @@ public partial interface IRunClient
bool? useCorrectionsDataset = default,
int? numFewShotExamples = default,
bool? extendOnly = default,
bool? transient = default,
global::System.Guid? addToAnnotationQueueId = default,
global::System.Guid? addToDatasetId = default,
bool? addToDatasetPreferCorrection = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public partial interface IRunClient
/// <param name="sessionId"></param>
/// <param name="type"></param>
/// <param name="nameContains"></param>
/// <param name="id"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::LangSmith.ApiException"></exception>
global::System.Threading.Tasks.Task<global::System.Collections.Generic.IList<global::LangSmith.RunRulesSchema>> ListRulesAsync(
global::System.Guid? datasetId = default,
global::System.Guid? sessionId = default,
global::LangSmith.ListRulesApiV1RunsRulesGetType? type = default,
string? nameContains = default,
global::System.Collections.Generic.IList<global::System.Guid>? id = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public partial interface IRunClient
/// <param name="extendOnly">
/// Default Value: false
/// </param>
/// <param name="transient">
/// Default Value: false
/// </param>
/// <param name="addToAnnotationQueueId"></param>
/// <param name="addToDatasetId"></param>
/// <param name="addToDatasetPreferCorrection">
Expand All @@ -65,6 +68,7 @@ public partial interface IRunClient
bool? useCorrectionsDataset = default,
int? numFewShotExamples = default,
bool? extendOnly = default,
bool? transient = default,
global::System.Guid? addToAnnotationQueueId = default,
global::System.Guid? addToDatasetId = default,
bool? addToDatasetPreferCorrection = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public sealed partial class AnnotationQueueCreateSchema
[global::System.Text.Json.Serialization.JsonPropertyName("rubric_instructions")]
public string? RubricInstructions { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("session_ids")]
public global::System.Collections.Generic.IList<global::System.Guid>? SessionIds { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand All @@ -101,6 +107,7 @@ public sealed partial class AnnotationQueueCreateSchema
/// <param name="id"></param>
/// <param name="rubricItems"></param>
/// <param name="rubricInstructions"></param>
/// <param name="sessionIds"></param>
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
public AnnotationQueueCreateSchema(
string name,
Expand All @@ -113,7 +120,8 @@ public AnnotationQueueCreateSchema(
int? reservationMinutes,
global::System.Guid? id,
global::System.Collections.Generic.IList<global::LangSmith.AnnotationQueueRubricItemSchema>? rubricItems,
string? rubricInstructions)
string? rubricInstructions,
global::System.Collections.Generic.IList<global::System.Guid>? sessionIds)
{
this.Name = name ?? throw new global::System.ArgumentNullException(nameof(name));
this.Description = description;
Expand All @@ -126,6 +134,7 @@ public AnnotationQueueCreateSchema(
this.Id = id;
this.RubricItems = rubricItems;
this.RubricInstructions = rubricInstructions;
this.SessionIds = sessionIds;
}

/// <summary>
Expand Down
Loading
Loading