Repository navigation
Add guidelines to chat.create - #229
Merged
Merged
Conversation
`client.chat.create` (sync and async) takes a `guidelines` list for
custom moderation controls and sets `GetCompletionsRequest.guidelines`
(field 39). Each entry is a `Guideline` dict in the REST shape,
`{"type": "policy", "category": ..., "behavior": ...}`, or a
`chat_pb2.Guideline`. An unknown category or behavior raises
`ValueError`. The API rejects an unsupported pair, a repeated category,
or a model that cannot apply guidelines with `INVALID_ARGUMENT`.
The v5 and v6 `chat_pb2` stubs are regenerated with xai-proto's
`buf.gen.yaml` from the proto state the vendored stubs match (xai-proto
xai-org#73 plus `safety_identifier`) plus the guideline definitions. Before the
change, that pipeline reproduces the vendored stubs except for the
`from . import` rewrite.
Depends on the xai-proto change that adds `GetCompletionsRequest.guidelines`.
rokujix
force-pushed
the
feat/guidelines
branch
from
October 21, 2026 05:18
abb5455 to
1e7bf39
Compare
Omar-V2
previously approved these changes
Oct 21, 2026
Regenerates only the guideline enums in the v5 and v6 chat stubs.
rokujix
force-pushed
the
feat/guidelines
branch
from
October 23, 2026 06:30
2549dce to
fafc074
Compare
|
Hey @rokujix, one line for the reviewer: the dependency named in the description, xai-org/xai-proto#80, merged on 2026-10-21 at 18:16 UTC, about fourteen hours after this PR was opened, so the vendored |
Omar-V2
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
client.chat.create(sync and async) takes aguidelineslist forcustom moderation controls and sets
GetCompletionsRequest.guidelines(field 39). Each entry is a
Guidelinedict in the REST shape,{"type": "policy", "category": ..., "behavior": ...}, or achat_pb2.Guideline. An unknown category or behavior raisesValueError. The API rejects an unsupported pair, a repeated category,or a model that cannot apply guidelines with
INVALID_ARGUMENT.The v5 and v6
chat_pb2stubs are regenerated with xai-proto'sbuf.gen.yamlfrom the proto state the vendored stubs match (xai-proto#73 plus
safety_identifier) plus the guideline definitions. Before thechange, that pipeline reproduces the vendored stubs except for the
from . importrewrite.Depends on xai-org/xai-proto#80, which adds
GetCompletionsRequest.guidelines.