You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/libs/community/langchain_community
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>
7 months ago
..
adapters community[patch]: Add safe lookup to OpenAI response adapter (#14765) 8 months ago
agent_toolkits core[patch], community[patch], langchain[patch], docs: Update SQL chains/agents/docs (#16168) 7 months ago
callbacks community[patch]: Fix MlflowCallback with none artifacts_dir (#16487) 7 months ago
chat_loaders Do not issue beta or deprecation warnings on internal calls (#15641) 8 months ago
chat_message_histories communty[minor]: Store Message History to TiDB Database (#16304) 7 months ago
chat_models community[patch]: Fix error message when litellm is not installed (#16316) 7 months ago
docstore community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
document_loaders community[patch]: avoid KeyError when language not in LANGUAGE_SEGMENTERS (#15212) 7 months ago
document_transformers community[minor]: Adding asynchronous function implementation for Doctran (#15941) 7 months ago
embeddings Adds progress bar to VertexAIEmbeddings (#14542) 7 months ago
graphs Fix neo4j sanitize (#16439) 7 months ago
indexes community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
llms community[minor]: add support for Guardrails for Amazon Bedrock (#15099) 7 months ago
output_parsers langchain[patch], community[minor]: move `output_parsers.ernie_functions` (#16057) 7 months ago
retrievers community[patch]: Handle when documents are not provided in the Cohere response (#16144) 7 months ago
storage community: SQLStrStore/SQLDocStore provide an easy SQL alternative to `InMemoryStore` to persist data remotely in a SQL storage (#15909) 7 months ago
tools community[patch]: Update bing results tool name (#16395) 7 months ago
utilities core[patch], community[patch], langchain[patch], docs: Update SQL chains/agents/docs (#16168) 7 months ago
utils openai[minor]: implement langchain-openai package (#15503) 8 months ago
vectorstores community[minor]: VectorStore integration for SAP HANA Cloud Vector Engine (#16514) 7 months ago
__init__.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
cache.py Do not issue beta or deprecation warnings on internal calls (#15641) 8 months ago
py.typed community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago