-
Notifications
You must be signed in to change notification settings - Fork 0
/
knowledge_bases.go
929 lines (823 loc) · 30.1 KB
/
knowledge_bases.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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
internal "github.com/VapiAI/server-sdk-go/internal"
time "time"
)
type KnowledgeBasesListRequest struct {
// This is the maximum number of items to return. Defaults to 100.
Limit *float64 `json:"-" url:"limit,omitempty"`
// This will return items where the createdAt is greater than the specified value.
CreatedAtGt *time.Time `json:"-" url:"createdAtGt,omitempty"`
// This will return items where the createdAt is less than the specified value.
CreatedAtLt *time.Time `json:"-" url:"createdAtLt,omitempty"`
// This will return items where the createdAt is greater than or equal to the specified value.
CreatedAtGe *time.Time `json:"-" url:"createdAtGe,omitempty"`
// This will return items where the createdAt is less than or equal to the specified value.
CreatedAtLe *time.Time `json:"-" url:"createdAtLe,omitempty"`
// This will return items where the updatedAt is greater than the specified value.
UpdatedAtGt *time.Time `json:"-" url:"updatedAtGt,omitempty"`
// This will return items where the updatedAt is less than the specified value.
UpdatedAtLt *time.Time `json:"-" url:"updatedAtLt,omitempty"`
// This will return items where the updatedAt is greater than or equal to the specified value.
UpdatedAtGe *time.Time `json:"-" url:"updatedAtGe,omitempty"`
// This will return items where the updatedAt is less than or equal to the specified value.
UpdatedAtLe *time.Time `json:"-" url:"updatedAtLe,omitempty"`
}
type CreateTrieveKnowledgeBaseDto struct {
// This is the name of the knowledge base.
Name *string `json:"name,omitempty" url:"name,omitempty"`
// This is the plan on how to search the vector store while a call is going on.
VectorStoreSearchPlan *TrieveKnowledgeBaseVectorStoreSearchPlan `json:"vectorStoreSearchPlan,omitempty" url:"vectorStoreSearchPlan,omitempty"`
// This is the plan if you want us to create a new vector store on your behalf. To use an existing vector store from your account, use `vectoreStoreProviderId`
VectorStoreCreatePlan *TrieveKnowledgeBaseVectorStoreCreatePlan `json:"vectorStoreCreatePlan,omitempty" url:"vectorStoreCreatePlan,omitempty"`
// This is an vector store that you already have on your account with the provider. To create a new vector store, use vectorStoreCreatePlan.
//
// Usage:
// - To bring your own vector store from Trieve, go to https://trieve.ai
// - Create a dataset, and use the datasetId here.
VectorStoreProviderId *string `json:"vectorStoreProviderId,omitempty" url:"vectorStoreProviderId,omitempty"`
provider string
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CreateTrieveKnowledgeBaseDto) GetName() *string {
if c == nil {
return nil
}
return c.Name
}
func (c *CreateTrieveKnowledgeBaseDto) GetVectorStoreSearchPlan() *TrieveKnowledgeBaseVectorStoreSearchPlan {
if c == nil {
return nil
}
return c.VectorStoreSearchPlan
}
func (c *CreateTrieveKnowledgeBaseDto) GetVectorStoreCreatePlan() *TrieveKnowledgeBaseVectorStoreCreatePlan {
if c == nil {
return nil
}
return c.VectorStoreCreatePlan
}
func (c *CreateTrieveKnowledgeBaseDto) GetVectorStoreProviderId() *string {
if c == nil {
return nil
}
return c.VectorStoreProviderId
}
func (c *CreateTrieveKnowledgeBaseDto) Provider() string {
return c.provider
}
func (c *CreateTrieveKnowledgeBaseDto) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CreateTrieveKnowledgeBaseDto) UnmarshalJSON(data []byte) error {
type embed CreateTrieveKnowledgeBaseDto
var unmarshaler = struct {
embed
Provider string `json:"provider"`
}{
embed: embed(*c),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*c = CreateTrieveKnowledgeBaseDto(unmarshaler.embed)
if unmarshaler.Provider != "trieve" {
return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", c, "trieve", unmarshaler.Provider)
}
c.provider = unmarshaler.Provider
extraProperties, err := internal.ExtractExtraProperties(data, *c, "provider")
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CreateTrieveKnowledgeBaseDto) MarshalJSON() ([]byte, error) {
type embed CreateTrieveKnowledgeBaseDto
var marshaler = struct {
embed
Provider string `json:"provider"`
}{
embed: embed(*c),
Provider: "trieve",
}
return json.Marshal(marshaler)
}
func (c *CreateTrieveKnowledgeBaseDto) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
type CustomKnowledgeBase struct {
// /**
// This is where the knowledge base request will be sent.
//
// Request Example:
//
// POST https://{server.url}
// Content-Type: application/json
//
// {
// "messsage": {
// "type": "knowledge-base-request",
// "messages": [
// {
// "role": "user",
// "content": "Why is ocean blue?"
// }
// ],
// ...other metadata about the call...
// }
// }
//
// Response Expected:
// ```
//
// {
// "message": {
// "role": "assistant",
// "content": "The ocean is blue because water absorbs everything but blue.",
// }, // YOU CAN RETURN THE EXACT RESPONSE TO SPEAK
// "documents": [
// {
// "content": "The ocean is blue primarily because water absorbs colors in the red part of the light spectrum and scatters the blue light, making it more visible to our eyes.",
// "similarity": 1
// },
// {
// "content": "Blue light is scattered more by the water molecules than other colors, enhancing the blue appearance of the ocean.",
// "similarity": .5
// }
// ] // OR, YOU CAN RETURN AN ARRAY OF DOCUMENTS THAT WILL BE SENT TO THE MODEL
// }
//
// ```
Server *Server `json:"server,omitempty" url:"server,omitempty"`
// This is the id of the knowledge base.
Id string `json:"id" url:"id"`
// This is the org id of the knowledge base.
OrgId string `json:"orgId" url:"orgId"`
provider string
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (c *CustomKnowledgeBase) GetServer() *Server {
if c == nil {
return nil
}
return c.Server
}
func (c *CustomKnowledgeBase) GetId() string {
if c == nil {
return ""
}
return c.Id
}
func (c *CustomKnowledgeBase) GetOrgId() string {
if c == nil {
return ""
}
return c.OrgId
}
func (c *CustomKnowledgeBase) Provider() string {
return c.provider
}
func (c *CustomKnowledgeBase) GetExtraProperties() map[string]interface{} {
return c.extraProperties
}
func (c *CustomKnowledgeBase) UnmarshalJSON(data []byte) error {
type embed CustomKnowledgeBase
var unmarshaler = struct {
embed
Provider string `json:"provider"`
}{
embed: embed(*c),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*c = CustomKnowledgeBase(unmarshaler.embed)
if unmarshaler.Provider != "custom-knowledge-base" {
return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", c, "custom-knowledge-base", unmarshaler.Provider)
}
c.provider = unmarshaler.Provider
extraProperties, err := internal.ExtractExtraProperties(data, *c, "provider")
if err != nil {
return err
}
c.extraProperties = extraProperties
c.rawJSON = json.RawMessage(data)
return nil
}
func (c *CustomKnowledgeBase) MarshalJSON() ([]byte, error) {
type embed CustomKnowledgeBase
var marshaler = struct {
embed
Provider string `json:"provider"`
}{
embed: embed(*c),
Provider: "custom-knowledge-base",
}
return json.Marshal(marshaler)
}
func (c *CustomKnowledgeBase) String() string {
if len(c.rawJSON) > 0 {
if value, err := internal.StringifyJSON(c.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}
type TrieveKnowledgeBase struct {
// This is the name of the knowledge base.
Name *string `json:"name,omitempty" url:"name,omitempty"`
// This is the plan on how to search the vector store while a call is going on.
VectorStoreSearchPlan *TrieveKnowledgeBaseVectorStoreSearchPlan `json:"vectorStoreSearchPlan,omitempty" url:"vectorStoreSearchPlan,omitempty"`
// This is the plan if you want us to create a new vector store on your behalf. To use an existing vector store from your account, use `vectoreStoreProviderId`
VectorStoreCreatePlan *TrieveKnowledgeBaseVectorStoreCreatePlan `json:"vectorStoreCreatePlan,omitempty" url:"vectorStoreCreatePlan,omitempty"`
// This is an vector store that you already have on your account with the provider. To create a new vector store, use vectorStoreCreatePlan.
//
// Usage:
// - To bring your own vector store from Trieve, go to https://trieve.ai
// - Create a dataset, and use the datasetId here.
VectorStoreProviderId *string `json:"vectorStoreProviderId,omitempty" url:"vectorStoreProviderId,omitempty"`
// This is the id of the knowledge base.
Id string `json:"id" url:"id"`
// This is the org id of the knowledge base.
OrgId string `json:"orgId" url:"orgId"`
provider string
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (t *TrieveKnowledgeBase) GetName() *string {
if t == nil {
return nil
}
return t.Name
}
func (t *TrieveKnowledgeBase) GetVectorStoreSearchPlan() *TrieveKnowledgeBaseVectorStoreSearchPlan {
if t == nil {
return nil
}
return t.VectorStoreSearchPlan
}
func (t *TrieveKnowledgeBase) GetVectorStoreCreatePlan() *TrieveKnowledgeBaseVectorStoreCreatePlan {
if t == nil {
return nil
}
return t.VectorStoreCreatePlan
}
func (t *TrieveKnowledgeBase) GetVectorStoreProviderId() *string {
if t == nil {
return nil
}
return t.VectorStoreProviderId
}
func (t *TrieveKnowledgeBase) GetId() string {
if t == nil {
return ""
}
return t.Id
}
func (t *TrieveKnowledgeBase) GetOrgId() string {
if t == nil {
return ""
}
return t.OrgId
}
func (t *TrieveKnowledgeBase) Provider() string {
return t.provider
}
func (t *TrieveKnowledgeBase) GetExtraProperties() map[string]interface{} {
return t.extraProperties
}
func (t *TrieveKnowledgeBase) UnmarshalJSON(data []byte) error {
type embed TrieveKnowledgeBase
var unmarshaler = struct {
embed
Provider string `json:"provider"`
}{
embed: embed(*t),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*t = TrieveKnowledgeBase(unmarshaler.embed)
if unmarshaler.Provider != "trieve" {
return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", t, "trieve", unmarshaler.Provider)
}
t.provider = unmarshaler.Provider
extraProperties, err := internal.ExtractExtraProperties(data, *t, "provider")
if err != nil {
return err
}
t.extraProperties = extraProperties
t.rawJSON = json.RawMessage(data)
return nil
}
func (t *TrieveKnowledgeBase) MarshalJSON() ([]byte, error) {
type embed TrieveKnowledgeBase
var marshaler = struct {
embed
Provider string `json:"provider"`
}{
embed: embed(*t),
Provider: "trieve",
}
return json.Marshal(marshaler)
}
func (t *TrieveKnowledgeBase) String() string {
if len(t.rawJSON) > 0 {
if value, err := internal.StringifyJSON(t.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(t); err == nil {
return value
}
return fmt.Sprintf("%#v", t)
}
type TrieveKnowledgeBaseVectorStoreCreatePlan struct {
// These are the file ids that will be used to create the vector store. To upload files, use the `POST /files` endpoint.
FileIds []string `json:"fileIds,omitempty" url:"fileIds,omitempty"`
// This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number.
TargetSplitsPerChunk *float64 `json:"targetSplitsPerChunk,omitempty" url:"targetSplitsPerChunk,omitempty"`
// This is an optional field which allows you to specify the delimiters to use when splitting the file before chunking the text. If not specified, the default [.!?\n] are used to split into sentences. However, you may want to use spaces or other delimiters.
SplitDelimiters []string `json:"splitDelimiters,omitempty" url:"splitDelimiters,omitempty"`
// This is an optional field which allows you to specify whether or not to rebalance the chunks created from the file. If not specified, the default true is used. If true, Trieve will evenly distribute remainder splits across chunks such that 66 splits with a target_splits_per_chunk of 20 will result in 3 chunks with 22 splits each.
RebalanceChunks *bool `json:"rebalanceChunks,omitempty" url:"rebalanceChunks,omitempty"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) GetFileIds() []string {
if t == nil {
return nil
}
return t.FileIds
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) GetTargetSplitsPerChunk() *float64 {
if t == nil {
return nil
}
return t.TargetSplitsPerChunk
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) GetSplitDelimiters() []string {
if t == nil {
return nil
}
return t.SplitDelimiters
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) GetRebalanceChunks() *bool {
if t == nil {
return nil
}
return t.RebalanceChunks
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) GetExtraProperties() map[string]interface{} {
return t.extraProperties
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) UnmarshalJSON(data []byte) error {
type unmarshaler TrieveKnowledgeBaseVectorStoreCreatePlan
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*t = TrieveKnowledgeBaseVectorStoreCreatePlan(value)
extraProperties, err := internal.ExtractExtraProperties(data, *t)
if err != nil {
return err
}
t.extraProperties = extraProperties
t.rawJSON = json.RawMessage(data)
return nil
}
func (t *TrieveKnowledgeBaseVectorStoreCreatePlan) String() string {
if len(t.rawJSON) > 0 {
if value, err := internal.StringifyJSON(t.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(t); err == nil {
return value
}
return fmt.Sprintf("%#v", t)
}
type TrieveKnowledgeBaseVectorStoreSearchPlan struct {
// If true, stop words (specified in server/src/stop-words.txt in the git repo) will be removed. This will preserve queries that are entirely stop words.
RemoveStopWords *bool `json:"removeStopWords,omitempty" url:"removeStopWords,omitempty"`
// This is the score threshold to filter out chunks with a score below the threshold for cosine distance metric. For Manhattan Distance, Euclidean Distance, and Dot Product, it will filter out scores above the threshold distance. This threshold applies before weight and bias modifications. If not specified, this defaults to no threshold. A threshold of 0 will default to no threshold.
ScoreThreshold *float64 `json:"scoreThreshold,omitempty" url:"scoreThreshold,omitempty"`
// This is the search method used when searching for relevant chunks from the vector store.
SearchType TrieveKnowledgeBaseVectorStoreSearchPlanSearchType `json:"searchType" url:"searchType"`
extraProperties map[string]interface{}
rawJSON json.RawMessage
}
func (t *TrieveKnowledgeBaseVectorStoreSearchPlan) GetRemoveStopWords() *bool {
if t == nil {
return nil
}
return t.RemoveStopWords
}
func (t *TrieveKnowledgeBaseVectorStoreSearchPlan) GetScoreThreshold() *float64 {
if t == nil {
return nil
}
return t.ScoreThreshold
}
func (t *TrieveKnowledgeBaseVectorStoreSearchPlan) GetSearchType() TrieveKnowledgeBaseVectorStoreSearchPlanSearchType {
if t == nil {
return ""
}
return t.SearchType
}
func (t *TrieveKnowledgeBaseVectorStoreSearchPlan) GetExtraProperties() map[string]interface{} {
return t.extraProperties
}
func (t *TrieveKnowledgeBaseVectorStoreSearchPlan) UnmarshalJSON(data []byte) error {
type unmarshaler TrieveKnowledgeBaseVectorStoreSearchPlan
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*t = TrieveKnowledgeBaseVectorStoreSearchPlan(value)
extraProperties, err := internal.ExtractExtraProperties(data, *t)
if err != nil {
return err
}
t.extraProperties = extraProperties
t.rawJSON = json.RawMessage(data)
return nil
}
func (t *TrieveKnowledgeBaseVectorStoreSearchPlan) String() string {
if len(t.rawJSON) > 0 {
if value, err := internal.StringifyJSON(t.rawJSON); err == nil {
return value
}
}
if value, err := internal.StringifyJSON(t); err == nil {
return value
}
return fmt.Sprintf("%#v", t)
}
// This is the search method used when searching for relevant chunks from the vector store.
type TrieveKnowledgeBaseVectorStoreSearchPlanSearchType string
const (
TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeFulltext TrieveKnowledgeBaseVectorStoreSearchPlanSearchType = "fulltext"
TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeSemantic TrieveKnowledgeBaseVectorStoreSearchPlanSearchType = "semantic"
TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeHybrid TrieveKnowledgeBaseVectorStoreSearchPlanSearchType = "hybrid"
TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeBm25 TrieveKnowledgeBaseVectorStoreSearchPlanSearchType = "bm25"
)
func NewTrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeFromString(s string) (TrieveKnowledgeBaseVectorStoreSearchPlanSearchType, error) {
switch s {
case "fulltext":
return TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeFulltext, nil
case "semantic":
return TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeSemantic, nil
case "hybrid":
return TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeHybrid, nil
case "bm25":
return TrieveKnowledgeBaseVectorStoreSearchPlanSearchTypeBm25, nil
}
var t TrieveKnowledgeBaseVectorStoreSearchPlanSearchType
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (t TrieveKnowledgeBaseVectorStoreSearchPlanSearchType) Ptr() *TrieveKnowledgeBaseVectorStoreSearchPlanSearchType {
return &t
}
type KnowledgeBasesCreateRequest struct {
CreateTrieveKnowledgeBaseDto *CreateTrieveKnowledgeBaseDto
CreateCustomKnowledgeBaseDto *CreateCustomKnowledgeBaseDto
typ string
}
func (k *KnowledgeBasesCreateRequest) GetCreateTrieveKnowledgeBaseDto() *CreateTrieveKnowledgeBaseDto {
if k == nil {
return nil
}
return k.CreateTrieveKnowledgeBaseDto
}
func (k *KnowledgeBasesCreateRequest) GetCreateCustomKnowledgeBaseDto() *CreateCustomKnowledgeBaseDto {
if k == nil {
return nil
}
return k.CreateCustomKnowledgeBaseDto
}
func (k *KnowledgeBasesCreateRequest) UnmarshalJSON(data []byte) error {
valueCreateTrieveKnowledgeBaseDto := new(CreateTrieveKnowledgeBaseDto)
if err := json.Unmarshal(data, &valueCreateTrieveKnowledgeBaseDto); err == nil {
k.typ = "CreateTrieveKnowledgeBaseDto"
k.CreateTrieveKnowledgeBaseDto = valueCreateTrieveKnowledgeBaseDto
return nil
}
valueCreateCustomKnowledgeBaseDto := new(CreateCustomKnowledgeBaseDto)
if err := json.Unmarshal(data, &valueCreateCustomKnowledgeBaseDto); err == nil {
k.typ = "CreateCustomKnowledgeBaseDto"
k.CreateCustomKnowledgeBaseDto = valueCreateCustomKnowledgeBaseDto
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, k)
}
func (k KnowledgeBasesCreateRequest) MarshalJSON() ([]byte, error) {
if k.typ == "CreateTrieveKnowledgeBaseDto" || k.CreateTrieveKnowledgeBaseDto != nil {
return json.Marshal(k.CreateTrieveKnowledgeBaseDto)
}
if k.typ == "CreateCustomKnowledgeBaseDto" || k.CreateCustomKnowledgeBaseDto != nil {
return json.Marshal(k.CreateCustomKnowledgeBaseDto)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesCreateRequestVisitor interface {
VisitCreateTrieveKnowledgeBaseDto(*CreateTrieveKnowledgeBaseDto) error
VisitCreateCustomKnowledgeBaseDto(*CreateCustomKnowledgeBaseDto) error
}
func (k *KnowledgeBasesCreateRequest) Accept(visitor KnowledgeBasesCreateRequestVisitor) error {
if k.typ == "CreateTrieveKnowledgeBaseDto" || k.CreateTrieveKnowledgeBaseDto != nil {
return visitor.VisitCreateTrieveKnowledgeBaseDto(k.CreateTrieveKnowledgeBaseDto)
}
if k.typ == "CreateCustomKnowledgeBaseDto" || k.CreateCustomKnowledgeBaseDto != nil {
return visitor.VisitCreateCustomKnowledgeBaseDto(k.CreateCustomKnowledgeBaseDto)
}
return fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesCreateResponse struct {
TrieveKnowledgeBase *TrieveKnowledgeBase
CustomKnowledgeBase *CustomKnowledgeBase
typ string
}
func (k *KnowledgeBasesCreateResponse) GetTrieveKnowledgeBase() *TrieveKnowledgeBase {
if k == nil {
return nil
}
return k.TrieveKnowledgeBase
}
func (k *KnowledgeBasesCreateResponse) GetCustomKnowledgeBase() *CustomKnowledgeBase {
if k == nil {
return nil
}
return k.CustomKnowledgeBase
}
func (k *KnowledgeBasesCreateResponse) UnmarshalJSON(data []byte) error {
valueTrieveKnowledgeBase := new(TrieveKnowledgeBase)
if err := json.Unmarshal(data, &valueTrieveKnowledgeBase); err == nil {
k.typ = "TrieveKnowledgeBase"
k.TrieveKnowledgeBase = valueTrieveKnowledgeBase
return nil
}
valueCustomKnowledgeBase := new(CustomKnowledgeBase)
if err := json.Unmarshal(data, &valueCustomKnowledgeBase); err == nil {
k.typ = "CustomKnowledgeBase"
k.CustomKnowledgeBase = valueCustomKnowledgeBase
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, k)
}
func (k KnowledgeBasesCreateResponse) MarshalJSON() ([]byte, error) {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return json.Marshal(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return json.Marshal(k.CustomKnowledgeBase)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesCreateResponseVisitor interface {
VisitTrieveKnowledgeBase(*TrieveKnowledgeBase) error
VisitCustomKnowledgeBase(*CustomKnowledgeBase) error
}
func (k *KnowledgeBasesCreateResponse) Accept(visitor KnowledgeBasesCreateResponseVisitor) error {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return visitor.VisitTrieveKnowledgeBase(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return visitor.VisitCustomKnowledgeBase(k.CustomKnowledgeBase)
}
return fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesDeleteResponse struct {
TrieveKnowledgeBase *TrieveKnowledgeBase
CustomKnowledgeBase *CustomKnowledgeBase
typ string
}
func (k *KnowledgeBasesDeleteResponse) GetTrieveKnowledgeBase() *TrieveKnowledgeBase {
if k == nil {
return nil
}
return k.TrieveKnowledgeBase
}
func (k *KnowledgeBasesDeleteResponse) GetCustomKnowledgeBase() *CustomKnowledgeBase {
if k == nil {
return nil
}
return k.CustomKnowledgeBase
}
func (k *KnowledgeBasesDeleteResponse) UnmarshalJSON(data []byte) error {
valueTrieveKnowledgeBase := new(TrieveKnowledgeBase)
if err := json.Unmarshal(data, &valueTrieveKnowledgeBase); err == nil {
k.typ = "TrieveKnowledgeBase"
k.TrieveKnowledgeBase = valueTrieveKnowledgeBase
return nil
}
valueCustomKnowledgeBase := new(CustomKnowledgeBase)
if err := json.Unmarshal(data, &valueCustomKnowledgeBase); err == nil {
k.typ = "CustomKnowledgeBase"
k.CustomKnowledgeBase = valueCustomKnowledgeBase
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, k)
}
func (k KnowledgeBasesDeleteResponse) MarshalJSON() ([]byte, error) {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return json.Marshal(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return json.Marshal(k.CustomKnowledgeBase)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesDeleteResponseVisitor interface {
VisitTrieveKnowledgeBase(*TrieveKnowledgeBase) error
VisitCustomKnowledgeBase(*CustomKnowledgeBase) error
}
func (k *KnowledgeBasesDeleteResponse) Accept(visitor KnowledgeBasesDeleteResponseVisitor) error {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return visitor.VisitTrieveKnowledgeBase(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return visitor.VisitCustomKnowledgeBase(k.CustomKnowledgeBase)
}
return fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesGetResponse struct {
TrieveKnowledgeBase *TrieveKnowledgeBase
CustomKnowledgeBase *CustomKnowledgeBase
typ string
}
func (k *KnowledgeBasesGetResponse) GetTrieveKnowledgeBase() *TrieveKnowledgeBase {
if k == nil {
return nil
}
return k.TrieveKnowledgeBase
}
func (k *KnowledgeBasesGetResponse) GetCustomKnowledgeBase() *CustomKnowledgeBase {
if k == nil {
return nil
}
return k.CustomKnowledgeBase
}
func (k *KnowledgeBasesGetResponse) UnmarshalJSON(data []byte) error {
valueTrieveKnowledgeBase := new(TrieveKnowledgeBase)
if err := json.Unmarshal(data, &valueTrieveKnowledgeBase); err == nil {
k.typ = "TrieveKnowledgeBase"
k.TrieveKnowledgeBase = valueTrieveKnowledgeBase
return nil
}
valueCustomKnowledgeBase := new(CustomKnowledgeBase)
if err := json.Unmarshal(data, &valueCustomKnowledgeBase); err == nil {
k.typ = "CustomKnowledgeBase"
k.CustomKnowledgeBase = valueCustomKnowledgeBase
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, k)
}
func (k KnowledgeBasesGetResponse) MarshalJSON() ([]byte, error) {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return json.Marshal(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return json.Marshal(k.CustomKnowledgeBase)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesGetResponseVisitor interface {
VisitTrieveKnowledgeBase(*TrieveKnowledgeBase) error
VisitCustomKnowledgeBase(*CustomKnowledgeBase) error
}
func (k *KnowledgeBasesGetResponse) Accept(visitor KnowledgeBasesGetResponseVisitor) error {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return visitor.VisitTrieveKnowledgeBase(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return visitor.VisitCustomKnowledgeBase(k.CustomKnowledgeBase)
}
return fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesListResponseItem struct {
TrieveKnowledgeBase *TrieveKnowledgeBase
CustomKnowledgeBase *CustomKnowledgeBase
typ string
}
func (k *KnowledgeBasesListResponseItem) GetTrieveKnowledgeBase() *TrieveKnowledgeBase {
if k == nil {
return nil
}
return k.TrieveKnowledgeBase
}
func (k *KnowledgeBasesListResponseItem) GetCustomKnowledgeBase() *CustomKnowledgeBase {
if k == nil {
return nil
}
return k.CustomKnowledgeBase
}
func (k *KnowledgeBasesListResponseItem) UnmarshalJSON(data []byte) error {
valueTrieveKnowledgeBase := new(TrieveKnowledgeBase)
if err := json.Unmarshal(data, &valueTrieveKnowledgeBase); err == nil {
k.typ = "TrieveKnowledgeBase"
k.TrieveKnowledgeBase = valueTrieveKnowledgeBase
return nil
}
valueCustomKnowledgeBase := new(CustomKnowledgeBase)
if err := json.Unmarshal(data, &valueCustomKnowledgeBase); err == nil {
k.typ = "CustomKnowledgeBase"
k.CustomKnowledgeBase = valueCustomKnowledgeBase
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, k)
}
func (k KnowledgeBasesListResponseItem) MarshalJSON() ([]byte, error) {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return json.Marshal(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return json.Marshal(k.CustomKnowledgeBase)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesListResponseItemVisitor interface {
VisitTrieveKnowledgeBase(*TrieveKnowledgeBase) error
VisitCustomKnowledgeBase(*CustomKnowledgeBase) error
}
func (k *KnowledgeBasesListResponseItem) Accept(visitor KnowledgeBasesListResponseItemVisitor) error {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return visitor.VisitTrieveKnowledgeBase(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return visitor.VisitCustomKnowledgeBase(k.CustomKnowledgeBase)
}
return fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesUpdateResponse struct {
TrieveKnowledgeBase *TrieveKnowledgeBase
CustomKnowledgeBase *CustomKnowledgeBase
typ string
}
func (k *KnowledgeBasesUpdateResponse) GetTrieveKnowledgeBase() *TrieveKnowledgeBase {
if k == nil {
return nil
}
return k.TrieveKnowledgeBase
}
func (k *KnowledgeBasesUpdateResponse) GetCustomKnowledgeBase() *CustomKnowledgeBase {
if k == nil {
return nil
}
return k.CustomKnowledgeBase
}
func (k *KnowledgeBasesUpdateResponse) UnmarshalJSON(data []byte) error {
valueTrieveKnowledgeBase := new(TrieveKnowledgeBase)
if err := json.Unmarshal(data, &valueTrieveKnowledgeBase); err == nil {
k.typ = "TrieveKnowledgeBase"
k.TrieveKnowledgeBase = valueTrieveKnowledgeBase
return nil
}
valueCustomKnowledgeBase := new(CustomKnowledgeBase)
if err := json.Unmarshal(data, &valueCustomKnowledgeBase); err == nil {
k.typ = "CustomKnowledgeBase"
k.CustomKnowledgeBase = valueCustomKnowledgeBase
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, k)
}
func (k KnowledgeBasesUpdateResponse) MarshalJSON() ([]byte, error) {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return json.Marshal(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return json.Marshal(k.CustomKnowledgeBase)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", k)
}
type KnowledgeBasesUpdateResponseVisitor interface {
VisitTrieveKnowledgeBase(*TrieveKnowledgeBase) error
VisitCustomKnowledgeBase(*CustomKnowledgeBase) error
}
func (k *KnowledgeBasesUpdateResponse) Accept(visitor KnowledgeBasesUpdateResponseVisitor) error {
if k.typ == "TrieveKnowledgeBase" || k.TrieveKnowledgeBase != nil {
return visitor.VisitTrieveKnowledgeBase(k.TrieveKnowledgeBase)
}
if k.typ == "CustomKnowledgeBase" || k.CustomKnowledgeBase != nil {
return visitor.VisitCustomKnowledgeBase(k.CustomKnowledgeBase)
}
return fmt.Errorf("type %T does not include a non-empty union type", k)
}