Skip to content

Add a missing getter to the CategoryScores class #2939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dev-jonghoonpark
Copy link
Contributor

related issue: #2919

In spring-projects/spring-ai#2201
properties related to the response values of Mistral AI's Moderation API were added to the CategoryScores class. However, getters for user access were not provided.

So, I have added them.


Additional discussion required:

  • spring-ai-model/src/main/java/org/springframework/ai/moderation/Categories.java
  • spring-ai-model/src/main/java/org/springframework/ai/moderation/CategoryScores.java

These two classes seem to need to encapsulate common parts, but currently, they contain detailed information for both OpenAI and Mistral.

It seems that an appropriate separation process is necessary.

@ilayaperumalg ilayaperumalg self-assigned this Apr 29, 2025
@ilayaperumalg ilayaperumalg added this to the 1.0.0-M8 milestone Apr 29, 2025
@ilayaperumalg
Copy link
Member

@dev-jonghoonpark Thanks for adding the missing getters.

@ilayaperumalg ilayaperumalg merged commit f5ac94c into spring-projects:main Apr 29, 2025
2 checks passed
Comment on lines +67 to +75
assertThat(scores.getSexual()).isNotNull();
assertThat(scores.getHate()).isNotNull();
assertThat(scores.getViolence()).isNotNull();
assertThat(scores.getDangerousAndCriminalContent()).isNotNull();
assertThat(scores.getSelfHarm()).isNotNull();
assertThat(scores.getHealth()).isNotNull();
assertThat(scores.getFinancial()).isNotNull();
assertThat(scores.getLaw()).isNotNull();
assertThat(scores.getPii()).isNotNull();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is essentially a test that will always pass because the return type of the getters is a primitive type. However, I believe it's worth keeping to ensure the presence of the getters.

The same approach is applied in the OpenAiModerationModelIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants