|
4 | 4 |
|
5 | 5 | import com.sap.ai.sdk.app.services.SpringAiOpenAiService; |
6 | 6 | import com.sap.ai.sdk.foundationmodels.openai.OpenAiModel; |
| 7 | +import java.util.List; |
7 | 8 | import org.junit.jupiter.api.Test; |
| 9 | +import org.springframework.ai.chat.messages.AssistantMessage; |
8 | 10 | import org.springframework.ai.chat.model.ChatResponse; |
9 | 11 |
|
10 | 12 | class SpringAiOpenAiTest { |
@@ -47,25 +49,25 @@ void testToolCallingWithExecution() { |
47 | 49 | assertThat(response.getResult().getOutput().getText()).contains("Potsdam", "Toulouse", "°C"); |
48 | 50 | } |
49 | 51 |
|
50 | | - // @Test |
51 | | - // void testToolCallingWithoutExecution() { |
52 | | - // ChatResponse response = service.toolCalling(false); |
53 | | - // assertThat(response.getResult().getOutput().getText()).contains("Potsdam", "Toulouse", "°C"); |
54 | | - // List<AssistantMessage.ToolCall> toolCalls = response.getResult().getOutput().getToolCalls(); |
55 | | - // assertThat(toolCalls).hasSize(2); |
56 | | - // AssistantMessage.ToolCall toolCall1 = toolCalls.get(0); |
57 | | - // AssistantMessage.ToolCall toolCall2 = toolCalls.get(1); |
58 | | - // assertThat(toolCall1.type()).isEqualTo("function"); |
59 | | - // assertThat(toolCall2.type()).isEqualTo("function"); |
60 | | - // assertThat(toolCall1.name()).isEqualTo("getCurrentWeather"); |
61 | | - // assertThat(toolCall2.name()).isEqualTo("getCurrentWeather"); |
62 | | - // assertThat(toolCall1.arguments()) |
63 | | - // .isEqualTo("{\"arg0\": {\"location\": \"Potsdam\", \"unit\": \"C\"}}"); |
64 | | - // assertThat(toolCall2.arguments()) |
65 | | - // .isEqualTo("{\"arg0\": {\"location\": \"Toulouse\", \"unit\": \"C\"}}"); |
66 | | - // } |
67 | 52 | @Test |
68 | | - void testchatMemory() { |
| 53 | + void testToolCallingWithoutExecution() { |
| 54 | + ChatResponse response = service.toolCalling(false); |
| 55 | + List<AssistantMessage.ToolCall> toolCalls = response.getResult().getOutput().getToolCalls(); |
| 56 | + assertThat(toolCalls).hasSize(2); |
| 57 | + AssistantMessage.ToolCall toolCall1 = toolCalls.get(0); |
| 58 | + AssistantMessage.ToolCall toolCall2 = toolCalls.get(1); |
| 59 | + assertThat(toolCall1.type()).isEqualTo("function"); |
| 60 | + assertThat(toolCall2.type()).isEqualTo("function"); |
| 61 | + assertThat(toolCall1.name()).isEqualTo("getCurrentWeather"); |
| 62 | + assertThat(toolCall2.name()).isEqualTo("getCurrentWeather"); |
| 63 | + assertThat(toolCall1.arguments()) |
| 64 | + .isEqualTo("{\"arg0\": {\"location\": \"Potsdam\", \"unit\": \"C\"}}"); |
| 65 | + assertThat(toolCall2.arguments()) |
| 66 | + .isEqualTo("{\"arg0\": {\"location\": \"Toulouse\", \"unit\": \"C\"}}"); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + void testChatMemory() { |
69 | 71 | ChatResponse response = service.chatMemory(); |
70 | 72 | assertThat(response).isNotNull(); |
71 | 73 | String text = response.getResult().getOutput().getText(); |
|
0 commit comments