@@ -140,8 +140,8 @@ pub struct UpdateVectorStoreRequest {
140
140
pub struct ListVectorStoreFilesResponse {
141
141
pub object : String ,
142
142
pub data : Vec < VectorStoreFileObject > ,
143
- pub first_id : String ,
144
- pub last_id : String ,
143
+ pub first_id : Option < String > ,
144
+ pub last_id : Option < String > ,
145
145
pub has_more : bool ,
146
146
}
147
147
@@ -209,7 +209,10 @@ pub enum VectorStoreFileObjectChunkingStrategy {
209
209
pub struct CreateVectorStoreFileRequest {
210
210
/// A [File](https://platform.openai.com/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files.
211
211
pub file_id : String ,
212
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
212
213
pub chunking_strategy : Option < VectorStoreChunkingStrategy > ,
214
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
215
+ pub attributes : Option < HashMap < String , AttributeValue > > ,
213
216
}
214
217
215
218
#[ derive( Debug , Deserialize , Clone , PartialEq , Serialize ) ]
@@ -269,3 +272,247 @@ pub struct VectorStoreFileBatchObject {
269
272
pub status : VectorStoreFileBatchStatus ,
270
273
pub file_counts : VectorStoreFileBatchCounts ,
271
274
}
275
+
276
+ /// Represents the parsed content of a vector store file.
277
+ #[ derive( Debug , Deserialize , Clone , PartialEq , Serialize ) ]
278
+ pub struct VectorStoreFileContentResponse {
279
+ /// The object type, which is always `vector_store.file_content.page`
280
+ pub object : String ,
281
+
282
+ /// Parsed content of the file.
283
+ pub data : Vec < VectorStoreFileContentObject > ,
284
+
285
+ /// Indicates if there are more content pages to fetch.
286
+ pub has_more : bool ,
287
+
288
+ /// The token for the next page, if any.
289
+ pub next_page : Option < String > ,
290
+ }
291
+
292
+ /// Represents the parsed content of a vector store file.
293
+ #[ derive( Debug , Deserialize , Clone , PartialEq , Serialize ) ]
294
+ pub struct VectorStoreFileContentObject {
295
+ /// The content type (currently only `"text"`)
296
+ pub r#type : String ,
297
+
298
+ /// The text content
299
+ pub text : String ,
300
+ }
301
+
302
+ #[ derive( Debug , Serialize , Default , Clone , Builder , PartialEq , Deserialize ) ]
303
+ #[ builder( name = "VectorStoreSearchRequestArgs" ) ]
304
+ #[ builder( pattern = "mutable" ) ]
305
+ #[ builder( setter( into, strip_option) , default ) ]
306
+ #[ builder( derive( Debug ) ) ]
307
+ #[ builder( build_fn( error = "OpenAIError" ) ) ]
308
+ pub struct VectorStoreSearchRequest {
309
+ /// A query string for a search.
310
+ pub query : VectorStoreSearchQuery ,
311
+
312
+ /// Whether to rewrite the natural language query for vector search.
313
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
314
+ pub rewrite_query : Option < bool > ,
315
+
316
+ /// The maximum number of results to return. This number should be between 1 and 50 inclusive.
317
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
318
+ pub max_num_results : Option < u8 > ,
319
+
320
+ /// A filter to apply based on file attributes.
321
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
322
+ pub filters : Option < VectorStoreSearchFilter > ,
323
+
324
+ /// Ranking options for search.
325
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
326
+ pub ranking_options : Option < RankingOptions > ,
327
+ }
328
+
329
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
330
+ #[ serde( untagged) ]
331
+ pub enum VectorStoreSearchQuery {
332
+ /// A single query to search for.
333
+ Text ( String ) ,
334
+ /// A list of queries to search for.
335
+ Array ( Vec < String > ) ,
336
+ }
337
+
338
+ impl Default for VectorStoreSearchQuery {
339
+ fn default ( ) -> Self {
340
+ Self :: Text ( String :: new ( ) )
341
+ }
342
+ }
343
+
344
+ impl From < String > for VectorStoreSearchQuery {
345
+ fn from ( query : String ) -> Self {
346
+ Self :: Text ( query)
347
+ }
348
+ }
349
+
350
+ impl From < & str > for VectorStoreSearchQuery {
351
+ fn from ( query : & str ) -> Self {
352
+ Self :: Text ( query. to_string ( ) )
353
+ }
354
+ }
355
+
356
+ impl From < Vec < String > > for VectorStoreSearchQuery {
357
+ fn from ( query : Vec < String > ) -> Self {
358
+ Self :: Array ( query)
359
+ }
360
+ }
361
+
362
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
363
+ #[ serde( untagged) ]
364
+ pub enum VectorStoreSearchFilter {
365
+ Comparison ( ComparisonFilter ) ,
366
+ Compound ( CompoundFilter ) ,
367
+ }
368
+
369
+ impl From < ComparisonFilter > for VectorStoreSearchFilter {
370
+ fn from ( filter : ComparisonFilter ) -> Self {
371
+ Self :: Comparison ( filter)
372
+ }
373
+ }
374
+
375
+ impl From < CompoundFilter > for VectorStoreSearchFilter {
376
+ fn from ( filter : CompoundFilter ) -> Self {
377
+ Self :: Compound ( filter)
378
+ }
379
+ }
380
+
381
+ /// A filter used to compare a specified attribute key to a given value using a defined comparison operation.
382
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
383
+ pub struct ComparisonFilter {
384
+ /// Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
385
+ pub r#type : ComparisonType ,
386
+
387
+ /// The key to compare against the value.
388
+ pub key : String ,
389
+
390
+ /// The value to compare against the attribute key; supports string, number, or boolean types.
391
+ pub value : AttributeValue ,
392
+ }
393
+
394
+ /// Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
395
+ #[ derive( Debug , Serialize , Deserialize , Clone , Copy , PartialEq ) ]
396
+ #[ serde( rename_all = "lowercase" ) ]
397
+ pub enum ComparisonType {
398
+ Eq ,
399
+ Ne ,
400
+ Gt ,
401
+ Gte ,
402
+ Lt ,
403
+ Lte ,
404
+ }
405
+
406
+ /// The value to compare against the attribute key; supports string, number, or boolean types.
407
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
408
+ #[ serde( untagged) ]
409
+ pub enum AttributeValue {
410
+ String ( String ) ,
411
+ Number ( i64 ) ,
412
+ Boolean ( bool ) ,
413
+ }
414
+
415
+ impl From < String > for AttributeValue {
416
+ fn from ( value : String ) -> Self {
417
+ Self :: String ( value)
418
+ }
419
+ }
420
+
421
+ impl From < i64 > for AttributeValue {
422
+ fn from ( value : i64 ) -> Self {
423
+ Self :: Number ( value)
424
+ }
425
+ }
426
+
427
+ impl From < bool > for AttributeValue {
428
+ fn from ( value : bool ) -> Self {
429
+ Self :: Boolean ( value)
430
+ }
431
+ }
432
+
433
+ impl From < & str > for AttributeValue {
434
+ fn from ( value : & str ) -> Self {
435
+ Self :: String ( value. to_string ( ) )
436
+ }
437
+ }
438
+
439
+ /// Ranking options for search.
440
+ #[ derive( Debug , Serialize , Default , Deserialize , Clone , PartialEq ) ]
441
+ pub struct RankingOptions {
442
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
443
+ pub ranker : Option < Ranker > ,
444
+
445
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
446
+ pub score_threshold : Option < f32 > ,
447
+ }
448
+
449
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
450
+ pub enum Ranker {
451
+ #[ serde( rename = "auto" ) ]
452
+ Auto ,
453
+ #[ serde( rename = "default-2024-11-15" ) ]
454
+ Default20241115 ,
455
+ }
456
+
457
+ /// Combine multiple filters using `and` or `or`.
458
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
459
+ pub struct CompoundFilter {
460
+ /// Type of operation: `and` or `or`.
461
+ pub r#type : CompoundFilterType ,
462
+
463
+ /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`
464
+ pub filters : Vec < VectorStoreSearchFilter > ,
465
+ }
466
+
467
+ /// Type of operation: `and` or `or`.
468
+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
469
+ #[ serde( rename_all = "lowercase" ) ]
470
+ pub enum CompoundFilterType {
471
+ And ,
472
+ Or ,
473
+ }
474
+
475
+ #[ derive( Debug , Deserialize , Clone , PartialEq , Serialize ) ]
476
+ pub struct VectorStoreSearchResultsPage {
477
+ /// The object type, which is always `vector_store.search_results.page`.
478
+ pub object : String ,
479
+
480
+ /// The query used for this search.
481
+ pub search_query : Vec < String > ,
482
+
483
+ /// The list of search result items.
484
+ pub data : Vec < VectorStoreSearchResultItem > ,
485
+
486
+ /// Indicates if there are more results to fetch.
487
+ pub has_more : bool ,
488
+
489
+ /// The token for the next page, if any.
490
+ pub next_page : Option < String > ,
491
+ }
492
+
493
+ #[ derive( Debug , Deserialize , Clone , PartialEq , Serialize ) ]
494
+ pub struct VectorStoreSearchResultItem {
495
+ /// The ID of the vector store file.
496
+ pub file_id : String ,
497
+
498
+ /// The name of the vector store file.
499
+ pub filename : String ,
500
+
501
+ /// The similarity score for the result.
502
+ pub score : f32 , // minimum: 0, maximum: 1
503
+
504
+ /// Attributes of the vector store file.
505
+ pub attributes : HashMap < String , AttributeValue > ,
506
+
507
+ /// Content chunks from the file.
508
+ pub content : Vec < VectorStoreSearchResultContentObject > ,
509
+ }
510
+
511
+ #[ derive( Debug , Deserialize , Clone , PartialEq , Serialize ) ]
512
+ pub struct VectorStoreSearchResultContentObject {
513
+ /// The type of content
514
+ pub r#type : String ,
515
+
516
+ /// The text content returned from search.
517
+ pub text : String ,
518
+ }
0 commit comments