@@ -18,56 +18,6 @@ type ProviderSettings struct {
18
18
Properties map [string ]interface {} `json:"properties"`
19
19
}
20
20
21
- // getProviderSettings reads and resolves provider settings by provider ID and option value
22
- func getProviderSettings (providerID , optionValue , locale string ) (* ProviderSettings , error ) {
23
- // Default locale to "en" if empty
24
- if locale == "" {
25
- locale = "en"
26
- }
27
-
28
- // Get the specific provider using KB API
29
- provider , err := kb .GetProviderWithLanguage ("embedding" , providerID , locale )
30
- if err != nil {
31
- return nil , fmt .Errorf ("failed to get provider %s: %v" , providerID , err )
32
- }
33
-
34
- // Find the target option
35
- targetOption , found := provider .GetOption (optionValue )
36
- if ! found {
37
- return nil , fmt .Errorf ("option not found: %s for provider %s" , optionValue , providerID )
38
- }
39
-
40
- // Extract settings from option properties
41
- settings := & ProviderSettings {
42
- Properties : make (map [string ]interface {}),
43
- }
44
-
45
- // Copy all properties
46
- if targetOption .Properties != nil {
47
- for key , value := range targetOption .Properties {
48
- settings .Properties [key ] = value
49
- }
50
- }
51
-
52
- // Extract dimension
53
- if dim , ok := targetOption .Properties ["dimensions" ]; ok {
54
- if dimInt , ok := dim .(int ); ok {
55
- settings .Dimension = dimInt
56
- } else if dimFloat , ok := dim .(float64 ); ok {
57
- settings .Dimension = int (dimFloat )
58
- }
59
- }
60
-
61
- // Extract connector
62
- if connector , ok := targetOption .Properties ["connector" ]; ok {
63
- if connStr , ok := connector .(string ); ok {
64
- settings .Connector = connStr
65
- }
66
- }
67
-
68
- return settings , nil
69
- }
70
-
71
21
// CreateCollection creates a new collection
72
22
func CreateCollection (c * gin.Context ) {
73
23
var req CreateCollectionRequest
@@ -396,3 +346,53 @@ func validateUpdateCollectionMetadataRequest(req *UpdateCollectionMetadataReques
396
346
397
347
return nil
398
348
}
349
+
350
+ // getProviderSettings reads and resolves provider settings by provider ID and option value
351
+ func getProviderSettings (providerID , optionValue , locale string ) (* ProviderSettings , error ) {
352
+ // Default locale to "en" if empty
353
+ if locale == "" {
354
+ locale = "en"
355
+ }
356
+
357
+ // Get the specific provider using KB API
358
+ provider , err := kb .GetProviderWithLanguage ("embedding" , providerID , locale )
359
+ if err != nil {
360
+ return nil , fmt .Errorf ("failed to get provider %s: %v" , providerID , err )
361
+ }
362
+
363
+ // Find the target option
364
+ targetOption , found := provider .GetOption (optionValue )
365
+ if ! found {
366
+ return nil , fmt .Errorf ("option not found: %s for provider %s" , optionValue , providerID )
367
+ }
368
+
369
+ // Extract settings from option properties
370
+ settings := & ProviderSettings {
371
+ Properties : make (map [string ]interface {}),
372
+ }
373
+
374
+ // Copy all properties
375
+ if targetOption .Properties != nil {
376
+ for key , value := range targetOption .Properties {
377
+ settings .Properties [key ] = value
378
+ }
379
+ }
380
+
381
+ // Extract dimension
382
+ if dim , ok := targetOption .Properties ["dimensions" ]; ok {
383
+ if dimInt , ok := dim .(int ); ok {
384
+ settings .Dimension = dimInt
385
+ } else if dimFloat , ok := dim .(float64 ); ok {
386
+ settings .Dimension = int (dimFloat )
387
+ }
388
+ }
389
+
390
+ // Extract connector
391
+ if connector , ok := targetOption .Properties ["connector" ]; ok {
392
+ if connStr , ok := connector .(string ); ok {
393
+ settings .Connector = connStr
394
+ }
395
+ }
396
+
397
+ return settings , nil
398
+ }
0 commit comments