Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI services that could not be resolved by interface name #6838

Closed
aldettinger opened this issue Dec 3, 2024 · 0 comments
Closed

AI services that could not be resolved by interface name #6838

aldettinger opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aldettinger
Copy link
Contributor

aldettinger commented Dec 3, 2024

Bug description

When trying to user a Quarkus LangChain4j AI service by interface type as below:

@RegisterAiService
@ApplicationScoped
public interface MyAiService {

    @UserMessage("My Prompt")
    @Handler
    String chat(String question);
}
...
@Override
public void configure() {
  from("...")
    .bean(MyAiService.class);
}

Then, the stack trace below is produced:

java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:628)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:712)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:305)
	at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:241)
	at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:595)
	at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:645)
	... 1 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.apache.camel.FailedToCreateRouteException: Failed to create route route2 at: >>> Bean[org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface] <<< in route: Route(route2)[From[direct:ai-service-should-be-resolvable-by... because of The bean is an interface type: interface org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface. Interfaces are only supported to lookup in the Camel registry for a single instance of such type. Otherwise the bean must be a class type.
	at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:49)
	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot548544167.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot548544167.deploy(Unknown Source)
	... 8 more
Caused by: java.lang.RuntimeException: org.apache.camel.FailedToCreateRouteException: Failed to create route route2 at: >>> Bean[org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface] <<< in route: Route(route2)[From[direct:ai-service-should-be-resolvable-by... because of The bean is an interface type: interface org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface. Interfaces are only supported to lookup in the Camel registry for a single instance of such type. Otherwise the bean must be a class type.
	at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:65)
	at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:47)
	... 10 more
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route2 at: >>> Bean[org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface] <<< in route: Route(route2)[From[direct:ai-service-should-be-resolvable-by... because of The bean is an interface type: interface org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface. Interfaces are only supported to lookup in the Camel registry for a single instance of such type. Otherwise the bean must be a class type.
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:235)
	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:86)
	at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:726)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:592)
	at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2433)
	at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:195)
	at org.apache.camel.support.service.BaseService.init(BaseService.java:85)
	at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2068)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2087)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:211)
	at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:91)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:123)
	at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:137)
	at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
	... 11 more
Caused by: java.lang.IllegalArgumentException: The bean is an interface type: interface org.apache.camel.quarkus.component.langchain.it.AiServiceResolvedByInterface. Interfaces are only supported to lookup in the Camel registry for a single instance of such type. Otherwise the bean must be a class type.
	at org.apache.camel.component.bean.DefaultBeanProcessorFactory.createBeanProcessor(DefaultBeanProcessorFactory.java:161)
	at org.apache.camel.reifier.BeanReifier.createProcessor(BeanReifier.java:49)
	at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:893)
	at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:629)
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:231)
	... 26 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants