spring-projects / spring-ai

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

Use @NonNull annotations for parameters and return types #1291

Open johnsonr opened 1 month ago

johnsonr commented 1 month ago

Using Spring AI from Kotlin, it's noticeable that unlike Spring Framework, it doesn't use @NonNull annotations, which are appropriate for most parameters and return types.

Doing this would not only make Spring AI nicer to use from Kotlin, but make the Java code clearer and more consistent with other Spring projects.

markpollack commented 3 weeks ago

Agreed. A first pass was taken and it seems like we will need to refactor some code, going from setters into ctor methods that ensure they are not null. Some passes were taken in the past, but a good deal depends on the internal implementation (e.g we never return null for content from a call, but empty string - or we already get usage stats in headers from openai) so quick passes don't work.