|
18 | 18 | import io.micrometer.observation.ObservationRegistry; |
19 | 19 | import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; |
20 | 20 | import org.springframework.ai.chat.observation.ChatModelObservationConvention; |
| 21 | +import org.springframework.ai.embedding.observation.EmbeddingModelObservationConvention; |
21 | 22 | import org.springframework.ai.minimax.MiniMaxChatModel; |
22 | 23 | import org.springframework.ai.minimax.MiniMaxEmbeddingModel; |
23 | 24 | import org.springframework.ai.minimax.api.MiniMaxApi; |
@@ -80,13 +81,20 @@ public MiniMaxChatModel miniMaxChatModel(MiniMaxConnectionProperties commonPrope |
80 | 81 | matchIfMissing = true) |
81 | 82 | public MiniMaxEmbeddingModel miniMaxEmbeddingModel(MiniMaxConnectionProperties commonProperties, |
82 | 83 | MiniMaxEmbeddingProperties embeddingProperties, RestClient.Builder restClientBuilder, |
83 | | - RetryTemplate retryTemplate, ResponseErrorHandler responseErrorHandler) { |
| 84 | + RetryTemplate retryTemplate, ResponseErrorHandler responseErrorHandler, |
| 85 | + ObjectProvider<ObservationRegistry> observationRegistry, |
| 86 | + ObjectProvider<EmbeddingModelObservationConvention> observationConvention) { |
84 | 87 |
|
85 | 88 | var miniMaxApi = miniMaxApi(embeddingProperties.getBaseUrl(), commonProperties.getBaseUrl(), |
86 | 89 | embeddingProperties.getApiKey(), commonProperties.getApiKey(), restClientBuilder, responseErrorHandler); |
87 | 90 |
|
88 | | - return new MiniMaxEmbeddingModel(miniMaxApi, embeddingProperties.getMetadataMode(), |
89 | | - embeddingProperties.getOptions(), retryTemplate); |
| 91 | + var embeddingModel = new MiniMaxEmbeddingModel(miniMaxApi, embeddingProperties.getMetadataMode(), |
| 92 | + embeddingProperties.getOptions(), retryTemplate, |
| 93 | + observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP)); |
| 94 | + |
| 95 | + observationConvention.ifAvailable(embeddingModel::setObservationConvention); |
| 96 | + |
| 97 | + return embeddingModel; |
90 | 98 | } |
91 | 99 |
|
92 | 100 | private MiniMaxApi miniMaxApi(String baseUrl, String commonBaseUrl, String apiKey, String commonApiKey, |
|
0 commit comments