quarkus-langchain4j icon indicating copy to clipboard operation
quarkus-langchain4j copied to clipboard

handle collections as return types or error

Open maxandersen opened this issue 1 year ago • 7 comments

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:

    @RegisterAiService
    public interface jaidataAI {

        @SystemMessage(
            """
            IDENTITY
            
            You are a superintelligent AI that finds all mentions of data structures within an input and...
        """
        )
        @UserMessage("""
                    {data}
                """)
        List<FileInfo> generate(String data);
    }

    record FileInfo(String filename, String content) {};

but if change it to the following it works:

     FileInfos generate(String data);
    }
    record FileInfos(List<FileInfo>) {};
    record FileInfo(String filename, String content) {};

I would think it should be possible to handle - and if not, throw build error it needs to be a non-collection java type?

maxandersen avatar Sep 28 '24 19:09 maxandersen