Skip to content

Commit a3a241f

Browse files
mariofuscojmartisk
authored andcommitted
Bump to LangChain4j 1.4.0
1 parent eebf266 commit a3a241f

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

integration-tests/mcp/src/test/java/io/quarkiverse/langchain4j/mcp/test/McpToolsTestBase.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.quarkiverse.langchain4j.mcp.test;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
45

56
import java.util.Map;
67

@@ -12,6 +13,8 @@
1213

1314
import dev.langchain4j.agent.tool.ToolExecutionRequest;
1415
import dev.langchain4j.agent.tool.ToolSpecification;
16+
import dev.langchain4j.exception.ToolArgumentsException;
17+
import dev.langchain4j.exception.ToolExecutionException;
1518
import dev.langchain4j.mcp.client.McpClient;
1619
import dev.langchain4j.model.chat.request.json.JsonBooleanSchema;
1720
import dev.langchain4j.model.chat.request.json.JsonIntegerSchema;
@@ -87,9 +90,8 @@ public void executeToolWithWrongArgumentType() {
8790
.name("echoString")
8891
.arguments("{\"input\": 1}") // wrong argument type
8992
.build();
90-
String toolExecutionResultString = executor.execute(toolExecutionRequest, null);
91-
assertThat(toolExecutionResultString)
92-
.isEqualTo("There was an error executing the tool. Message: Internal error. Code: -32603");
93+
assertThatThrownBy(() -> executor.execute(toolExecutionRequest, null))
94+
.isInstanceOf(ToolExecutionException.class);
9395
}
9496

9597
@Test
@@ -100,20 +102,18 @@ public void executeNonExistentTool() {
100102
.name("THIS-TOOL-DOES-NOT-EXIST")
101103
.arguments("{\"input\": 1}")
102104
.build();
103-
String toolExecutionResultString = executor.execute(toolExecutionRequest, null);
104-
assertThat(toolExecutionResultString)
105-
.isEqualTo("There was an error executing the tool. "
106-
+ "Message: Invalid tool name: THIS-TOOL-DOES-NOT-EXIST. Code: -32602");
105+
assertThatThrownBy(() -> executor.execute(toolExecutionRequest, null))
106+
.isInstanceOf(ToolArgumentsException.class)
107+
.hasMessageContaining("THIS-TOOL-DOES-NOT-EXIST");
107108
}
108109

109110
@Test
110111
public void executeToolThatThrowsBusinessError() {
111112
ToolProviderResult toolProviderResult = toolProvider.provideTools(null);
112113
ToolExecutor executor = toolProviderResult.toolExecutorByName("error");
113114
ToolExecutionRequest toolExecutionRequest = ToolExecutionRequest.builder().name("error").arguments("{}").build();
114-
String toolExecutionResultString = executor.execute(toolExecutionRequest, null);
115-
assertThat(toolExecutionResultString)
116-
.isEqualTo("There was an error executing the tool. Message: Internal error. Code: -32603");
115+
assertThatThrownBy(() -> executor.execute(toolExecutionRequest, null))
116+
.isInstanceOf(ToolExecutionException.class);
117117
}
118118

119119
@Test
@@ -124,9 +124,8 @@ public void executeToolThatReturnsError() {
124124
.name("errorResponse")
125125
.arguments("{}")
126126
.build();
127-
String toolExecutionResultString = executor.execute(toolExecutionRequest, null);
128-
assertThat(toolExecutionResultString)
129-
.isEqualTo("There was an error executing the tool. The tool returned: This is an actual error");
127+
assertThatThrownBy(() -> executor.execute(toolExecutionRequest, null))
128+
.isInstanceOf(ToolExecutionException.class);
130129
}
131130

132131
@Test

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
<properties>
3737
<quarkus.version>3.20.0</quarkus.version>
3838
<quarkus.extension-processor.version>${quarkus.version}</quarkus.extension-processor.version>
39-
<langchain4j.version>1.3.0</langchain4j.version>
40-
<langchain4j-beta.version>1.3.0-beta9</langchain4j-beta.version>
41-
<langchain4j-community.version>1.2.0-beta8</langchain4j-community.version>
42-
<langchain4j-embeddings.version>1.3.0-beta9</langchain4j-embeddings.version>
39+
<langchain4j.version>1.4.0</langchain4j.version>
40+
<langchain4j-beta.version>1.4.0-beta10</langchain4j-beta.version>
41+
<langchain4j-community.version>1.3.0-beta9</langchain4j-community.version>
42+
<langchain4j-embeddings.version>1.4.0-beta10</langchain4j-embeddings.version>
4343
<quarkus-antora.version>2.2.0</quarkus-antora.version>
4444
<quarkus-poi.version>2.0.4</quarkus-poi.version> <!-- we need to use this version because langchain4j uses POI 5.2.3 instead of 5.2.5 and the substitution needed is different in the two versions -->
4545
<assertj.version>3.27.3</assertj.version>

0 commit comments

Comments
 (0)