Skip to content

Commit fcaf14e

Browse files
authored
[hotfix] Fix ollama4j can't deserialize tool call message from Ollama v0.12.10 and above. (#333)
1 parent 44252e8 commit fcaf14e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

integrations/chat-models/ollama/src/main/java/org/apache/flink/agents/integrations/chatmodels/ollama/OllamaChatModelConnection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
package org.apache.flink.agents.integrations.chatmodels.ollama;
2020

2121
import com.fasterxml.jackson.core.type.TypeReference;
22+
import com.fasterxml.jackson.databind.DeserializationFeature;
2223
import com.fasterxml.jackson.databind.ObjectMapper;
2324
import io.github.ollama4j.OllamaAPI;
2425
import io.github.ollama4j.exceptions.RoleNotFoundException;
2526
import io.github.ollama4j.models.chat.OllamaChatMessage;
2627
import io.github.ollama4j.models.chat.OllamaChatMessageRole;
2728
import io.github.ollama4j.models.chat.OllamaChatResult;
2829
import io.github.ollama4j.tools.Tools;
30+
import io.github.ollama4j.utils.Utils;
2931
import org.apache.flink.agents.api.chat.messages.ChatMessage;
3032
import org.apache.flink.agents.api.chat.messages.MessageRole;
3133
import org.apache.flink.agents.api.chat.model.BaseChatModelConnection;
@@ -79,6 +81,7 @@ public class OllamaChatModelConnection extends BaseChatModelConnection {
7981
public OllamaChatModelConnection(
8082
ResourceDescriptor descriptor, BiFunction<String, ResourceType, Resource> getResource) {
8183
super(descriptor, getResource);
84+
Utils.getObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
8285
String endpoint = descriptor.getArgument("endpoint");
8386
if (endpoint == null || endpoint.isEmpty()) {
8487
throw new IllegalArgumentException("endpoint should not be null or empty.");

0 commit comments

Comments
 (0)