spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/index.html
Apache License 2.0
3.24k stars 824 forks source link

Add Kotlin reflection support to `ModelOptionsUtils` #1667

Open sdeleuze opened 3 days ago

sdeleuze commented 3 days ago

As documented via #1666, schema generation from Kotlin classes currently requires using non idiomatic code like data class Foo(@get:JsonProperty(required = true, value = "output") val bar: String) while the required information can be inferred from Kotlin null-safety and the value inferred from Kotlin reflection.

A related com.github.victools.jsonschema.generator.Module instance could be implemented and created when KotlinDetector.isKotlinReflectPresent() == true to provide those information automatically here.

That would allow to perform schema generation with just data class Foo(val bar: String).

devcrocod commented 5 hours ago

Hi,

I have some question regarding this issue, please clarify follow points: