Skip to content

Commit a6d76f4

Browse files
committed
merge
2 parents 69f307f + 9a979ad commit a6d76f4

26 files changed

+10928
-9899
lines changed

api/OpenAI.net8.0.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ public class ChatClient {
14711471
[Experimental("OPENAI001")]
14721472
public virtual Task<ClientResult<ChatCompletion>> GetChatCompletionAsync(string completionId, CancellationToken cancellationToken = default);
14731473
[Experimental("OPENAI001")]
1474-
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionCollectionOptions options = null, CancellationToken cancellationToken = default);
1474+
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionMessageCollectionOptions options = null, CancellationToken cancellationToken = default);
14751475
[Experimental("OPENAI001")]
14761476
public virtual CollectionResult GetChatCompletionMessages(string completionId, string after, int? limit, string order, RequestOptions options);
14771477
[Experimental("OPENAI001")]
@@ -4815,6 +4815,10 @@ public class OpenAIResponseClient {
48154815
public virtual ClientResult<ResponseDeletionResult> DeleteResponse(string responseId, CancellationToken cancellationToken = default);
48164816
public virtual Task<ClientResult> DeleteResponseAsync(string responseId, RequestOptions options);
48174817
public virtual Task<ClientResult<ResponseDeletionResult>> DeleteResponseAsync(string responseId, CancellationToken cancellationToken = default);
4818+
public virtual CollectionResult<ResponseItem> GetInputItems(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
4819+
public virtual CollectionResult GetInputItems(string responseId, int? limit, string order, string after, string before, RequestOptions options);
4820+
public virtual AsyncCollectionResult<ResponseItem> GetInputItemsAsync(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
4821+
public virtual AsyncCollectionResult GetInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options);
48184822
public virtual ClientResult GetResponse(string responseId, bool? stream, int? startingAfter, RequestOptions options);
48194823
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, CancellationToken cancellationToken = default);
48204824
public virtual Task<ClientResult> GetResponseAsync(string responseId, bool? stream, int? startingAfter, RequestOptions options);
@@ -5066,11 +5070,15 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
50665070
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
50675071
}
50685072
[Experimental("OPENAI001")]
5069-
public class ResponseItemCollectionOptions {
5073+
public class ResponseItemCollectionOptions : IJsonModel<ResponseItemCollectionOptions>, IPersistableModel<ResponseItemCollectionOptions> {
50705074
public string AfterId { get; set; }
50715075
public string BeforeId { get; set; }
50725076
public ResponseItemCollectionOrder? Order { get; set; }
50735077
public int? PageSizeLimit { get; set; }
5078+
protected virtual ResponseItemCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
5079+
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
5080+
protected virtual ResponseItemCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
5081+
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
50745082
}
50755083
[Experimental("OPENAI001")]
50765084
public readonly partial struct ResponseItemCollectionOrder : IEquatable<ResponseItemCollectionOrder> {
@@ -5084,6 +5092,7 @@ public class ResponseItemCollectionOptions {
50845092
public override readonly int GetHashCode();
50855093
public static bool operator ==(ResponseItemCollectionOrder left, ResponseItemCollectionOrder right);
50865094
public static implicit operator ResponseItemCollectionOrder(string value);
5095+
public static implicit operator ResponseItemCollectionOrder?(string value);
50875096
public static bool operator !=(ResponseItemCollectionOrder left, ResponseItemCollectionOrder right);
50885097
public override readonly string ToString();
50895098
}

api/OpenAI.netstandard2.0.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ public class ChatClient {
13181318
public virtual ClientResult<ChatCompletion> GetChatCompletion(string completionId, CancellationToken cancellationToken = default);
13191319
public virtual Task<ClientResult> GetChatCompletionAsync(string completionId, RequestOptions options);
13201320
public virtual Task<ClientResult<ChatCompletion>> GetChatCompletionAsync(string completionId, CancellationToken cancellationToken = default);
1321-
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionCollectionOptions options = null, CancellationToken cancellationToken = default);
1321+
public virtual CollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessages(string completionId, ChatCompletionMessageCollectionOptions options = null, CancellationToken cancellationToken = default);
13221322
public virtual CollectionResult GetChatCompletionMessages(string completionId, string after, int? limit, string order, RequestOptions options);
13231323
public virtual AsyncCollectionResult<ChatCompletionMessageListDatum> GetChatCompletionMessagesAsync(string completionId, ChatCompletionMessageCollectionOptions options = null, CancellationToken cancellationToken = default);
13241324
public virtual AsyncCollectionResult GetChatCompletionMessagesAsync(string completionId, string after, int? limit, string order, RequestOptions options);
@@ -4249,6 +4249,10 @@ public class OpenAIResponseClient {
42494249
public virtual ClientResult<ResponseDeletionResult> DeleteResponse(string responseId, CancellationToken cancellationToken = default);
42504250
public virtual Task<ClientResult> DeleteResponseAsync(string responseId, RequestOptions options);
42514251
public virtual Task<ClientResult<ResponseDeletionResult>> DeleteResponseAsync(string responseId, CancellationToken cancellationToken = default);
4252+
public virtual CollectionResult<ResponseItem> GetInputItems(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
4253+
public virtual CollectionResult GetInputItems(string responseId, int? limit, string order, string after, string before, RequestOptions options);
4254+
public virtual AsyncCollectionResult<ResponseItem> GetInputItemsAsync(string responseId, ResponseItemCollectionOptions options = null, CancellationToken cancellationToken = default);
4255+
public virtual AsyncCollectionResult GetInputItemsAsync(string responseId, int? limit, string order, string after, string before, RequestOptions options);
42524256
public virtual ClientResult GetResponse(string responseId, bool? stream, int? startingAfter, RequestOptions options);
42534257
public virtual ClientResult<OpenAIResponse> GetResponse(string responseId, CancellationToken cancellationToken = default);
42544258
public virtual Task<ClientResult> GetResponseAsync(string responseId, bool? stream, int? startingAfter, RequestOptions options);
@@ -4478,11 +4482,15 @@ public class ResponseItem : IJsonModel<ResponseItem>, IPersistableModel<Response
44784482
protected virtual ResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
44794483
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
44804484
}
4481-
public class ResponseItemCollectionOptions {
4485+
public class ResponseItemCollectionOptions : IJsonModel<ResponseItemCollectionOptions>, IPersistableModel<ResponseItemCollectionOptions> {
44824486
public string AfterId { get; set; }
44834487
public string BeforeId { get; set; }
44844488
public ResponseItemCollectionOrder? Order { get; set; }
44854489
public int? PageSizeLimit { get; set; }
4490+
protected virtual ResponseItemCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4491+
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4492+
protected virtual ResponseItemCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4493+
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
44864494
}
44874495
public readonly partial struct ResponseItemCollectionOrder : IEquatable<ResponseItemCollectionOrder> {
44884496
public ResponseItemCollectionOrder(string value);
@@ -4495,6 +4503,7 @@ public class ResponseItemCollectionOptions {
44954503
public override readonly int GetHashCode();
44964504
public static bool operator ==(ResponseItemCollectionOrder left, ResponseItemCollectionOrder right);
44974505
public static implicit operator ResponseItemCollectionOrder(string value);
4506+
public static implicit operator ResponseItemCollectionOrder?(string value);
44984507
public static bool operator !=(ResponseItemCollectionOrder left, ResponseItemCollectionOrder right);
44994508
public override readonly string ToString();
45004509
}

codegen/generator/src/Visitors/PaginationVisitor.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PaginationVisitor : ScmLibraryVisitor
2222
private static readonly Dictionary<string, string> _paramReplacementMap = new()
2323
{
2424
{ "after", "AfterId" },
25-
{ "before", "LastId" },
25+
{ "before", "BeforeId" },
2626
{ "limit", "PageSizeLimit" },
2727
{ "order", "Order" },
2828
{ "model", "Model" },
@@ -40,7 +40,7 @@ public class PaginationVisitor : ScmLibraryVisitor
4040
},
4141
{
4242
"GetChatCompletionMessages",
43-
("ChatCompletionMessageListDatum", "ChatCompletionCollectionOptions", _chatParamsToReplace)
43+
("ChatCompletionMessageListDatum", "ChatCompletionMessageCollectionOptions", _chatParamsToReplace)
4444
},
4545
{
4646
"GetChatCompletionMessagesAsync",
@@ -61,6 +61,14 @@ public class PaginationVisitor : ScmLibraryVisitor
6161
{
6262
"GetContainerFilesAsync",
6363
("ContainerFileResource", "ContainerFileCollectionOptions", _chatParamsToReplace)
64+
},
65+
{
66+
"GetInputItems",
67+
("ResponseItem", "ResponseItemCollectionOptions", _chatParamsToReplace)
68+
},
69+
{
70+
"GetInputItemsAsync",
71+
("ResponseItem", "ResponseItemCollectionOptions", _chatParamsToReplace)
6472
}
6573
};
6674

specification/base/typespec/responses/models.tsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ model ResponseItemList {
12721272
object: "list";
12731273

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

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

12831283
/** The ID of the last item in the list. */
1284-
last_id: string;
1284+
@continuationToken last_id: string;
12851285
}
12861286

12871287
// Tool customization: Establish discriminated type base

specification/base/typespec/responses/operations.tsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ interface Responses {
8282
@operationId("listInputItems")
8383
@get
8484
@route("{response_id}/input_items")
85+
@list
8586
listInputItems(
8687
@path
8788
@example("resp_677efb5139a88190b512bc3fef8e535d")

specification/client/models/common.models.tsp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,13 @@ alias CollectionAfterQueryParameter = {
144144
* subsequent call can include after=obj_foo in order to fetch the next page of the list.
145145
*/
146146
@query @continuationToken afterId?: string;
147+
};
148+
149+
alias CollectionBeforeQueryParameter = {
150+
/**
151+
* A cursor for use in pagination. `before` is an object ID that defines your place in the list.
152+
* For instance, if you make a list request and receive 100 objects, starting with obj_foo, your
153+
* subsequent call can include before=obj_foo in order to fetch the previous page of the list.
154+
*/
155+
@query beforeId?: string;
147156
};

specification/client/models/responses.models.tsp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "../../base/typespec/responses/main.tsp";
22
import "@azure-tools/typespec-client-generator-core";
33

44
using Azure.ClientGenerator.Core;
5+
using TypeSpec.Http;
56

67
namespace OpenAI;
78

@@ -25,3 +26,26 @@ model DotNetItemReferenceItemResource extends ItemResource {
2526
type: ItemType.item_reference;
2627
...ItemReferenceItemBase;
2728
}
29+
30+
alias ResponseItemCollectionOrderQueryParameter = {
31+
/**
32+
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
33+
* for descending order.
34+
*/
35+
@query order?: ResponseItemCollectionOrder;
36+
};
37+
38+
union ResponseItemCollectionOrder {
39+
string,
40+
Ascending: "asc",
41+
Descending: "desc",
42+
}
43+
44+
@access(Access.public)
45+
@usage(Usage.input)
46+
model ResponseItemCollectionOptions {
47+
...CollectionAfterQueryParameter,
48+
...CollectionBeforeQueryParameter,
49+
...CollectionLimitQueryParameter,
50+
...ResponseItemCollectionOrderQueryParameter,
51+
}

src/Custom/Responses/OpenAIResponseClient.Protocol.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ namespace OpenAI.Responses;
88

99
[CodeGenSuppress("GetResponse", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
1010
[CodeGenSuppress("GetResponseAsync", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
11-
[CodeGenSuppress("GetInputItems", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
12-
[CodeGenSuppress("GetInputItemsAsync", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
1311
[CodeGenSuppress("CancelResponse", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
1412
[CodeGenSuppress("CancelResponseAsync", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]
1513
[CodeGenSuppress("GetResponse", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(RequestOptions))]

src/Custom/Responses/OpenAIResponseClient.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace OpenAI.Responses;
1616
[CodeGenSuppress("CreateResponse", typeof(ResponseCreationOptions), typeof(CancellationToken))]
1717
[CodeGenSuppress("GetResponse", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(CancellationToken))]
1818
[CodeGenSuppress("GetResponseAsync", typeof(string), typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(CancellationToken))]
19-
[CodeGenSuppress("GetInputItems", typeof(string), typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
20-
[CodeGenSuppress("GetInputItemsAsync", typeof(string), typeof(int?), typeof(OpenAI.VectorStores.VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
2119
[CodeGenSuppress("DeleteResponse", typeof(string), typeof(string), typeof(CancellationToken))]
2220
[CodeGenSuppress("DeleteResponseAsync", typeof(string), typeof(string), typeof(CancellationToken))]
2321
[CodeGenSuppress("CancelResponse", typeof(string), typeof(IEnumerable<InternalIncludable>), typeof(bool?), typeof(int?), typeof(CancellationToken))]
Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
2-
31
namespace OpenAI.Responses;
42

5-
/// <summary> The options to configure how <see cref="ResponseItem"/> objects are retrieved and paginated. </summary>
6-
[Experimental("OPENAI001")]
7-
public class ResponseItemCollectionOptions
8-
{
9-
/// <summary> Initializes a new instance of <see cref="ResponseItemCollectionOptions"/>. </summary>
10-
public ResponseItemCollectionOptions() { }
11-
12-
/// <summary>
13-
/// A limit on the number of <see cref="Response"/> objects to be returned per page.
14-
/// </summary>
15-
public int? PageSizeLimit { get; set; }
16-
17-
/// <summary>
18-
/// The order in which to retrieve <see cref="Response"/> objects when sorted by their
19-
/// <see cref="Response.CreatedAt"/> timestamp.
20-
/// </summary>
21-
public ResponseItemCollectionOrder? Order { get; set; }
22-
23-
/// <summary>
24-
/// The <see cref="Response.Id"/> used to retrieve the page of <see cref="Response"/> objects that come
25-
/// after this one.
26-
/// </summary>
27-
public string AfterId { get; set; }
28-
29-
/// <summary>
30-
/// The <see cref="Response.Id"/> used to retrieve the page of <see cref="Response"/> objects that come
31-
/// before this one.
32-
/// </summary>
33-
public string BeforeId { get; set; }
34-
}
3+
// CUSTOM: Make public and use the correct namespace.
4+
[CodeGenType("ResponseItemCollectionOptions")] public partial class ResponseItemCollectionOptions { }

0 commit comments

Comments
 (0)