Skip to content

Conversation

@terussell85
Copy link
Contributor

@terussell85 terussell85 commented Nov 23, 2024

Adds support for SafetySettings configuration to VertexAiGeminiChatModel and VertexAiGeminiChatOptions

See https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters for reference.

Should fix #942

@terussell85
Copy link
Contributor Author

@tzolov I updated the code with updates from the spring-javaformat plugin. Apologies that I didn't catch that the first time.

Copy link
Contributor

@tzolov tzolov left a comment

Choose a reason for hiding this comment

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

Hi @terussell85 , thank you, for the important contribution!

I've left couple of comments. The most important one is to verify if we can use the spring.ai.vertex.ai.gemini.chat.options.SafetySetting to configure the SafetySettings declaratively via app. properties. You can check the auto-config ITs here.

Also can you please check if you can update the VertexAIGemini docs here.
You can build the docs locally with: ./mvnw -pl spring-ai-docs antora .

@terussell85
Copy link
Contributor Author

Great feedback. I'll take a look and get back to you.

feat(gemini) not null checks on safetySettings

feat(gemini) check safety settings not empty instead of not null

feat(gemini) Add VertexAiGeminiSafetySetting wrapper class

feat(gemini) Update documentation with new property

feat(gemini) Update equals, hashCode, and toString
@terussell85
Copy link
Contributor Author

terussell85 commented Dec 4, 2024

@tzolov I think we're good to go now.

Changes since last review:

  1. Introduce new VertexAiGeminiSafetySetting class to allow for declarative configuration. This is converted to the Vertex AI setting at request-time.
  2. Not null assertions for safetySettings on both the Builder and the class property.
  3. Verified that declarative configuration works
  4. Updated docs

I made some changes to the originally suggested SafetySetting class, including renaming it and adding a Builder. I also kept the newly defined Spring enums both value- and name-consistent with the Gemini enums so that there won't be accidental confusion of users.

Let me know if there is anything else.

@terussell85 terussell85 requested a review from tzolov December 4, 2024 19:12
@tzolov
Copy link
Contributor

tzolov commented Dec 17, 2024

thanks @terussell85

@tzolov
Copy link
Contributor

tzolov commented Dec 17, 2024

rebased and merged at c14618f

@tzolov tzolov closed this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VertexAiGeminiChatModel: Make safetySettings configurable

3 participants