microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
20.51k stars 2.97k forks source link

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

Open bx-h opened 1 month ago

bx-h commented 1 month ago
image

it seems not possible :(

johnoliver commented 3 weeks 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()
            )
        );