langchain/libs/community/tests/integration_tests
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[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
callbacks core[patch], langchain[patch], community[patch]: Revert #15326 (#15546) 2024-01-04 10:39:37 -05:00
chat_message_histories communty[minor]: Store Message History to TiDB Database (#16304) 2024-01-22 13:56:56 -08:00
chat_models community[minor]: Add iFlyTek Spark LLM chat model support (#13389) 2024-01-23 19:23:46 -08:00
document_loaders community[patch]: Load list of files using UnstructuredFileLoader (#16216) 2024-01-23 19:37:37 -08:00
embeddings community[minor]: DeepInfra support for chat models (#16380) 2024-01-22 11:22:17 -08:00
examples community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
graphs Fix neo4j sanitize (#16439) 2024-01-23 10:56:28 -05:00
llms community[minor]: add support for Guardrails for Amazon Bedrock (#15099) 2024-01-24 14:44:19 -08:00
retrievers community[minor]: Qdrant sparse vector retriever (#14814) 2023-12-20 02:22:19 -05: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[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00
utilities community: Handling missing key in Google Trends API response. (#15864) 2024-01-21 18:11:45 -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
.env.example community[minor]: Add Cassandra document loader (#16215) 2024-01-18 18:49:02 -08:00
conftest.py infra: Use dotenv in langchain-community's integration tests (#16137) 2024-01-17 18:18:26 -08:00
test_compile.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 2023-12-11 13:53:30 -08:00