langchain/docs
Harel Gal a91181fe6d
community[minor]: add support for Guardrails for Amazon Bedrock (#15099)
Added support for optionally supplying 'Guardrails for Amazon Bedrock'
on both types of model invocations (batch/regular and streaming) and for
all models supported by the Amazon Bedrock service.

@baskaryan  @hwchase17

```python 
llm = Bedrock(model_id="<model_id>", client=bedrock,
                  model_kwargs={},
                  guardrails={"id": " <guardrail_id>",
                              "version": "<guardrail_version>",
                               "trace": True}, callbacks=[BedrockAsyncCallbackHandler()])

class BedrockAsyncCallbackHandler(AsyncCallbackHandler):
    """Async callback handler that can be used to handle callbacks from langchain."""

    async def on_llm_error(
            self,
            error: BaseException,
            **kwargs: Any,
    ) -> Any:
        reason = kwargs.get("reason")
        if reason == "GUARDRAIL_INTERVENED":
           # kwargs contains additional trace information sent by 'Guardrails for Bedrock' service.
            print(f"""Guardrails: {kwargs}""")


# streaming 
llm = Bedrock(model_id="<model_id>", client=bedrock,
                  model_kwargs={},
                  streaming=True,
                  guardrails={"id": "<guardrail_id>",
                              "version": "<guardrail_version>"})
```

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2024-01-24 14:44:19 -08:00
..
api_reference docs: bump sphinx>=5 (#16162) 2024-01-17 12:57:34 -08:00
docs community[minor]: add support for Guardrails for Amazon Bedrock (#15099) 2024-01-24 14:44:19 -08:00
scripts docs: fix llm/chat_model tables (#15716) 2024-01-08 11:40:35 -08:00
src
static docs: Update with LCEL examples to Ollama & ChatOllama Integration notebook (#16194) 2024-01-22 22:05:59 -08:00
.local_build.sh update chain docs (#15495) 2024-01-05 09:15:00 -08:00
babel.config.js
code-block-loader.js
docusaurus.config.js docs: add changelog (#15606) 2024-01-07 08:34:34 -08:00
package-lock.json
package.json
README.md
settings.ini
sidebars.js docs: add LangGraph (#15682) 2024-01-08 08:38:14 -08:00
vercel_build.sh docs: add LangGraph (#15682) 2024-01-08 08:38:14 -08:00
vercel_requirements.txt
vercel.json core[patch], community[patch], langchain[patch], docs: Update SQL chains/agents/docs (#16168) 2024-01-22 08:19:08 -08:00

LangChain Documentation

For more information on contributing to our documentation, see the Documentation Contributing Guide