Skip to content

Commit fe501b4

Browse files
committed
feat: improvement
1 parent 34c72a0 commit fe501b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backend/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ OllamaApi.ChatRequest ollamaChatRequest(Prompt prompt, boolean stream) {
101101
|| message.getMessageType() == MessageType.ASSISTANT
102102
|| message.getMessageType() == MessageType.SYSTEM)
103103
.map(m -> {
104-
var messageBuilder = OllamaApi.Message.builder(toRole(m)).withContent(m.getContent());
104+
var messageBuilder = OllamaApi.Message.builder(OllamaChatClient.toRole(m)).withContent(m.getContent());
105105

106106
if (!CollectionUtils.isEmpty(m.getMedia())) {
107107
messageBuilder
108-
.withImages(m.getMedia().stream().map(media -> this.fromMediaData(media.getData())).toList());
108+
.withImages(m.getMedia().stream().map(media -> OllamaChatClient.fromMediaData(media.getData())).toList());
109109
}
110110
return messageBuilder.build();
111111
})
@@ -148,7 +148,7 @@ OllamaApi.ChatRequest ollamaChatRequest(Prompt prompt, boolean stream) {
148148
return requestBuilder.build();
149149
}
150150

151-
private String fromMediaData(Object mediaData) {
151+
private static String fromMediaData(Object mediaData) {
152152
if (mediaData instanceof byte[] bytes) {
153153
return Base64.getEncoder().encodeToString(bytes);
154154
}
@@ -161,7 +161,7 @@ else if (mediaData instanceof String text) {
161161

162162
}
163163

164-
private OllamaApi.Message.Role toRole(Message message) {
164+
private static OllamaApi.Message.Role toRole(Message message) {
165165

166166
switch (message.getMessageType()) {
167167
case USER:

0 commit comments

Comments
 (0)