Skip to content

Commit

Permalink
Merge pull request #1070 from quarkiverse/#685
Browse files Browse the repository at this point in the history
Properly handle Ollama streaming
  • Loading branch information
geoand authored Nov 12, 2024
2 parents 0b5cf23 + 8ad9c26 commit 29d197e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;

import io.quarkiverse.langchain4j.QuarkusJsonCodecFactory;
import io.quarkiverse.langchain4j.auth.ModelAuthProvider;
Expand Down Expand Up @@ -85,7 +86,8 @@ public Object aroundReadFrom(ReaderInterceptorContext context) throws IOExceptio
try {
return context.proceed();
} catch (ClientWebApplicationException e) {
if (e.getCause() instanceof JsonParseException) {
Throwable cause = e.getCause();
if ((cause instanceof JsonParseException) || (cause instanceof MismatchedInputException)) {
if (e.getResponse().getStatus() == 200) {
Object invokedMethod = context.getProperty("org.eclipse.microprofile.rest.client.invokedMethod");
if ((invokedMethod != null) && invokedMethod.toString().contains("OllamaRestApi.streamingChat")) {
Expand Down

0 comments on commit 29d197e

Please sign in to comment.