spring-projects / spring-ai

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

Use @NonNull annotations for parameters and return types #1291

Open johnsonr opened 2 months ago

johnsonr commented 2 months 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 2 months 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.