Skip to content

Commit

Permalink
Fix @coderabbitai review
Browse files Browse the repository at this point in the history
  • Loading branch information
isontheline committed Aug 7, 2024
1 parent 5939170 commit e0591a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions backend/src/main/java/ai/dragon/util/ChatMessageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static String singleTextFrom(ChatMessage message) {
}
return sb.toString();
}

public static String singleTextFrom(OpenAiCompletionRequest request) {
Object prompt = request.getPrompt();
if (prompt instanceof String stringPrompt) {
Expand Down Expand Up @@ -77,14 +77,16 @@ public static Optional<ChatMessage> convertToChatMessage(OpenAiCompletionMessage

private static List<Content> contentsListFrom(List<Map<String, Object>> content) {
List<Content> contents = new ArrayList<>();
content.forEach(contentItem -> {
String type = (String) contentItem.get("type");
if (type == null) {
LOGGER.error("Content part must have a type field!");
return;
}
contents.add(createContent(type, contentItem));
});
if (content != null) {
content.forEach(contentItem -> {
String type = (String) contentItem.get("type");
if (type == null) {
LOGGER.error("Content part must have a type field!");
return;
}
contents.add(createContent(type, contentItem));
});
}
return contents;
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/ai/dragon/util/DataUrlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static String getImageType(String base64String) {

public static String convertFileToDataImageBase64(File file) throws IOException {
String mimeType = Files.probeContentType(file.toPath());
return convertFileToDataImageBase64(file, mimeType);
return convertFileToDataImageBase64(file, mimeType != null ? mimeType : "application/octet-stream");
}

public static String convertFileToDataImageBase64(File file, String mimeType) throws IOException {
Expand Down

0 comments on commit e0591a2

Please sign in to comment.