-
Notifications
You must be signed in to change notification settings - Fork 98
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
Improve tool type support #1047
base: main
Are you sure you want to change the base?
Conversation
…d data from @description annotations to json schema, for llm to better understand how to output data.
This is pretty useful indeed! But given that all this operates on |
@geoand I’m not sure. My thought was that there might always be cases requiring special handling, beyond what upstream supports or offers, and an extension could have its own strategy to address those. On another note, I was trying to add support for Kotlin nullable types to be treated as optional. However, I couldn’t find an easy way to extract that information from reflection on the Java side. Without kotlin-reflect, I assume this isn't possible, whether it’s on Quarkus or upstream. Am I correct? |
That is certainly true, but your changes in this case seem to be applicable to the library as well, no?
I don't really remember this one to TBH, but I am pretty sure your assessment is correct |
Yes, this could be added to the langchain4j upstream library. However, since Codec is being overridden anyway and I got the impression that we wanted to extend QuarkusServiceOutputParser, I assumed this was the correct approach. That said, it might be worth coordinating with upstream on this. On the other hand, this opens up more possibilities for allowing users to define their own OutputParsers. The next step, I’d guess, would be adjusting the deployment to enable users to register their own output parsers, complementing the current parser mechanism. |
Right, I have the feeling that this specific change is warranted for upsteeam.
Right, both things can be true :) |
@geoand I fixed the test, I will leave this pr opened until it is decided what to do with it then. |
Thanks! @langchain4j WDYT about these changed being upstream? |
Yes, I wanted to handle optionality for quite a while now, would be great to have it in upstream! |
@langchain4j @geoand I have couple of issues on my end here still, but in spare time I will try to prepare a pr to upstream then! |
@Tarjei400 great, thank you in advance! Considering that current structured output implementations in Quarkus extension and upstream is different, what will be the scope of the PR? As far as I understand only support for |
🙏 |
@langchain4j Quarkus is using this as codec for mapping :
I see it is deprecated but not sure if favor for what though. But ideally instead of Class<?> it would support Type. On the other hand, what I tried to achieve is to make mapping to POJO from response (Including cases when returnType is a collection or nested collections of objects), but into instruction passing constructed JsonSchema based on class definition - I guess those 2 parts we could fit into upstream? I overloaded QuarkusServiceOutputParser.parse and QuarkusServiceOutputParser.outputFormatInstructions for this just in case. |
@Tarjei400 Please ignore deprecation for now.
Not sure I follow, please elaborate. BTW there is also langchain4j/langchain4j#1938 in progress which seems to be overlapping with what you describe? |
@langchain4j Yes this pr seems to tackle same problem, as with one difference structures like List<List< POJO > > should be also supported I think ? I mean jackson is capable to resolve such cases given json and JavaType
Oh, so most likely we should bump version quarkus then to cover for that. |
@Tarjei400 those changes are not released yet (planning to release next week). In theory,
That PR addresses only fist case On a side note, |
@langchain4j I will try to branch out from that PR to see what I can do about optional then. As for this pr @geoand I think it would be best to wait for upstream to release, bump the version and see what we can do from there. |
Makes sense to me! |
We have since bumped to |
Added support for mapping to complex types in ai service methods.
Not sure if I didn't miss anything, but I due to interfaces on langchain4j side, it seems like we have to have our own version for both json schema and parser methods.
As an addition, I noticed there is a @description annotation for adding more context to llm about individual fields
and added it to description node of json schema, for llm to better understand how to output data.