quarkiverse / quarkus-langchain4j

Quarkus Langchain4j extension
https://docs.quarkiverse.io/quarkus-langchain4j/dev/index.html
Apache License 2.0
149 stars 89 forks source link

Improve the error message in the DevUI when the call times out #315

Closed geoand closed 9 months ago

geoand commented 9 months ago

When for example an image generation request from the DevUI times out, we get this error:

Screenshot from 2024-02-21 11-46-05

The exception thrown is:

2024-02-21 11:44:10,150 ERROR [io.qua.dev.run.jso.JsonRpcCodec] (executor-thread-1) Error in JsonRPC Call: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at io.smallrye.mutiny.unchecked.UncheckedSupplier.lambda$toSupplier$0(UncheckedSupplier.java:45)
        at io.smallrye.context.impl.wrappers.SlowContextualSupplier.get(SlowContextualSupplier.java:21)
        at io.smallrye.mutiny.operators.uni.builders.UniCreateFromItemSupplier.subscribe(UniCreateFromItemSupplier.java:28)
        at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
        at io.smallrye.mutiny.operators.uni.UniRunSubscribeOn.lambda$subscribe$0(UniRunSubscribeOn.java:27)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.devui.runtime.comms.JsonRpcRouter.lambda$invoke$0(JsonRpcRouter.java:98)
        at io.smallrye.mutiny.unchecked.UncheckedSupplier.lambda$toSupplier$0(UncheckedSupplier.java:41)
        ... 11 more
Caused by: jakarta.ws.rs.ProcessingException: The timeout of 2000 ms has been exceeded when getting a connection to api.openai.com:443
        at org.jboss.resteasy.reactive.client.impl.InvocationBuilderImpl.unwrap(InvocationBuilderImpl.java:223)
        at org.jboss.resteasy.reactive.client.impl.InvocationBuilderImpl.method(InvocationBuilderImpl.java:339)
        at io.quarkiverse.langchain4j.openai.OpenAiRestApi$$QuarkusRestClientInterface.blockingImagesGenerations(Unknown Source)
        at io.quarkiverse.langchain4j.openai.QuarkusOpenAiClient$9.execute(QuarkusOpenAiClient.java:462)
        at io.quarkiverse.langchain4j.openai.QuarkusOpenAiClient$9.execute(QuarkusOpenAiClient.java:459)
        at io.quarkiverse.langchain4j.openai.QuarkusOpenAiImageModel.generate(QuarkusOpenAiImageModel.java:71)
        at io.quarkiverse.langchain4j.openai.runtime.devui.OpenAiImagesJsonRPCService.generate(OpenAiImagesJsonRPCService.java:49)
        at io.quarkiverse.langchain4j.openai.runtime.devui.OpenAiImagesJsonRPCService_ClientProxy.generate(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 14 more
Caused by: io.vertx.core.impl.NoStackTraceTimeoutException: The timeout of 2000 ms has been exceeded when getting a connection to api.openai.com:443
geoand commented 9 months ago

I am also assuming that something similar happens if other errors are thrown

jmartisk commented 9 months ago

Yeah but what would you suggest to show? This is the full message that the Dev UI receives from the JSON-RPC call. Hmm, maybe the JSON-RPC endpoint could catch the exception and try to rethrow it as another exception with some meaningful message. I'll see what I can do