forked from openai/openai-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbetavectorstorefile.go
669 lines (574 loc) · 24.4 KB
/
betavectorstorefile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openai
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"github.com/openai/openai-go/internal/apijson"
"github.com/openai/openai-go/internal/apiquery"
"github.com/openai/openai-go/internal/pagination"
"github.com/openai/openai-go/internal/param"
"github.com/openai/openai-go/internal/requestconfig"
"github.com/openai/openai-go/option"
"github.com/tidwall/gjson"
)
// BetaVectorStoreFileService contains methods and other services that help with
// interacting with the openai API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaVectorStoreFileService] method instead.
type BetaVectorStoreFileService struct {
Options []option.RequestOption
}
// NewBetaVectorStoreFileService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewBetaVectorStoreFileService(opts ...option.RequestOption) (r *BetaVectorStoreFileService) {
r = &BetaVectorStoreFileService{}
r.Options = opts
return
}
// Create a vector store file by attaching a
// [File](https://platform.openai.com/docs/api-reference/files) to a
// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
func (r *BetaVectorStoreFileService) New(ctx context.Context, vectorStoreID string, body BetaVectorStoreFileNewParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
opts = append(r.Options[:], opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
}
path := fmt.Sprintf("vector_stores/%s/files", vectorStoreID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Retrieves a vector store file.
func (r *BetaVectorStoreFileService) Get(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
opts = append(r.Options[:], opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
}
if fileID == "" {
err = errors.New("missing required file_id parameter")
return
}
path := fmt.Sprintf("vector_stores/%s/files/%s", vectorStoreID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// Returns a list of vector store files.
func (r *BetaVectorStoreFileService) List(ctx context.Context, vectorStoreID string, query BetaVectorStoreFileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStoreFile], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
}
path := fmt.Sprintf("vector_stores/%s/files", vectorStoreID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Returns a list of vector store files.
func (r *BetaVectorStoreFileService) ListAutoPaging(ctx context.Context, vectorStoreID string, query BetaVectorStoreFileListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[VectorStoreFile] {
return pagination.NewCursorPageAutoPager(r.List(ctx, vectorStoreID, query, opts...))
}
// Delete a vector store file. This will remove the file from the vector store but
// the file itself will not be deleted. To delete the file, use the
// [delete file](https://platform.openai.com/docs/api-reference/files/delete)
// endpoint.
func (r *BetaVectorStoreFileService) Delete(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFileDeleted, err error) {
opts = append(r.Options[:], opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
}
if fileID == "" {
err = errors.New("missing required file_id parameter")
return
}
path := fmt.Sprintf("vector_stores/%s/files/%s", vectorStoreID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}
// A list of files attached to a vector store.
type VectorStoreFile struct {
// The identifier, which can be referenced in API endpoints.
ID string `json:"id,required"`
// The Unix timestamp (in seconds) for when the vector store file was created.
CreatedAt int64 `json:"created_at,required"`
// The last error associated with this vector store file. Will be `null` if there
// are no errors.
LastError VectorStoreFileLastError `json:"last_error,required,nullable"`
// The object type, which is always `vector_store.file`.
Object VectorStoreFileObject `json:"object,required"`
// The status of the vector store file, which can be either `in_progress`,
// `completed`, `cancelled`, or `failed`. The status `completed` indicates that the
// vector store file is ready for use.
Status VectorStoreFileStatus `json:"status,required"`
// The total vector store usage in bytes. Note that this may be different from the
// original file size.
UsageBytes int64 `json:"usage_bytes,required"`
// The ID of the
// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
// that the [File](https://platform.openai.com/docs/api-reference/files) is
// attached to.
VectorStoreID string `json:"vector_store_id,required"`
// The strategy used to chunk the file.
ChunkingStrategy VectorStoreFileChunkingStrategy `json:"chunking_strategy"`
JSON vectorStoreFileJSON `json:"-"`
}
// vectorStoreFileJSON contains the JSON metadata for the struct [VectorStoreFile]
type vectorStoreFileJSON struct {
ID apijson.Field
CreatedAt apijson.Field
LastError apijson.Field
Object apijson.Field
Status apijson.Field
UsageBytes apijson.Field
VectorStoreID apijson.Field
ChunkingStrategy apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VectorStoreFile) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vectorStoreFileJSON) RawJSON() string {
return r.raw
}
// The last error associated with this vector store file. Will be `null` if there
// are no errors.
type VectorStoreFileLastError struct {
// One of `server_error` or `rate_limit_exceeded`.
Code VectorStoreFileLastErrorCode `json:"code,required"`
// A human-readable description of the error.
Message string `json:"message,required"`
JSON vectorStoreFileLastErrorJSON `json:"-"`
}
// vectorStoreFileLastErrorJSON contains the JSON metadata for the struct
// [VectorStoreFileLastError]
type vectorStoreFileLastErrorJSON struct {
Code apijson.Field
Message apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VectorStoreFileLastError) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vectorStoreFileLastErrorJSON) RawJSON() string {
return r.raw
}
// One of `server_error` or `rate_limit_exceeded`.
type VectorStoreFileLastErrorCode string
const (
VectorStoreFileLastErrorCodeServerError VectorStoreFileLastErrorCode = "server_error"
VectorStoreFileLastErrorCodeUnsupportedFile VectorStoreFileLastErrorCode = "unsupported_file"
VectorStoreFileLastErrorCodeInvalidFile VectorStoreFileLastErrorCode = "invalid_file"
)
func (r VectorStoreFileLastErrorCode) IsKnown() bool {
switch r {
case VectorStoreFileLastErrorCodeServerError, VectorStoreFileLastErrorCodeUnsupportedFile, VectorStoreFileLastErrorCodeInvalidFile:
return true
}
return false
}
// The object type, which is always `vector_store.file`.
type VectorStoreFileObject string
const (
VectorStoreFileObjectVectorStoreFile VectorStoreFileObject = "vector_store.file"
)
func (r VectorStoreFileObject) IsKnown() bool {
switch r {
case VectorStoreFileObjectVectorStoreFile:
return true
}
return false
}
// The status of the vector store file, which can be either `in_progress`,
// `completed`, `cancelled`, or `failed`. The status `completed` indicates that the
// vector store file is ready for use.
type VectorStoreFileStatus string
const (
VectorStoreFileStatusInProgress VectorStoreFileStatus = "in_progress"
VectorStoreFileStatusCompleted VectorStoreFileStatus = "completed"
VectorStoreFileStatusCancelled VectorStoreFileStatus = "cancelled"
VectorStoreFileStatusFailed VectorStoreFileStatus = "failed"
)
func (r VectorStoreFileStatus) IsKnown() bool {
switch r {
case VectorStoreFileStatusInProgress, VectorStoreFileStatusCompleted, VectorStoreFileStatusCancelled, VectorStoreFileStatusFailed:
return true
}
return false
}
// The strategy used to chunk the file.
type VectorStoreFileChunkingStrategy struct {
// Always `static`.
Type VectorStoreFileChunkingStrategyType `json:"type,required"`
// This field can have the runtime type of
// [VectorStoreFileChunkingStrategyStaticStatic].
Static interface{} `json:"static,required"`
JSON vectorStoreFileChunkingStrategyJSON `json:"-"`
union VectorStoreFileChunkingStrategyUnion
}
// vectorStoreFileChunkingStrategyJSON contains the JSON metadata for the struct
// [VectorStoreFileChunkingStrategy]
type vectorStoreFileChunkingStrategyJSON struct {
Type apijson.Field
Static apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r vectorStoreFileChunkingStrategyJSON) RawJSON() string {
return r.raw
}
func (r *VectorStoreFileChunkingStrategy) UnmarshalJSON(data []byte) (err error) {
*r = VectorStoreFileChunkingStrategy{}
err = apijson.UnmarshalRoot(data, &r.union)
if err != nil {
return err
}
return apijson.Port(r.union, &r)
}
// AsUnion returns a [VectorStoreFileChunkingStrategyUnion] interface which you can
// cast to the specific types for more type safety.
//
// Possible runtime types of the union are [VectorStoreFileChunkingStrategyStatic],
// [VectorStoreFileChunkingStrategyOther].
func (r VectorStoreFileChunkingStrategy) AsUnion() VectorStoreFileChunkingStrategyUnion {
return r.union
}
// The strategy used to chunk the file.
//
// Union satisfied by [VectorStoreFileChunkingStrategyStatic] or
// [VectorStoreFileChunkingStrategyOther].
type VectorStoreFileChunkingStrategyUnion interface {
implementsVectorStoreFileChunkingStrategy()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*VectorStoreFileChunkingStrategyUnion)(nil)).Elem(),
"type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(VectorStoreFileChunkingStrategyStatic{}),
DiscriminatorValue: "static",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(VectorStoreFileChunkingStrategyOther{}),
DiscriminatorValue: "other",
},
)
}
type VectorStoreFileChunkingStrategyStatic struct {
Static VectorStoreFileChunkingStrategyStaticStatic `json:"static,required"`
// Always `static`.
Type VectorStoreFileChunkingStrategyStaticType `json:"type,required"`
JSON vectorStoreFileChunkingStrategyStaticJSON `json:"-"`
}
// vectorStoreFileChunkingStrategyStaticJSON contains the JSON metadata for the
// struct [VectorStoreFileChunkingStrategyStatic]
type vectorStoreFileChunkingStrategyStaticJSON struct {
Static apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VectorStoreFileChunkingStrategyStatic) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vectorStoreFileChunkingStrategyStaticJSON) RawJSON() string {
return r.raw
}
func (r VectorStoreFileChunkingStrategyStatic) implementsVectorStoreFileChunkingStrategy() {}
type VectorStoreFileChunkingStrategyStaticStatic struct {
// The number of tokens that overlap between chunks. The default value is `400`.
//
// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
// The maximum number of tokens in each chunk. The default value is `800`. The
// minimum value is `100` and the maximum value is `4096`.
MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
JSON vectorStoreFileChunkingStrategyStaticStaticJSON `json:"-"`
}
// vectorStoreFileChunkingStrategyStaticStaticJSON contains the JSON metadata for
// the struct [VectorStoreFileChunkingStrategyStaticStatic]
type vectorStoreFileChunkingStrategyStaticStaticJSON struct {
ChunkOverlapTokens apijson.Field
MaxChunkSizeTokens apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VectorStoreFileChunkingStrategyStaticStatic) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vectorStoreFileChunkingStrategyStaticStaticJSON) RawJSON() string {
return r.raw
}
// Always `static`.
type VectorStoreFileChunkingStrategyStaticType string
const (
VectorStoreFileChunkingStrategyStaticTypeStatic VectorStoreFileChunkingStrategyStaticType = "static"
)
func (r VectorStoreFileChunkingStrategyStaticType) IsKnown() bool {
switch r {
case VectorStoreFileChunkingStrategyStaticTypeStatic:
return true
}
return false
}
// This is returned when the chunking strategy is unknown. Typically, this is
// because the file was indexed before the `chunking_strategy` concept was
// introduced in the API.
type VectorStoreFileChunkingStrategyOther struct {
// Always `other`.
Type VectorStoreFileChunkingStrategyOtherType `json:"type,required"`
JSON vectorStoreFileChunkingStrategyOtherJSON `json:"-"`
}
// vectorStoreFileChunkingStrategyOtherJSON contains the JSON metadata for the
// struct [VectorStoreFileChunkingStrategyOther]
type vectorStoreFileChunkingStrategyOtherJSON struct {
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VectorStoreFileChunkingStrategyOther) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vectorStoreFileChunkingStrategyOtherJSON) RawJSON() string {
return r.raw
}
func (r VectorStoreFileChunkingStrategyOther) implementsVectorStoreFileChunkingStrategy() {}
// Always `other`.
type VectorStoreFileChunkingStrategyOtherType string
const (
VectorStoreFileChunkingStrategyOtherTypeOther VectorStoreFileChunkingStrategyOtherType = "other"
)
func (r VectorStoreFileChunkingStrategyOtherType) IsKnown() bool {
switch r {
case VectorStoreFileChunkingStrategyOtherTypeOther:
return true
}
return false
}
// Always `static`.
type VectorStoreFileChunkingStrategyType string
const (
VectorStoreFileChunkingStrategyTypeStatic VectorStoreFileChunkingStrategyType = "static"
VectorStoreFileChunkingStrategyTypeOther VectorStoreFileChunkingStrategyType = "other"
)
func (r VectorStoreFileChunkingStrategyType) IsKnown() bool {
switch r {
case VectorStoreFileChunkingStrategyTypeStatic, VectorStoreFileChunkingStrategyTypeOther:
return true
}
return false
}
type VectorStoreFileDeleted struct {
ID string `json:"id,required"`
Deleted bool `json:"deleted,required"`
Object VectorStoreFileDeletedObject `json:"object,required"`
JSON vectorStoreFileDeletedJSON `json:"-"`
}
// vectorStoreFileDeletedJSON contains the JSON metadata for the struct
// [VectorStoreFileDeleted]
type vectorStoreFileDeletedJSON struct {
ID apijson.Field
Deleted apijson.Field
Object apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *VectorStoreFileDeleted) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r vectorStoreFileDeletedJSON) RawJSON() string {
return r.raw
}
type VectorStoreFileDeletedObject string
const (
VectorStoreFileDeletedObjectVectorStoreFileDeleted VectorStoreFileDeletedObject = "vector_store.file.deleted"
)
func (r VectorStoreFileDeletedObject) IsKnown() bool {
switch r {
case VectorStoreFileDeletedObjectVectorStoreFileDeleted:
return true
}
return false
}
type BetaVectorStoreFileNewParams struct {
// 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.
FileID param.Field[string] `json:"file_id,required"`
// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
// strategy.
ChunkingStrategy param.Field[BetaVectorStoreFileNewParamsChunkingStrategyUnion] `json:"chunking_strategy"`
}
func (r BetaVectorStoreFileNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
// strategy.
type BetaVectorStoreFileNewParamsChunkingStrategy struct {
// Always `auto`.
Type param.Field[BetaVectorStoreFileNewParamsChunkingStrategyType] `json:"type,required"`
Static param.Field[interface{}] `json:"static,required"`
}
func (r BetaVectorStoreFileNewParamsChunkingStrategy) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r BetaVectorStoreFileNewParamsChunkingStrategy) implementsBetaVectorStoreFileNewParamsChunkingStrategyUnion() {
}
// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
// strategy.
//
// Satisfied by
// [BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParam],
// [BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParam],
// [BetaVectorStoreFileNewParamsChunkingStrategy].
type BetaVectorStoreFileNewParamsChunkingStrategyUnion interface {
implementsBetaVectorStoreFileNewParamsChunkingStrategyUnion()
}
// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
// `800` and `chunk_overlap_tokens` of `400`.
type BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParam struct {
// Always `auto`.
Type param.Field[BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParamType] `json:"type,required"`
}
func (r BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParam) implementsBetaVectorStoreFileNewParamsChunkingStrategyUnion() {
}
// Always `auto`.
type BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParamType string
const (
BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParamTypeAuto BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParamType = "auto"
)
func (r BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParamType) IsKnown() bool {
switch r {
case BetaVectorStoreFileNewParamsChunkingStrategyAutoChunkingStrategyRequestParamTypeAuto:
return true
}
return false
}
type BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParam struct {
Static param.Field[BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamStatic] `json:"static,required"`
// Always `static`.
Type param.Field[BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamType] `json:"type,required"`
}
func (r BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParam) implementsBetaVectorStoreFileNewParamsChunkingStrategyUnion() {
}
type BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamStatic struct {
// The number of tokens that overlap between chunks. The default value is `400`.
//
// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
ChunkOverlapTokens param.Field[int64] `json:"chunk_overlap_tokens,required"`
// The maximum number of tokens in each chunk. The default value is `800`. The
// minimum value is `100` and the maximum value is `4096`.
MaxChunkSizeTokens param.Field[int64] `json:"max_chunk_size_tokens,required"`
}
func (r BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamStatic) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Always `static`.
type BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamType string
const (
BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamTypeStatic BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamType = "static"
)
func (r BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamType) IsKnown() bool {
switch r {
case BetaVectorStoreFileNewParamsChunkingStrategyStaticChunkingStrategyRequestParamTypeStatic:
return true
}
return false
}
// Always `auto`.
type BetaVectorStoreFileNewParamsChunkingStrategyType string
const (
BetaVectorStoreFileNewParamsChunkingStrategyTypeAuto BetaVectorStoreFileNewParamsChunkingStrategyType = "auto"
BetaVectorStoreFileNewParamsChunkingStrategyTypeStatic BetaVectorStoreFileNewParamsChunkingStrategyType = "static"
)
func (r BetaVectorStoreFileNewParamsChunkingStrategyType) IsKnown() bool {
switch r {
case BetaVectorStoreFileNewParamsChunkingStrategyTypeAuto, BetaVectorStoreFileNewParamsChunkingStrategyTypeStatic:
return true
}
return false
}
type BetaVectorStoreFileListParams struct {
// A cursor for use in pagination. `after` is an object ID that defines your place
// in the list. For instance, if you make a list request and receive 100 objects,
// ending with obj_foo, your subsequent call can include after=obj_foo in order to
// fetch the next page of the list.
After param.Field[string] `query:"after"`
// 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,
// ending with obj_foo, your subsequent call can include before=obj_foo in order to
// fetch the previous page of the list.
Before param.Field[string] `query:"before"`
// Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
Filter param.Field[BetaVectorStoreFileListParamsFilter] `query:"filter"`
// A limit on the number of objects to be returned. Limit can range between 1 and
// 100, and the default is 20.
Limit param.Field[int64] `query:"limit"`
// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
// order and `desc` for descending order.
Order param.Field[BetaVectorStoreFileListParamsOrder] `query:"order"`
}
// URLQuery serializes [BetaVectorStoreFileListParams]'s query parameters as
// `url.Values`.
func (r BetaVectorStoreFileListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
type BetaVectorStoreFileListParamsFilter string
const (
BetaVectorStoreFileListParamsFilterInProgress BetaVectorStoreFileListParamsFilter = "in_progress"
BetaVectorStoreFileListParamsFilterCompleted BetaVectorStoreFileListParamsFilter = "completed"
BetaVectorStoreFileListParamsFilterFailed BetaVectorStoreFileListParamsFilter = "failed"
BetaVectorStoreFileListParamsFilterCancelled BetaVectorStoreFileListParamsFilter = "cancelled"
)
func (r BetaVectorStoreFileListParamsFilter) IsKnown() bool {
switch r {
case BetaVectorStoreFileListParamsFilterInProgress, BetaVectorStoreFileListParamsFilterCompleted, BetaVectorStoreFileListParamsFilterFailed, BetaVectorStoreFileListParamsFilterCancelled:
return true
}
return false
}
// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
// order and `desc` for descending order.
type BetaVectorStoreFileListParamsOrder string
const (
BetaVectorStoreFileListParamsOrderAsc BetaVectorStoreFileListParamsOrder = "asc"
BetaVectorStoreFileListParamsOrderDesc BetaVectorStoreFileListParamsOrder = "desc"
)
func (r BetaVectorStoreFileListParamsOrder) IsKnown() bool {
switch r {
case BetaVectorStoreFileListParamsOrderAsc, BetaVectorStoreFileListParamsOrderDesc:
return true
}
return false
}