quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

quarkus-langchain4j-workshop/step-04 does not work with Ollama #43987

Closed jordensy closed 3 weeks ago

jordensy commented 3 weeks ago

Describe the bug

I am doing the https://github.com/cescoffier/quarkus-langchain4j-workshop But I got stuck on step 04

Since I do not have an OPENAI KEY I am using this with Ollama.

I have:

io.quarkus.platform 3.15.1
io.quarkiverse.langchain4j 0.20.3
Java 21

When I use @SessionScoped I get an error this interface is not Serializable and that it needs to be a concrete class

@SessionScoped
@RegisterAiService
public interface CustomerSupportService extends Serializable {

          Multi<String> chat(@UserMessage String userMessage);
}

I couldn't fine a proper solution so I disabled the CDI inspection for this error But then I get below error:

2024-10-21 10:13:27,446 WARN  [io.qua.lan.dep.JandexUtil] (build-19) 'java.io.Serializable' used for creating an AiService is not an interface. Attempting to create an AiService using this class will fail
2024-10-21 10:13:27,491 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
2024-10-21 10:13:27,943 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkiverse.langchain4j.deployment.AiServicesProcessor#handleAiServices threw an exception: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.name()" because "directSubInterface" is null
        at io.quarkiverse.langchain4j.deployment.JandexUtil.getAllSuperinterfaces(JandexUtil.java:54)
        at io.quarkiverse.langchain4j.deployment.AiServicesProcessor.handleAiServices(AiServicesProcessor.java:876)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:354)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:272)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:62)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:89)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:428)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:55)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkiverse.langchain4j.deployment.AiServicesProcessor#handleAiServices threw an exception: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.name()" because "directSubInterface" is null
        at io.quarkiverse.langchain4j.deployment.JandexUtil.getAllSuperinterfaces(JandexUtil.java:54)
        at io.quarkiverse.langchain4j.deployment.AiServicesProcessor.handleAiServices(AiServicesProcessor.java:876)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)

        at io.quarkus.builder.Execution.run(Execution.java:124)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:161)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:350)
        ... 9 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.jboss.jandex.ClassInfo.name()" because "directSubInterface" is null
        at io.quarkiverse.langchain4j.deployment.JandexUtil.getAllSuperinterfaces(JandexUtil.java:54)
        at io.quarkiverse.langchain4j.deployment.AiServicesProcessor.handleAiServices(AiServicesProcessor.java:876)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:1583)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)

Expected behavior

the only difference between the official workshop POM and mine is:

so is the issue only when using Ollama?

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

21.0.1" 2023-10-17 LTS

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

mvn plugin 3.13.0 quarkus-mvn 3.15.1

Additional information

No response

geoand commented 3 weeks ago

Can you please report this to https://github.com/quarkiverse/quarkus-langchain4j?

Thanks!