Skip to content

Commit 082e00d

Browse files
Merge pull request #365 from vorburger:flip-equals-in-LangChain4j
PiperOrigin-RevId: 797342184
2 parents 7fb70cb + d5c98ad commit 082e00d

File tree

1 file changed

+8
-11
lines changed
  • contrib/langchain4j/src/main/java/com/google/adk/models/langchain4j

1 file changed

+8
-11
lines changed

contrib/langchain4j/src/main/java/com/google/adk/models/langchain4j/LangChain4j.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,11 @@ private ChatRequest toChatRequest(LlmRequest llmRequest) {
224224
.mode()
225225
.ifPresent(
226226
functionMode -> {
227-
if (functionMode
228-
.knownEnum()
229-
.equals(FunctionCallingConfigMode.Known.AUTO)) {
227+
if (FunctionCallingConfigMode.Known.AUTO.equals(
228+
functionMode.knownEnum())) {
230229
requestBuilder.toolChoice(ToolChoice.AUTO);
231-
} else if (functionMode
232-
.knownEnum()
233-
.equals(FunctionCallingConfigMode.Known.ANY)) {
230+
} else if (FunctionCallingConfigMode.Known.ANY.equals(
231+
functionMode.knownEnum())) {
234232
// TODO check if it's the correct
235233
// mapping
236234
requestBuilder.toolChoice(ToolChoice.REQUIRED);
@@ -246,9 +244,8 @@ private ChatRequest toChatRequest(LlmRequest llmRequest) {
246244
toolSpecification.name()))
247245
.toList());
248246
});
249-
} else if (functionMode
250-
.knownEnum()
251-
.equals(FunctionCallingConfigMode.Known.NONE)) {
247+
} else if (FunctionCallingConfigMode.Known.NONE.equals(
248+
functionMode.knownEnum())) {
252249
requestBuilder.toolSpecifications(List.of());
253250
}
254251
});
@@ -349,7 +346,7 @@ private List<ChatMessage> toUserOrToolResultMessage(Content content) {
349346
.mimeType(mimeType)
350347
.build());
351348
} else if (mimeType.startsWith("text/")
352-
|| mimeType.equals("application/json")
349+
|| "application/json".equals(mimeType)
353350
|| mimeType.endsWith("+json")
354351
|| mimeType.endsWith("+xml")) {
355352
// TODO are there missing text based mime types?
@@ -454,7 +451,7 @@ private List<ToolSpecification> toToolSpecifications(LlmRequest llmRequest) {
454451
}
455452

456453
private JsonObjectSchema toParameters(Schema schema) {
457-
if (schema.type().isPresent() && schema.type().get().knownEnum().equals(Type.Known.OBJECT)) {
454+
if (schema.type().isPresent() && Type.Known.OBJECT.equals(schema.type().get().knownEnum())) {
458455
return JsonObjectSchema.builder()
459456
.addProperties(toProperties(schema))
460457
.required(schema.required().orElse(List.of()))

0 commit comments

Comments
 (0)