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