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/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>
8 months ago
..
adapters community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
callbacks core[patch], langchain[patch], community[patch]: Revert #15326 (#15546) 8 months ago
chat_message_histories communty[minor]: Store Message History to TiDB Database (#16304) 8 months ago
chat_models community[minor]: Add iFlyTek Spark LLM chat model support (#13389) 8 months ago
document_loaders community[patch]: Load list of files using UnstructuredFileLoader (#16216) 8 months ago
embeddings community[minor]: DeepInfra support for chat models (#16380) 8 months ago
examples community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
graphs Fix neo4j sanitize (#16439) 8 months ago
llms community[minor]: add support for Guardrails for Amazon Bedrock (#15099) 8 months ago
retrievers community[minor]: Qdrant sparse vector retriever (#14814) 9 months ago
storage community: SQLStrStore/SQLDocStore provide an easy SQL alternative to `InMemoryStore` to persist data remotely in a SQL storage (#15909) 8 months ago
tools community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
utilities community: Handling missing key in Google Trends API response. (#15864) 8 months ago
vectorstores community[minor]: VectorStore integration for SAP HANA Cloud Vector Engine (#16514) 8 months ago
.env.example community[minor]: Add Cassandra document loader (#16215) 8 months ago
__init__.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago
conftest.py infra: Use dotenv in langchain-community's integration tests (#16137) 8 months ago
test_compile.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 9 months ago