@@ -41,6 +41,10 @@ extension Mistral {
41
41
@POST
42
42
@Path ( " chat/completions " )
43
43
public var chatCompletions = Endpoint < RequestBodies . ChatCompletions , ResponseBodies . ChatCompletion , Void > ( )
44
+
45
+ @POST
46
+ @Path ( " embeddings " )
47
+ public var createEmbeddings = Endpoint < RequestBodies . CreateEmbedding , Mistral . Embeddings , Void > ( )
44
48
}
45
49
}
46
50
@@ -121,24 +125,6 @@ extension Mistral.APISpecification {
121
125
}
122
126
}
123
127
124
- extension Mistral {
125
- public struct ChatMessage : Codable , Hashable , Sendable {
126
- public enum Role : String , Codable , Hashable , Sendable {
127
- case system
128
- case user
129
- case assistant
130
- }
131
-
132
- public var role : Role
133
- public var content : String
134
-
135
- public init ( role: Role , content: String ) {
136
- self . role = role
137
- self . content = content
138
- }
139
- }
140
- }
141
-
142
128
extension Mistral . APISpecification . RequestBodies {
143
129
/// https://docs.mistral.ai/api#operation/createChatCompletion
144
130
public struct ChatCompletions : Codable , Hashable , Sendable {
@@ -152,31 +138,18 @@ extension Mistral.APISpecification.RequestBodies {
152
138
}
153
139
}
154
140
155
- extension Mistral . APISpecification . ResponseBodies {
156
- public struct ChatCompletion : Codable , Hashable , Sendable {
157
- public struct Choice : Codable , Hashable , Sendable {
158
- public enum FinishReason : String , Codable , Hashable , Sendable {
159
- case stop = " stop "
160
- case length = " length "
161
- case modelLength = " model_length "
162
- }
163
-
164
- public let index : Int
165
- public let message : Mistral . ChatMessage
166
- public let finishReason : FinishReason
167
- }
141
+ extension Mistral . APISpecification . RequestBodies {
142
+ public struct CreateEmbedding : Codable , Hashable {
143
+ public let model : Mistral . Model
144
+ public let input : [ String ]
145
+ public let encodingFormat : String
168
146
169
- public struct Usage : Codable , Hashable , Sendable {
170
- public let promptTokens : Int
171
- public let completionTokens : Int
172
- public let totalTokens : Int
147
+ init ( input : [ String ] ) {
148
+ self . model = Mistral . Model . mistral_embed
149
+ self . input = input
150
+ self . encodingFormat = " Float "
173
151
}
174
-
175
- public var id : String
176
- public var object : String
177
- public var created : Date
178
- public var model : String
179
- public var choices : [ Choice ]
180
- public let usage : Usage
181
152
}
182
153
}
154
+
155
+
0 commit comments