Skip to content
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

Fix ChatBedrock docs for guardrails #156

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions libs/aws/langchain_aws/llms/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,19 +524,20 @@ class BedrockBase(BaseLanguageModel, ABC):
"""
An optional dictionary to configure guardrails for Bedrock.

This field 'guardrails' consists of two keys: 'id' and 'version',
which should be strings, but are initialized to None. It's used to
determine if specific guardrails are enabled and properly set.
This field 'guardrails' consists of two keys: 'guardrailId' and
'guardrailVersion', which should be strings, but are initialized to None.
It's used to determine if specific guardrails are enabled and properly set.

Type:
Optional[Mapping[str, str]]: A mapping with 'id' and 'version' keys.
Optional[Mapping[str, str]]: A mapping with 'guardrailId' and
'guardrailVersion' keys.

Example:
llm = Bedrock(model_id="<model_id>", client=<bedrock_client>,
model_kwargs={},
guardrails={
"id": "<guardrail_id>",
"version": "<guardrail_version>"})
"guardrailId": "<guardrail_id>",
"guardrailVersion": "<guardrail_version>"})

To enable tracing for guardrails, set the 'trace' key to True and pass a callback handler to the
'run_manager' parameter of the 'generate', '_call' methods.
Expand All @@ -545,8 +546,8 @@ class BedrockBase(BaseLanguageModel, ABC):
llm = Bedrock(model_id="<model_id>", client=<bedrock_client>,
model_kwargs={},
guardrails={
"id": "<guardrail_id>",
"version": "<guardrail_version>",
"guardrailId": "<guardrail_id>",
"guardrailVersion": "<guardrail_version>",
"trace": True},
callbacks=[BedrockAsyncCallbackHandler()])

Expand Down