You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Loop through all available models and print their ID. The id can be used to specify the model when creating chat completions
78
-
for (Model model : models) {
79
-
System.out.println(model.getId());
80
-
}
81
+
for(
82
+
Model model :models){
83
+
System.out.
84
+
85
+
println(model.getId());
86
+
}
81
87
```
82
88
83
89
Example output:
@@ -137,10 +143,41 @@ public class HelloWorld {
137
143
'''
138
144
```
139
145
146
+
## Embeddings
147
+
148
+
```java
149
+
// You can also put the API key in an environment variable called MISTRAL_API_KEY and remove the apiKey parameter given to the MistralClient constructor
150
+
String apiKey ="API_KEY_HERE";
151
+
152
+
// Initialize the client. This should ideally only be done once. The instance should be re-used for multiple requests
* This method is used to create an embedding using the Mistral AI API.
147
+
* The embeddings for the input strings. See the <a href="https://docs.mistral.ai/guides/embeddings/">mistral documentation</a> for more details on embeddings.
148
+
* This is a blocking method.
149
+
*
150
+
* @param request The request to create an embedding. See {@link EmbeddingRequest}.
151
+
* @return The response from the Mistral AI API containing the generated embedding. See {@link EmbeddingResponse}.
152
+
* @throws ConstraintViolationException if the request does not pass validation
153
+
* @throws UnexpectedResponseException if an unexpected response is received from the Mistral AI API
* This method is used to create an embedding using the Mistral AI API.
161
+
* The embeddings for the input strings. See the <a href="https://docs.mistral.ai/guides/embeddings/">mistral documentation</a> for more details on embeddings.
162
+
* This is a non-blocking/asynchronous method.
163
+
*
164
+
* @param request The request to create an embedding. See {@link EmbeddingRequest}.
165
+
* @return A CompletableFuture that will complete with the generated embedding from the Mistral AI API. See {@link EmbeddingResponse}.
166
+
* @throws ConstraintViolationException if the request does not pass validation
167
+
* @throws UnexpectedResponseException if an unexpected response is received from the Mistral AI API
0 commit comments