Add Amazon Kendra Retriver
This commit is contained in:
parent
0881904892
commit
8abfb7a00e
1 changed files with 27 additions and 0 deletions
27
src/backend/langflow/components/retrievers/AmazonKendra.py
Normal file
27
src/backend/langflow/components/retrievers/AmazonKendra.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from langflow import CustomComponent
|
||||
from langchain.retrievers import AmazonKendraRetriever
|
||||
from langchain.schema import BaseRetriever
|
||||
|
||||
|
||||
class AmazonKendraRetrieverComponent(CustomComponent):
|
||||
display_name: str = "Amazon Kendra Retriever"
|
||||
description: str = "Retriever that uses the Amazon Kendra API."
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"index_id": {"display_name": "Index ID"},
|
||||
"attribute_filter": {
|
||||
"attribute_filter": "Attribute Filter",
|
||||
"field_type": "code",
|
||||
},
|
||||
"code": {"show": False},
|
||||
}
|
||||
|
||||
def build(
|
||||
self, index_id: str, attribute_filter: dict
|
||||
) -> BaseRetriever:
|
||||
try:
|
||||
output = AmazonKendraRetriever(index_id=index_id, attribute_filter=attribute_filter)
|
||||
except Exception as e:
|
||||
raise ValueError("Could not connect to AmazonKendra API.") from e
|
||||
return output
|
||||
Loading…
Add table
Add a link
Reference in a new issue