Skip to content

Commit 45770fe

Browse files
committed
wip
1 parent 9f3a94b commit 45770fe

20 files changed

+2317
-1814
lines changed

api/OpenAI.net8.0.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5620,11 +5620,15 @@ public class VectorStoreClient {
56205620
public virtual Task<ClientResult<VectorStoreFileAssociation>> UpdateVectorStoreFileAttributesAsync(string vectorStoreId, string fileId, IDictionary<string, BinaryData> attributes, CancellationToken cancellationToken = default);
56215621
}
56225622
[Experimental("OPENAI001")]
5623-
public class VectorStoreCollectionOptions {
5623+
public class VectorStoreCollectionOptions : IJsonModel<VectorStoreCollectionOptions>, IPersistableModel<VectorStoreCollectionOptions> {
56245624
public string AfterId { get; set; }
56255625
public string BeforeId { get; set; }
56265626
public VectorStoreCollectionOrder? Order { get; set; }
56275627
public int? PageSizeLimit { get; set; }
5628+
protected virtual VectorStoreCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
5629+
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
5630+
protected virtual VectorStoreCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
5631+
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
56285632
}
56295633
[Experimental("OPENAI001")]
56305634
public readonly partial struct VectorStoreCollectionOrder : IEquatable<VectorStoreCollectionOrder> {

api/OpenAI.netstandard2.0.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4984,11 +4984,15 @@ public class VectorStoreClient {
49844984
public virtual Task<ClientResult> UpdateVectorStoreFileAttributesAsync(string vectorStoreId, string fileId, BinaryContent content, RequestOptions options = null);
49854985
public virtual Task<ClientResult<VectorStoreFileAssociation>> UpdateVectorStoreFileAttributesAsync(string vectorStoreId, string fileId, IDictionary<string, BinaryData> attributes, CancellationToken cancellationToken = default);
49864986
}
4987-
public class VectorStoreCollectionOptions {
4987+
public class VectorStoreCollectionOptions : IJsonModel<VectorStoreCollectionOptions>, IPersistableModel<VectorStoreCollectionOptions> {
49884988
public string AfterId { get; set; }
49894989
public string BeforeId { get; set; }
49904990
public VectorStoreCollectionOrder? Order { get; set; }
49914991
public int? PageSizeLimit { get; set; }
4992+
protected virtual VectorStoreCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options);
4993+
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options);
4994+
protected virtual VectorStoreCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options);
4995+
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options);
49924996
}
49934997
public readonly partial struct VectorStoreCollectionOrder : IEquatable<VectorStoreCollectionOrder> {
49944998
public VectorStoreCollectionOrder(string value);

codegen/generator/src/Visitors/PaginationVisitor.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ namespace OpenAILibraryPlugin.Visitors;
1818
public class PaginationVisitor : ScmLibraryVisitor
1919
{
2020

21-
private static readonly string[] _chatParamsToReplace = ["after", "before", "limit", "order", "model", "metadata"];
21+
private static readonly string[] _paginationParamsToReplace = ["after", "before", "limit", "order", "model", "metadata"];
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" },
@@ -32,19 +32,27 @@ public class PaginationVisitor : ScmLibraryVisitor
3232
{
3333
{
3434
"GetChatCompletions",
35-
("ChatCompletion", "ChatCompletionCollectionOptions", _chatParamsToReplace)
35+
("ChatCompletion", "ChatCompletionCollectionOptions", _paginationParamsToReplace)
3636
},
3737
{
3838
"GetChatCompletionsAsync",
39-
("ChatCompletion", "ChatCompletionCollectionOptions", _chatParamsToReplace)
39+
("ChatCompletion", "ChatCompletionCollectionOptions", _paginationParamsToReplace)
4040
},
4141
{
4242
"GetChatCompletionMessages",
43-
("ChatCompletionMessageListDatum", "ChatCompletionCollectionOptions", _chatParamsToReplace)
43+
("ChatCompletionMessageListDatum", "ChatCompletionCollectionOptions", _paginationParamsToReplace)
4444
},
4545
{
4646
"GetChatCompletionMessagesAsync",
47-
("ChatCompletionMessageListDatum", "ChatCompletionMessageCollectionOptions", _chatParamsToReplace)
47+
("ChatCompletionMessageListDatum", "ChatCompletionMessageCollectionOptions", _paginationParamsToReplace)
48+
},
49+
{
50+
"GetVectorStores",
51+
("VectorStore", "VectorStoreCollectionOptions", _paginationParamsToReplace)
52+
},
53+
{
54+
"GetVectorStoresAsync",
55+
("VectorStore", "VectorStoreCollectionOptions", _paginationParamsToReplace)
4856
}
4957
};
5058

@@ -90,7 +98,7 @@ private bool TryHandlePaginationMethodWithOptions(MethodProvider method)
9098
int lastRemovedIndex = -1;
9199
for (int i = 0; i < newParameters.Count; i++)
92100
{
93-
if (_chatParamsToReplace.Contains(newParameters[i].Name))
101+
if (_paginationParamsToReplace.Contains(newParameters[i].Name))
94102
{
95103
newParameters.RemoveAt(i);
96104
lastRemovedIndex = i;

specification/base/typespec/vector-stores/models.tsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ model ListVectorStoresResponse {
128128
// Tool customization: add a clear enum enforcement of constrained 'object' label
129129
object: "list";
130130

131-
data: VectorStoreObject[];
131+
@pageItems data: VectorStoreObject[];
132132
first_id: string;
133-
last_id: string;
133+
@continuationToken last_id: string;
134134
has_more: boolean;
135135
}
136136

specification/base/typespec/vector-stores/operations.tsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface VectorStores {
1616
@get
1717
@operationId("listVectorStores")
1818
@summary("Returns a list of vector stores.")
19+
@list
1920
listVectorStores(
2021
...AcceptJsonHeader,
2122
...CommonPageQueryParameters,

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/vector-stores.models.tsp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "../../base/typespec/vector-stores/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

@@ -32,3 +33,12 @@ model DotNetCombinedOtherChunkingStrategyParam
3233
extends DotNetCombinedChunkingStrategyParam {
3334
...OtherChunkingStrategyResponseParam;
3435
}
36+
37+
@access(Access.public)
38+
@usage(Usage.input)
39+
model VectorStoreCollectionOptions {
40+
...CollectionAfterQueryParameter,
41+
...CollectionBeforeQueryParameter,
42+
...CollectionLimitQueryParameter,
43+
...PageOrderQueryParameter,
44+
}

src/Custom/VectorStores/VectorStoreClient.Protocol.cs

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace OpenAI.VectorStores;
99

10-
[CodeGenSuppress("GetVectorStoresAsync", typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
11-
[CodeGenSuppress("GetVectorStores", typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
1210
[CodeGenSuppress("GetVectorStoreFilesAsync", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
1311
[CodeGenSuppress("GetVectorStoreFiles", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
1412
[CodeGenSuppress("CreateVectorStoreFileAsync", typeof(string), typeof(BinaryContent), typeof(RequestOptions))]
@@ -23,63 +21,6 @@ namespace OpenAI.VectorStores;
2321
[CodeGenSuppress("ListFilesInVectorStoreBatches", typeof(string), typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))]
2422
public partial class VectorStoreClient
2523
{
26-
/// <summary>
27-
/// [Protocol Method] Returns a paginated collection of vector-stores.
28-
/// </summary>
29-
/// <param name="limit">
30-
/// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
31-
/// default is 20.
32-
/// </param>
33-
/// <param name="order">
34-
/// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
35-
/// for descending order. Allowed values: "asc" | "desc"
36-
/// </param>
37-
/// <param name="after">
38-
/// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
39-
/// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
40-
/// subsequent call can include after=obj_foo in order to fetch the next page of the list.
41-
/// </param>
42-
/// <param name="before">
43-
/// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
44-
/// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
45-
/// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
46-
/// </param>
47-
/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
48-
/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
49-
/// <returns> A collection of service responses, each holding a page of values. </returns>
50-
public virtual AsyncCollectionResult GetVectorStoresAsync(int? limit, string order, string after, string before, RequestOptions options)
51-
{
52-
return new AsyncVectorStoreCollectionResult(this, Pipeline, options, limit, order, after, before);
53-
}
54-
55-
/// <summary>
56-
/// [Protocol Method] Returns a paginated collection of vector-stores.
57-
/// </summary>
58-
/// <param name="limit">
59-
/// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
60-
/// default is 20.
61-
/// </param>
62-
/// <param name="order">
63-
/// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
64-
/// for descending order. Allowed values: "asc" | "desc"
65-
/// </param>
66-
/// <param name="after">
67-
/// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
68-
/// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
69-
/// subsequent call can include after=obj_foo in order to fetch the next page of the list.
70-
/// </param>
71-
/// <param name="before">
72-
/// A cursor for use in pagination. `before` is an object ID that defines your place in the list.
73-
/// For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
74-
/// subsequent call can include before=obj_foo in order to fetch the previous page of the list.
75-
/// </param>
76-
/// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
77-
/// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
78-
/// <returns> A collection of service responses, each holding a page of values. </returns>
79-
public virtual CollectionResult GetVectorStores(int? limit, string order, string after, string before, RequestOptions options)
80-
{
81-
return new VectorStoreCollectionResult(this, Pipeline, options, limit, order, after, before);
82-
}
8324

8425
/// <summary>
8526
/// [Protocol Method] Creates a vector store.

src/Custom/VectorStores/VectorStoreClient.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ namespace OpenAI.VectorStores;
1919
[CodeGenSuppress("CreateVectorStoreAsync", typeof(VectorStoreCreationOptions), typeof(CancellationToken))]
2020
[CodeGenSuppress("CreateVectorStoreFile", typeof(string), typeof(InternalCreateVectorStoreFileRequest), typeof(CancellationToken))]
2121
[CodeGenSuppress("CreateVectorStore", typeof(VectorStoreCreationOptions), typeof(CancellationToken))]
22-
[CodeGenSuppress("GetVectorStoresAsync", typeof(int?), typeof(VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
23-
[CodeGenSuppress("GetVectorStores", typeof(int?), typeof(VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))]
2422
[CodeGenSuppress("GetVectorStoreFilesAsync", typeof(string), typeof(int?), typeof(VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))]
2523
[CodeGenSuppress("GetVectorStoreFiles", typeof(string), typeof(int?), typeof(VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))]
2624
[CodeGenSuppress("CreateVectorStoreFileAsync", typeof(string), typeof(InternalCreateVectorStoreFileRequest), typeof(CancellationToken))]
@@ -254,20 +252,6 @@ public virtual ClientResult<VectorStoreDeletionResult> DeleteVectorStore(string
254252
return ClientResult.FromValue(value, rawProtocolResponse);
255253
}
256254

257-
/// <summary>
258-
/// Gets a page collection holding <see cref="VectorStore"/> instances for the configured organization.
259-
/// </summary>
260-
/// <param name="options"> Options describing the collection to return. </param>
261-
/// <param name="cancellationToken">A token that can be used to cancel this method call.</param>
262-
/// <returns> A collection of <see cref="VectorStore"/>. </returns>
263-
public virtual AsyncCollectionResult<VectorStore> GetVectorStoresAsync(
264-
VectorStoreCollectionOptions options = default,
265-
CancellationToken cancellationToken = default)
266-
{
267-
return GetVectorStoresAsync(options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions())
268-
as AsyncCollectionResult<VectorStore>;
269-
}
270-
271255
/// <summary>
272256
/// Rehydrates a page collection holding <see cref="VectorStore"/> instances from a page token.
273257
/// </summary>
@@ -285,20 +269,6 @@ public virtual AsyncCollectionResult<VectorStore> GetVectorStoresAsync(
285269
as AsyncCollectionResult<VectorStore>;
286270
}
287271

288-
/// <summary>
289-
/// Gets a page collection holding <see cref="VectorStore"/> instances for the configured organization.
290-
/// </summary>
291-
/// <param name="options"> Options describing the collection to return. </param>
292-
/// <param name="cancellationToken">A token that can be used to cancel this method call.</param>
293-
/// <returns> A collection of <see cref="VectorStore"/>. </returns>
294-
public virtual CollectionResult<VectorStore> GetVectorStores(
295-
VectorStoreCollectionOptions options = default,
296-
CancellationToken cancellationToken = default)
297-
{
298-
return GetVectorStores(options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions())
299-
as CollectionResult<VectorStore>;
300-
}
301-
302272
/// <summary>
303273
/// Rehydrates a page collection holding <see cref="VectorStore"/> instances from a page token.
304274
/// </summary>

src/Custom/VectorStores/VectorStoreCollectionOptions.cs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,5 @@
33
namespace OpenAI.VectorStores;
44

55
/// <summary> The options to configure how <see cref="VectorStore"/> objects are retrieved and paginated. </summary>
6-
[Experimental("OPENAI001")]
7-
public class VectorStoreCollectionOptions
8-
{
9-
/// <summary> Initializes a new instance of <see cref="VectorStoreCollectionOptions"/>. </summary>
10-
public VectorStoreCollectionOptions() { }
11-
12-
/// <summary>
13-
/// A limit on the number of <see cref="VectorStore"/> 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="VectorStore"/> objects when sorted by their
19-
/// <see cref="VectorStore.CreatedAt"/> timestamp.
20-
/// </summary>
21-
public VectorStoreCollectionOrder? Order { get; set; }
22-
23-
/// <summary>
24-
/// The <see cref="VectorStore.Id"/> used to retrieve the page of <see cref="VectorStore"/> objects that come
25-
/// after this one.
26-
/// </summary>
27-
public string AfterId { get; set; }
28-
29-
/// <summary>
30-
/// The <see cref="VectorStore.Id"/> used to retrieve the page of <see cref="VectorStore"/> objects that come
31-
/// before this one.
32-
/// </summary>
33-
public string BeforeId { get; set; }
34-
}
6+
// Customization: fix namespace
7+
[CodeGenType("VectorStoreCollectionOptions")] public partial class VectorStoreCollectionOptions{ }

0 commit comments

Comments
 (0)