feat(MetalRetriever.py): add MetalRetriever component to retrieve data using the Metal API

 feat(__init__.py): add empty __init__.py file to the retrievers directory to make it a package
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-28 07:32:18 -03:00
commit 0f9279c68d
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,23 @@
from typing import Optional
from langflow import CustomComponent
from langchain.retrievers import MetalRetriever
from langchain.schema.retriever import BaseRetriever
class MetalRetrieverComponent(CustomComponent):
display_name: str = "Metal Retriever"
description: str = "Retriever that uses the Metal API."
def build_config(self):
return {
"api_key": {"display_name": "API Key", "password": True},
"client_id": {"display_name": "Client ID", "password": True},
"index_id": {"display_name": "Index ID"},
"params": {"display_name": "Parameters", "field_type": "code"},
"code": {"show": False},
}
def build(
self, api_key: str, client_id: str, index_id: str, params: Optional[dict] = None
) -> BaseRetriever:
return MetalRetriever(api_key, client_id, index_id, params=params)