Skip to content

feat: support configurable safety_settings on ChatVertexAI#576

Draft
pinetops wants to merge 1 commit into
brainlid:mainfrom
u2i:feat/vertex-configurable-safety-settings
Draft

feat: support configurable safety_settings on ChatVertexAI#576
pinetops wants to merge 1 commit into
brainlid:mainfrom
u2i:feat/vertex-configurable-safety-settings

Conversation

@pinetops

@pinetops pinetops commented Jul 2, 2026

Copy link
Copy Markdown

Summary

ChatGoogleAI exposes a safety_settings field passed through to the API as safetySettings, but ChatVertexAI has no equivalent — callers can't set Vertex AI harm-category thresholds, so the provider defaults always apply.

This adds a safety_settings field to ChatVertexAI (default []), mirroring ChatGoogleAI:

  • cast it in @create_fields
  • conditionally add it to the request body as safetySettings

Behaviour

Default [] is a no-op (an empty list is not added to the request), so existing behaviour is unchanged. Callers who need to tune harm thresholds — e.g. a stricter or more permissive filter for their domain — can now do so:

ChatVertexAI.new!(%{
  model: "...",
  endpoint: "...",
  safety_settings: [
    %{"category" => "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold" => "BLOCK_ONLY_HIGH"}
  ]
})

Test

Mirrors the existing ChatGoogleAI safety-settings tests: present settings are sent as safetySettings; an empty list is omitted. chat_vertex_ai_test.exs passes (41 tests).

`ChatGoogleAI` exposes a `safety_settings` field that is passed through
to the API as `safetySettings`, but `ChatVertexAI` had no equivalent —
callers could not set Vertex AI harm-category thresholds, so the
provider defaults always applied.

Add a `safety_settings` field to `ChatVertexAI` (default `[]`), mirroring
`ChatGoogleAI`: cast it, and conditionally add it to the request body as
`safetySettings`. Default `[]` is a no-op (the empty list is not added),
so existing behaviour is unchanged; callers who need to tune harm
thresholds (e.g. a stricter or more permissive filter for their domain)
can now do so.

Adds tests mirroring the ChatGoogleAI safety-settings tests: present
settings are sent, an empty list is omitted.
@brainlid

brainlid commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Hi @pinetops! I see the PR is still a draft. Please let me know when it's ready. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants