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>
2024-01-24 14:44:19 -08:00
..
adapters community[patch]: Add safe lookup to OpenAI response adapter (#14765) 2023-12-20 01:17:23 -05:00
agent_toolkits core[patch], community[patch], langchain[patch], docs: Update SQL chains/agents/docs (#16168) 2024-01-22 08:19:08 -08:00
callbacks community[patch]: Fix MlflowCallback with none artifacts_dir (#16487) 2024-01-23 19:09:02 -08:00
chat_loaders Do not issue beta or deprecation warnings on internal calls (#15641) 2024-01-07 20:54:45 -08:00
chat_message_histories communty[minor]: Store Message History to TiDB Database (#16304) 2024-01-22 13:56:56 -08:00
chat_models community[patch]: Fix error message when litellm is not installed (#16316) 2024-01-23 21:42:29 -08:00
docstore community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
document_loaders community[patch]: avoid KeyError when language not in LANGUAGE_SEGMENTERS (#15212) 2024-01-23 21:09:43 -08:00
document_transformers community[minor]: Adding asynchronous function implementation for Doctran (#15941) 2024-01-15 10:39:25 -08:00
embeddings Adds progress bar to VertexAIEmbeddings (#14542) 2024-01-24 11:16:16 -07:00
graphs Fix neo4j sanitize (#16439) 2024-01-23 10:56:28 -05:00
indexes community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
llms community[minor]: add support for Guardrails for Amazon Bedrock (#15099) 2024-01-24 14:44:19 -08:00
output_parsers langchain[patch], community[minor]: move output_parsers.ernie_functions (#16057) 2024-01-17 10:06:18 -08:00
retrievers community[patch]: Handle when documents are not provided in the Cohere response (#16144) 2024-01-17 09:11:00 -08:00
storage community: SQLStrStore/SQLDocStore provide an easy SQL alternative to InMemoryStore to persist data remotely in a SQL storage (#15909) 2024-01-23 16:50:48 -08:00
tools community[patch]: Update bing results tool name (#16395) 2024-01-22 11:11:03 -08:00
utilities core[patch], community[patch], langchain[patch], docs: Update SQL chains/agents/docs (#16168) 2024-01-22 08:19:08 -08:00
utils openai[minor]: implement langchain-openai package (#15503) 2024-01-05 15:03:28 -08:00
vectorstores community[minor]: VectorStore integration for SAP HANA Cloud Vector Engine (#16514) 2024-01-24 14:05:07 -08:00
__init__.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
cache.py Do not issue beta or deprecation warnings on internal calls (#15641) 2024-01-07 20:54:45 -08:00
py.typed community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00