Open maxandersen opened 1 month ago
Are you using the latest version?
//DEPS io.quarkus:quarkus-bom:${quarkus.version:3.15.1}@pom
//DEPS io.quarkiverse.langchain4j:quarkus-langchain4j-openai:0.19.0.CR3
latest i could find in maven central at least.
Interesting, I remember fixing some related issues recently.
I'll have a look tomorrow
So indeed this is an issue with how upstream LangChain4j creates the json schema
@gsmet has run into similar so we probably need to rethink the whole approach
It is also related to #671
FWIW, using Map
throws an error in 0.20.0 due to LangChain4j changes:
Caused by: dev.langchain4j.exception.IllegalConfigurationException: Illegal method return type: java.util.Map<java.lang.String, java.lang.Integer>
at dev.langchain4j.exception.IllegalConfigurationException.illegalConfiguration(IllegalConfigurationException.java:12)
at dev.langchain4j.service.output.ServiceOutputParser.validateJsonStructure(ServiceOutputParser.java:135)
at dev.langchain4j.service.output.ServiceOutputParser.outputFormatInstructions(ServiceOutputParser.java:125)
at io.quarkiverse.langchain4j.runtime.QuarkusServiceOutputParser.outputFormatInstructions(QuarkusServiceOutputParser.java:19)
at io.quarkiverse.langchain4j.deployment.AiServicesProcessor.gatherMethodMetadata(AiServicesProcessor.java:1098)
at io.quarkiverse.langchain4j.deployment.AiServicesProcessor.handleAiServices(AiServicesProcessor.java:932)
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:2516)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
at java.base/java.lang.Thread.run(Thread.java:1583)
at org.jboss.threads.JBossThread.run(JBossThread.java:483)
if one use List, Set, Map etc. as return types the ask to genAI is:
You must answer strictly in the following JSON format: {\n}
- it should have the the json structure.This fails:
but if change it to the following it works:
I would think it should be possible to handle - and if not, throw build error it needs to be a non-collection java type?