Skip to content

Commit 295eadd

Browse files
committed
bla
1 parent 6fc76b7 commit 295eadd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWithPlainFunctionBeanIT.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.springframework.ai.chat.model.ChatResponse;
3333
import org.springframework.ai.chat.model.Generation;
3434
import org.springframework.ai.chat.prompt.Prompt;
35+
import org.springframework.ai.model.function.FunctionCallingOptions;
36+
import org.springframework.ai.model.function.FunctionCallingOptionsBuilder.PortableFunctionCallingOptions;
3537
import org.springframework.ai.openai.OpenAiChatModel;
3638
import org.springframework.ai.openai.OpenAiChatOptions;
3739
import org.springframework.ai.openai.api.OpenAiApi.ChatModel;
@@ -103,6 +105,31 @@ void functionCallWithPortableFunctionCallingOptions() {
103105
});
104106
}
105107

108+
@Test
109+
void functionCallWithPortableFunctionCallingOptions2() {
110+
contextRunner
111+
.withPropertyValues("spring.ai.openai.chat.options.model=" + ChatModel.GPT_4_O_MINI.getName(),
112+
"spring.ai.openai.chat.options.temperature=0.1")
113+
.run(context -> {
114+
115+
OpenAiChatModel chatModel = context.getBean(OpenAiChatModel.class);
116+
117+
// Test weatherFunction
118+
UserMessage userMessage = new UserMessage(
119+
"What's the weather like in San Francisco, Tokyo, and Paris?");
120+
121+
PortableFunctionCallingOptions functionOptions = FunctionCallingOptions.builder()
122+
.withFunction("weatherFunction")
123+
.build();
124+
125+
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage), functionOptions));
126+
127+
logger.info("Response: {}", response.getResult().getOutput().getContent());
128+
129+
assertThat(response.getResult().getOutput().getContent()).contains("30", "10", "15");
130+
});
131+
}
132+
106133
@Test
107134
void streamFunctionCallTest() {
108135
contextRunner

0 commit comments

Comments
 (0)