Skip to content

Conversation

@hemeda3
Copy link
Contributor

@hemeda3 hemeda3 commented Feb 14, 2024

Please review

Given a input text, outputs if the model classifies it as violating OpenAI's content policy.
Related guide: Moderations

@tzolov
Copy link
Contributor

tzolov commented Feb 15, 2024

Hi @hemeda3 , thank you for your contribution.

The safety moderation is something we've been considering for a while but still have not tackled.

As Spring AI supports multiple LLMs providers and their APIs it important for as to come with a design that "generalise" and "unifies" (as much as possible) features such as the safety moderation.
(btw, the code in the spring-ai-core/model package is meant to be generic for all models)

For example most LLM provides offer some sort of safety policies:

Google's Vertex Gemini and PaLM2 has this:

Microsoft Azure OpenAi:

Amazon Bedrok Guardrails

OpenAI

@markpollack what do you think?

@hemeda3
Copy link
Contributor Author

hemeda3 commented Feb 15, 2024

@tzolov thanks for taking the time to check my PR.
I followed OpenAiImageApi as good generic example , almost copy paste the structure file names etc..

https://docs.spring.io/spring-ai/reference/api/index.html#generic-model-api
image

but seems you're talking about new or different approach I guess something more generic than the one mentioned in this image, I guess it should be sharable across models which I believe will be new structure/design specifically diff from this structure https://docs.spring.io/spring-ai/reference/api/index.html#generic-model-api

if I understood your comment correctly then I think we can close this PR since it's too early

also I can also create new PR more generic way, assuming something different than OpenAiImageApi

@tzolov
Copy link
Contributor

tzolov commented Feb 16, 2024

@hemeda3, I'm truly impressed with your effort and understanding of our somewhat poorly documented concepts.
What i'm saying is that we still have not clear understanding how we are going to extend the generic model (you've shown above) to model the safety moderations in way we can implement it of the various providers.
We are just asking for bit more patience until we get there.
Then I will have more time to review your PR and continue the work

@markpollack markpollack added this to the 0.9.0 milestone Feb 29, 2024
@tzolov tzolov added enhancement New feature or request model client labels Mar 1, 2024
@radhakrishna67
Copy link

I can not wait to see this feature in the upcoming releases. Please prioritize it.

@tzolov tzolov modified the milestones: 1.0.0-M1, 1.0.0-M2 May 28, 2024
@markpollack
Copy link
Member

Hi. I understand the concern of putting classes in the generic model package before having a second impl, but I figure we can adjust as we go considering this is a very clean PR. Thanks @hemeda3 ! very much appreciated.

Added docs and merged into current naming conventions and use of new approach for retry/errorhandler since this PR was authored.

merged in 1894681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request model client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants