File tree Expand file tree Collapse file tree
OpenAIService/Configuration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ public actor TemporaryUSearch: VectorStore {
1818 let index : USearchIndex
1919 var documents : [ USearchLabel : LabeledDocument ] = [ : ]
2020
21- public init ( identifier: String ) {
21+ public init ( identifier: String , dimensions : Int = 1536 /* text-embedding-ada-002 */ ) {
2222 self . identifier = calculateMD5Hash ( identifier)
2323 index = . init(
2424 metric: . IP,
25- dimensions: 1536 , // text-embedding-ada-002
25+ dimensions: UInt32 ( dimensions ) ,
2626 connectivity: 16 ,
2727 quantization: . F32
2828 )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ public protocol EmbeddingConfiguration {
77 var model : EmbeddingModel { get }
88 var apiKey : String { get }
99 var maxToken : Int { get }
10+ var dimensions : Int { get }
1011}
1112
1213public extension EmbeddingConfiguration {
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ public struct UserPreferenceEmbeddingConfiguration: EmbeddingConfiguration {
1414 model. info. maxTokens
1515 }
1616
17+ #warning("TODO: Support different dimensions.")
18+ public var dimensions : Int {
19+ 1536 // text-embedding-ada-002
20+ }
21+
1722 public init ( ) { }
1823}
1924
@@ -24,15 +29,18 @@ public class OverridingEmbeddingConfiguration<
2429 public var modelId : String ?
2530 public var model : EmbeddingModel ?
2631 public var maxTokens : Int ?
32+ public var dimensions : Int ?
2733
2834 public init (
2935 modelId: String ? = nil ,
3036 model: EmbeddingModel ? = nil ,
31- maxTokens: Int ? = nil
37+ maxTokens: Int ? = nil ,
38+ dimensions: Int ? = nil
3239 ) {
3340 self . modelId = modelId
3441 self . model = model
3542 self . maxTokens = maxTokens
43+ self . dimensions = dimensions
3644 }
3745 }
3846
@@ -56,5 +64,9 @@ public class OverridingEmbeddingConfiguration<
5664 public var maxToken : Int {
5765 overriding. maxTokens ?? configuration. maxToken
5866 }
67+
68+ public var dimensions : Int {
69+ overriding. dimensions ?? configuration. dimensions
70+ }
5971}
6072
You can’t perform that action at this time.
0 commit comments