Skip to content
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
12 changes: 10 additions & 2 deletions api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ public class ChatClient {
[Experimental("OPENAI001")]
public virtual Task<ClientResult<ChatCompletion>> GetChatCompletionAsync(string completionId, CancellationToken cancellationToken = default);
[Experimental("OPENAI001")]
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionMessageCollectionOptions options = null, CancellationToken cancellationToken = default);
[Experimental("OPENAI001")]
public virtual CollectionResult GetChatCompletionMessages(string completionId, string after, int? limit, string order, RequestOptions options);
[Experimental("OPENAI001")]
Expand Down Expand Up @@ -4704,6 +4704,10 @@ public class OpenAIResponseClient {
public virtual ClientResult<ResponseDeletionResult> DeleteResponse(string responseId, CancellationToken cancellationToken = default);
public virtual Task<ClientResult> DeleteResponseAsync(string responseId, RequestOptions options);
public virtual Task<ClientResult<ResponseDeletionResult>> DeleteResponseAsync(string responseId, CancellationToken cancellationToken = default);
public virtual CollectionResult<ResponseItem> GetInputItems(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual CollectionResult GetInputItems(string responseId, int? limit, string order, string after, string before, RequestOptions options);
public virtual AsyncCollectionResult<ResponseItem> GetInputItemsAsync(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual AsyncCollectionResult GetInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options);
public virtual ClientResult GetResponse(string responseId, bool? stream, int? startingAfter, RequestOptions options);
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, CancellationToken cancellationToken = default);
public virtual Task<ClientResult> GetResponseAsync(string responseId, bool? stream, int? startingAfter, RequestOptions options);
Expand Down Expand Up @@ -4951,11 +4955,15 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public class ResponseItemCollectionOptions {
public class ResponseItemCollectionOptions : IJsonModel<ResponseItemCollectionOptions>, IPersistableModel<ResponseItemCollectionOptions> {
public string AfterId { get; set; }
public string BeforeId { get; set; }
public ResponseItemCollectionOrder? Order { get; set; }
public int? PageSizeLimit { get; set; }
protected virtual ResponseItemCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected virtual ResponseItemCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
[Experimental("OPENAI001")]
public readonly partial struct ResponseItemCollectionOrder : IEquatable<ResponseItemCollectionOrder> {
Expand Down
12 changes: 10 additions & 2 deletions api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ public class ChatClient {
public virtual ClientResult<ChatCompletion> GetChatCompletion(string completionId, CancellationToken cancellationToken = default);
public virtual Task<ClientResult> GetChatCompletionAsync(string completionId, RequestOptions options);
public virtual Task<ClientResult<ChatCompletion>> GetChatCompletionAsync(string completionId, CancellationToken cancellationToken = default);
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionMessageCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual CollectionResult GetChatCompletionMessages(string completionId, string after, int? limit, string order, RequestOptions options);
public virtual AsyncCollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessagesAsync(string completionId, ChatCompletionMessageCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual AsyncCollectionResult GetChatCompletionMessagesAsync(string completionId, string after, int? limit, string order, RequestOptions options);
Expand Down Expand Up @@ -4148,6 +4148,10 @@ public class OpenAIResponseClient {
public virtual ClientResult<ResponseDeletionResult> DeleteResponse(string responseId, CancellationToken cancellationToken = default);
public virtual Task<ClientResult> DeleteResponseAsync(string responseId, RequestOptions options);
public virtual Task<ClientResult<ResponseDeletionResult>> DeleteResponseAsync(string responseId, CancellationToken cancellationToken = default);
public virtual CollectionResult<ResponseItem> GetInputItems(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual CollectionResult GetInputItems(string responseId, int? limit, string order, string after, string before, RequestOptions options);
public virtual AsyncCollectionResult<ResponseItem> GetInputItemsAsync(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
public virtual AsyncCollectionResult GetInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options);
public virtual ClientResult GetResponse(string responseId, bool? stream, int? startingAfter, RequestOptions options);
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, CancellationToken cancellationToken = default);
public virtual Task<ClientResult> GetResponseAsync(string responseId, bool? stream, int? startingAfter, RequestOptions options);
Expand Down Expand Up @@ -4373,11 +4377,15 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
protected virtual ResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public class ResponseItemCollectionOptions {
public class ResponseItemCollectionOptions : IJsonModel<ResponseItemCollectionOptions>, IPersistableModel<ResponseItemCollectionOptions> {
public string AfterId { get; set; }
public string BeforeId { get; set; }
public ResponseItemCollectionOrder? Order { get; set; }
public int? PageSizeLimit { get; set; }
protected virtual ResponseItemCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
protected virtual ResponseItemCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
}
public readonly partial struct ResponseItemCollectionOrder : IEquatable<ResponseItemCollectionOrder> {
public ResponseItemCollectionOrder(string value);
Expand Down
12 changes: 10 additions & 2 deletions codegen/generator/src/Visitors/PaginationVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PaginationVisitor : ScmLibraryVisitor
private static readonly Dictionary<string, string> _paramReplacementMap = new()
{
{ "after", "AfterId" },
{ "before", "LastId" },
{ "before", "BeforeId" },
{ "limit", "PageSizeLimit" },
{ "order", "Order" },
{ "model", "Model" },
Expand All @@ -40,11 +40,19 @@ public class PaginationVisitor : ScmLibraryVisitor
},
{
"GetChatCompletionMessages",
("ChatCompletionMessageListDatum", "ChatCompletionCollectionOptions", _chatParamsToReplace)
("ChatCompletionMessageListDatum", "ChatCompletionMessageCollectionOptions", _chatParamsToReplace)
},
{
"GetChatCompletionMessagesAsync",
("ChatCompletionMessageListDatum", "ChatCompletionMessageCollectionOptions", _chatParamsToReplace)
},
{
"GetInputItems",
("ResponseItem", "ResponseItemCollectionOptions", _chatParamsToReplace)
},
{
"GetInputItemsAsync",
("ResponseItem", "ResponseItemCollectionOptions", _chatParamsToReplace)
}
};

Expand Down
4 changes: 2 additions & 2 deletions specification/base/typespec/responses/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ model ResponseItemList {
object: "list";

/** A list of items used to generate this response. */
data: ItemResource[];
@pageItems data: ItemResource[];

/** Whether there are more items available. */
has_more: boolean;
Expand All @@ -1281,7 +1281,7 @@ model ResponseItemList {
first_id: string;

/** The ID of the last item in the list. */
last_id: string;
@continuationToken last_id: string;
}

// Tool customization: Establish discriminated type base
Expand Down
1 change: 1 addition & 0 deletions specification/base/typespec/responses/operations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ interface Responses {
@operationId("listInputItems")
@get
@route("{response_id}/input_items")
@list
listInputItems(
@path
@example("resp_677efb5139a88190b512bc3fef8e535d")
Expand Down
9 changes: 9 additions & 0 deletions specification/client/models/common.models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,13 @@ alias CollectionAfterQueryParameter = {
* subsequent call can include after=obj_foo in order to fetch the next page of the list.
*/
@query @continuationToken afterId?: string;
};

alias CollectionBeforeQueryParameter = {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place in the list.
* For instance, if you make a list request and receive 100 objects, starting with obj_foo, your
* subsequent call can include before=obj_foo in order to fetch the previous page of the list.
*/
@query beforeId?: string;
};
24 changes: 24 additions & 0 deletions specification/client/models/responses.models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "../../base/typespec/responses/main.tsp";
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using TypeSpec.Http;

namespace OpenAI;

Expand All @@ -25,3 +26,26 @@ model DotNetItemReferenceItemResource extends ItemResource {
type: ItemType.item_reference;
...ItemReferenceItemBase;
}

alias ResponseItemCollectionOrderQueryParameter = {
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
* for descending order.
*/
@query order?: ResponseItemCollectionOrder;
};

union ResponseItemCollectionOrder {
string,
Ascending: "asc",
Descending: "desc",
}

@access(Access.public)
@usage(Usage.input)
model ResponseItemCollectionOptions {
...CollectionAfterQueryParameter,
...CollectionBeforeQueryParameter,
...CollectionLimitQueryParameter,
...ResponseItemCollectionOrderQueryParameter,
}
2 changes: 0 additions & 2 deletions src/Custom/Responses/OpenAIResponseClient.Protocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace OpenAI.Responses;

[CodeGenSuppress("GetResponse", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
[CodeGenSuppress("GetResponseAsync", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
[CodeGenSuppress("GetInputItems", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
[CodeGenSuppress("GetInputItemsAsync", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
[CodeGenSuppress("CancelResponse", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
[CodeGenSuppress("CancelResponseAsync", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
[CodeGenSuppress("GetResponse", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
Expand Down
2 changes: 0 additions & 2 deletions src/Custom/Responses/OpenAIResponseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace OpenAI.Responses;
[CodeGenSuppress("CreateResponse", typeof(ResponseCreationOptions), typeof(CancellationToken))]
[CodeGenSuppress("GetResponse", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(CancellationToken))]
[CodeGenSuppress("GetResponseAsync", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(CancellationToken))]
[CodeGenSuppress("GetInputItems", typeof(string), typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
[CodeGenSuppress("GetInputItemsAsync", typeof(string), typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
[CodeGenSuppress("DeleteResponse", typeof(string), typeof(string), typeof(CancellationToken))]
[CodeGenSuppress("DeleteResponseAsync", typeof(string), typeof(string), typeof(CancellationToken))]
[CodeGenSuppress("CancelResponse", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(CancellationToken))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Responses;

/// <summary> The options to configure how <see cref="ResponseItem"/> objects are retrieved and paginated. </summary>
[Experimental("OPENAI001")]
public class ResponseItemCollectionOptions
{
/// <summary> Initializes a new instance of <see cref="ResponseItemCollectionOptions"/>. </summary>
public ResponseItemCollectionOptions() { }

/// <summary>
/// A limit on the number of <see cref="Response"/> objects to be returned per page.
/// </summary>
public int? PageSizeLimit { get; set; }

/// <summary>
/// The order in which to retrieve <see cref="Response"/> objects when sorted by their
/// <see cref="Response.CreatedAt"/> timestamp.
/// </summary>
public ResponseItemCollectionOrder? Order { get; set; }

/// <summary>
/// The <see cref="Response.Id"/> used to retrieve the page of <see cref="Response"/> objects that come
/// after this one.
/// </summary>
public string AfterId { get; set; }

/// <summary>
/// The <see cref="Response.Id"/> used to retrieve the page of <see cref="Response"/> objects that come
/// before this one.
/// </summary>
public string BeforeId { get; set; }
}
// CUSTOM: Make public and use the correct namespace.
[CodeGenType("ResponseItemCollectionOptions")] public partial class ResponseItemCollectionOptions { }
39 changes: 3 additions & 36 deletions src/Custom/Responses/Pagination/ResponseItemCollectionOrder.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
namespace OpenAI.Responses;

namespace OpenAI.Responses;

[Experimental("OPENAI001")]
public readonly partial struct ResponseItemCollectionOrder: IEquatable<ResponseItemCollectionOrder>
{
public static ResponseItemCollectionOrder Ascending { get; } = new("asc");

public static ResponseItemCollectionOrder Descending { get; } = new("desc");

private readonly string _value;

public ResponseItemCollectionOrder(string value)
{
Argument.AssertNotNull(value, nameof(value));
_value = value;
}

public static bool operator ==(ResponseItemCollectionOrder left, ResponseItemCollectionOrder right) => left.Equals(right);

public static bool operator !=(ResponseItemCollectionOrder left, ResponseItemCollectionOrder right) => !left.Equals(right);

public static implicit operator ResponseItemCollectionOrder(string value) => new(value);

[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) => obj is ResponseItemCollectionOrder other && Equals(other);

public bool Equals(ResponseItemCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;

public override string ToString() => _value;
}
// CUSTOM: Make public and use the correct namespace.
[CodeGenType("ResponseItemCollectionOrder")] public readonly partial struct ResponseItemCollectionOrder { }
2 changes: 1 addition & 1 deletion src/Generated/ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public virtual AsyncCollectionResult GetChatCompletionMessagesAsync(string compl
}

[Experimental("OPENAI001")]
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionCollectionOptions options = default, CancellationToken cancellationToken = default)
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionMessageCollectionOptions options = default, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(completionId, nameof(completionId));

Expand Down
Loading