File tree Expand file tree Collapse file tree 5 files changed +26
-12
lines changed
models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat
spring-ai-spring-boot-autoconfigure/src
main/java/org/springframework/ai/autoconfigure
test/java/org/springframework/ai/autoconfigure Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ void streamCompletenessTestWithChatResponse() throws InterruptedException {
130
130
});
131
131
chatResponseFlux .subscribe ();
132
132
assertThat (latch .await (120 , TimeUnit .SECONDS )).isTrue ();
133
- assertThat (answer ).contains ("the 1st " );
133
+ assertThat (answer ).contains ("1st " );
134
134
}
135
135
136
136
@ Test
@@ -153,7 +153,7 @@ void ensureChatResponseAsContentDoesNotSwallowBlankSpace() throws InterruptedExc
153
153
});
154
154
chatResponseFlux .subscribe ();
155
155
assertThat (latch .await (120 , TimeUnit .SECONDS )).isTrue ();
156
- assertThat (answer ).contains ("the 1st " );
156
+ assertThat (answer ).contains ("1st " );
157
157
}
158
158
159
159
@ Test
Original file line number Diff line number Diff line change 24
24
import org .springframework .ai .chat .observation .ChatModelPromptContentObservationFilter ;
25
25
import org .springframework .beans .factory .ObjectProvider ;
26
26
import org .springframework .boot .autoconfigure .AutoConfiguration ;
27
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
27
28
import org .springframework .boot .autoconfigure .condition .ConditionalOnClass ;
28
29
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
29
30
import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
@@ -46,7 +47,7 @@ public class ChatObservationAutoConfiguration {
46
47
47
48
@ Bean
48
49
@ ConditionalOnMissingBean
49
- @ ConditionalOnClass (MeterRegistry .class )
50
+ @ ConditionalOnBean (MeterRegistry .class )
50
51
ChatModelMeterObservationHandler chatModelMeterObservationHandler (ObjectProvider <MeterRegistry > meterRegistry ) {
51
52
return new ChatModelMeterObservationHandler (meterRegistry .getObject ());
52
53
}
Original file line number Diff line number Diff line change 20
20
import org .springframework .ai .embedding .observation .EmbeddingModelMeterObservationHandler ;
21
21
import org .springframework .beans .factory .ObjectProvider ;
22
22
import org .springframework .boot .autoconfigure .AutoConfiguration ;
23
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
23
24
import org .springframework .boot .autoconfigure .condition .ConditionalOnClass ;
24
25
import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
25
26
import org .springframework .context .annotation .Bean ;
@@ -37,7 +38,7 @@ public class EmbeddingObservationAutoConfiguration {
37
38
38
39
@ Bean
39
40
@ ConditionalOnMissingBean
40
- @ ConditionalOnClass (MeterRegistry .class )
41
+ @ ConditionalOnBean (MeterRegistry .class )
41
42
EmbeddingModelMeterObservationHandler embeddingModelMeterObservationHandler (
42
43
ObjectProvider <MeterRegistry > meterRegistry ) {
43
44
return new EmbeddingModelMeterObservationHandler (meterRegistry .getObject ());
Original file line number Diff line number Diff line change 33
33
class ChatObservationAutoConfigurationTests {
34
34
35
35
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner ()
36
- .withConfiguration (AutoConfigurations .of (ChatObservationAutoConfiguration .class ))
37
- .withBean (CompositeMeterRegistry .class );
36
+ .withConfiguration (AutoConfigurations .of (ChatObservationAutoConfiguration .class ));
38
37
39
38
@ Test
40
- void meterObservationHandler () {
41
- contextRunner .run (context -> {
39
+ void meterObservationHandlerEnabled () {
40
+ contextRunner .withBean ( CompositeMeterRegistry . class ). run (context -> {
42
41
assertThat (context ).hasSingleBean (ChatModelMeterObservationHandler .class );
43
42
});
44
43
}
45
44
45
+ @ Test
46
+ void meterObservationHandlerDisabled () {
47
+ contextRunner .run (context -> {
48
+ assertThat (context ).doesNotHaveBean (ChatModelMeterObservationHandler .class );
49
+ });
50
+ }
51
+
46
52
@ Test
47
53
void promptFilterDefault () {
48
54
contextRunner .run (context -> {
Original file line number Diff line number Diff line change 31
31
class EmbeddingObservationAutoConfigurationTests {
32
32
33
33
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner ()
34
- .withConfiguration (AutoConfigurations .of (EmbeddingObservationAutoConfiguration .class ))
35
- .withBean (CompositeMeterRegistry .class );
34
+ .withConfiguration (AutoConfigurations .of (EmbeddingObservationAutoConfiguration .class ));
36
35
37
36
@ Test
38
- void meterObservationHandler () {
39
- contextRunner .run (context -> {
37
+ void meterObservationHandlerEnabled () {
38
+ contextRunner .withBean ( CompositeMeterRegistry . class ). run (context -> {
40
39
assertThat (context ).hasSingleBean (EmbeddingModelMeterObservationHandler .class );
41
40
});
42
41
}
43
42
43
+ @ Test
44
+ void meterObservationHandlerDisabled () {
45
+ contextRunner .run (context -> {
46
+ assertThat (context ).doesNotHaveBean (EmbeddingModelMeterObservationHandler .class );
47
+ });
48
+ }
49
+
44
50
}
You can’t perform that action at this time.
0 commit comments