microsoft / semantic-kernel-java

Semantic Kernel for Java. Integrate cutting-edge LLM technology quickly and easily into your Java based apps. See https://aka.ms/semantic-kernel.
MIT License
59 stars 14 forks source link

Java: Can LLM help me build an object by calling the Kernel Function with CUSTOM CLASS? #127

Open bx-h opened 3 months ago

bx-h commented 3 months ago
image

it seems not possible :(

johnoliver commented 3 months ago

You need to tell SK how to convert your type, i.e:

       ContextVariableTypes.addGlobalConverter(
            new ContextVariableTypeConverter<MyClass>(
                MyClass.class,
                obj -> {
                    // Converter to convert an unknown object to MyClass
                },
                it -> {
                    // convert MyClass to string
                },
                it -> {
                    // Parse string to MyClass
                },
                Collections.emptyList()
            )
        );