20
20
21
21
import org .springframework .ai .mistralai .MistralAiChatModel ;
22
22
import org .springframework .ai .mistralai .MistralAiEmbeddingModel ;
23
+ import org .springframework .ai .mistralai .moderation .MistralAiModerationModel ;
23
24
import org .springframework .boot .autoconfigure .AutoConfigurations ;
24
25
import org .springframework .boot .test .context .runner .ApplicationContextRunner ;
25
26
29
30
* Unit Tests for Mistral AI auto-configurations conditional enabling of models.
30
31
*
31
32
* @author Ilayaperumal Gopinathan
33
+ * @author Ricken Bazolo
32
34
*/
33
35
public class MistralModelConfigurationTests {
34
36
@@ -43,6 +45,8 @@ void chatModelActivation() {
43
45
assertThat (context .getBeansOfType (MistralAiChatModel .class )).isNotEmpty ();
44
46
assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
45
47
assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
48
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isEmpty ();
49
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isEmpty ();
46
50
});
47
51
48
52
this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiChatAutoConfiguration .class ))
@@ -61,6 +65,8 @@ void chatModelActivation() {
61
65
assertThat (context .getBeansOfType (MistralAiChatModel .class )).isNotEmpty ();
62
66
assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
63
67
assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
68
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isEmpty ();
69
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isEmpty ();
64
70
});
65
71
}
66
72
@@ -84,4 +90,42 @@ void embeddingModelActivation() {
84
90
});
85
91
}
86
92
93
+ @ Test
94
+ void moderationModelActivation () {
95
+ this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiModerationAutoConfiguration .class ))
96
+ .run (context -> {
97
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isNotEmpty ();
98
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isNotEmpty ();
99
+ assertThat (context .getBeansOfType (MistralAiChatModel .class )).isEmpty ();
100
+ assertThat (context .getBeansOfType (MistralAiChatProperties .class )).isEmpty ();
101
+ assertThat (context .getBeansOfType (MistralAiEmbeddingProperties .class )).isEmpty ();
102
+ assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
103
+ });
104
+
105
+ this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiModerationAutoConfiguration .class ))
106
+ .withPropertyValues ("spring.ai.model.moderation=none" )
107
+ .run (context -> {
108
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isEmpty ();
109
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isEmpty ();
110
+ });
111
+
112
+ this .contextRunner .withConfiguration (AutoConfigurations .of (MistralAiModerationAutoConfiguration .class ))
113
+ .withPropertyValues ("spring.ai.model.moderation=mistral" )
114
+ .run (context -> {
115
+ assertThat (context .getBeansOfType (MistralAiModerationProperties .class )).isNotEmpty ();
116
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isNotEmpty ();
117
+ });
118
+
119
+ this .contextRunner
120
+ .withConfiguration (AutoConfigurations .of (MistralAiChatAutoConfiguration .class ,
121
+ MistralAiEmbeddingAutoConfiguration .class , MistralAiModerationAutoConfiguration .class ))
122
+ .withPropertyValues ("spring.ai.model.chat=none" , "spring.ai.model.embedding=none" ,
123
+ "spring.ai.model.moderation=mistral" )
124
+ .run (context -> {
125
+ assertThat (context .getBeansOfType (MistralAiModerationModel .class )).isNotEmpty ();
126
+ assertThat (context .getBeansOfType (MistralAiEmbeddingModel .class )).isEmpty ();
127
+ assertThat (context .getBeansOfType (MistralAiChatModel .class )).isEmpty ();
128
+ });
129
+ }
130
+
87
131
}
0 commit comments