Update import statements in GitbookLoader, JsonToolkit, CSVAgent, UnstructuredHTMLLoader, IMSDbLoader, IFixitLoader, BSHTMLLoader, ReadTheDocsLoader, OpenAPIToolkit, Qdrant, EverNoteLoader, CoNLLULoader, and AirbyteJSONLoader components

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-01-09 10:17:35 -03:00
commit 15dd9e3ee1
20 changed files with 61 additions and 69 deletions

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import BaseLanguageModel, AgentExecutor from langflow.field_typing import BaseLanguageModel, AgentExecutor
class CSVAgentComponent(CustomComponent): class CSVAgentComponent(CustomComponent):
display_name = "CSVAgent" display_name = "CSVAgent"

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict
class AZLyricsLoaderComponent(CustomComponent): class AZLyricsLoaderComponent(CustomComponent):
display_name = "AZLyricsLoader" display_name = "AZLyricsLoader"
description = "Load `AZLyrics` webpages." description = "Load `AZLyrics` webpages."
@ -10,18 +10,8 @@ class AZLyricsLoaderComponent(CustomComponent):
def build_config(self): def build_config(self):
return { return {
"metadata": { "metadata": {"display_name": "Metadata", "type": "dict", "default": {}, "show": True},
"display_name": "Metadata", "web_path": {"display_name": "Web Page", "type": "str", "required": True, "show": True},
"type": "dict",
"default": {},
"show": True
},
"web_path": {
"display_name": "Web Page",
"type": "str",
"required": True,
"show": True
},
} }
def build(self, metadata: Optional[Dict] = None, web_path: str = "") -> Document: def build(self, metadata: Optional[Dict] = None, web_path: str = "") -> Document:

View file

@ -1,13 +1,14 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict
class AirbyteJSONLoaderComponent(CustomComponent): class AirbyteJSONLoaderComponent(CustomComponent):
display_name = "AirbyteJSONLoader" display_name = "AirbyteJSONLoader"
description = "Load local `Airbyte` json files." description = "Load local `Airbyte` json files."
documentation = "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/airbyte_json" documentation = (
"https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/airbyte_json"
)
def build_config(self): def build_config(self):
return { return {

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict
class BSHTMLLoaderComponent(CustomComponent): class BSHTMLLoaderComponent(CustomComponent):
display_name = "BSHTMLLoader" display_name = "BSHTMLLoader"
description = "Load `HTML` files and parse them with `beautiful soup`." description = "Load `HTML` files and parse them with `beautiful soup`."

View file

@ -1,8 +1,7 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.documents import Document from langchain.documents import Document
from typing import Optional, Dict from typing import Optional, Dict
from langchain.field_typing import TemplateField from langflow.field_typing import TemplateField
class CoNLLULoaderComponent(CustomComponent): class CoNLLULoaderComponent(CustomComponent):
@ -17,7 +16,7 @@ class CoNLLULoaderComponent(CustomComponent):
required=True, required=True,
type="file", type="file",
file_types=["conllu"], file_types=["conllu"],
suffixes=['.conllu'], suffixes=[".conllu"],
), ),
"metadata": TemplateField( "metadata": TemplateField(
display_name="Metadata", display_name="Metadata",

View file

@ -1,13 +1,13 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict
class EverNoteLoaderComponent(CustomComponent): class EverNoteLoaderComponent(CustomComponent):
display_name = "EverNoteLoader" display_name = "EverNoteLoader"
description = "Load from `EverNote`." description = "Load from `EverNote`."
documentation = "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/evernote" documentation = "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/evernote"
def build_config(self): def build_config(self):
return { return {
"file_path": { "file_path": {

View file

@ -1,6 +1,5 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict
class IFixitLoaderComponent(CustomComponent): class IFixitLoaderComponent(CustomComponent):
display_name = "IFixitLoader" display_name = "IFixitLoader"
description = "Load `iFixit` repair guides, device wikis and answers." description = "Load `iFixit` repair guides, device wikis and answers."

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Dict, Optional from typing import Dict, Optional
class IMSDbLoaderComponent(CustomComponent): class IMSDbLoaderComponent(CustomComponent):
display_name = "IMSDbLoader" display_name = "IMSDbLoader"
description = "Load `IMSDb` webpages." description = "Load `IMSDb` webpages."

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Dict, Optional from typing import Dict, Optional
class ReadTheDocsLoaderComponent(CustomComponent): class ReadTheDocsLoaderComponent(CustomComponent):
display_name = "ReadTheDocsLoader" display_name = "ReadTheDocsLoader"
description = "Load `ReadTheDocs` documentation directory." description = "Load `ReadTheDocs` documentation directory."

View file

@ -1,6 +1,5 @@
from langchain import CustomComponent from langchain import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict

View file

@ -1,13 +1,14 @@
from langchain import CustomComponent from langchain import CustomComponent
from langchain.field_typing import Document from langflow.field_typing import Document
from typing import Optional, Dict from typing import Optional, Dict
class UnstructuredWordDocumentLoaderComponent(CustomComponent): class UnstructuredWordDocumentLoaderComponent(CustomComponent):
display_name = "UnstructuredWordDocumentLoader" display_name = "UnstructuredWordDocumentLoader"
description = "Load `Microsoft Word` file using `Unstructured`." description = "Load `Microsoft Word` file using `Unstructured`."
documentation = "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/microsoft_word" documentation = (
"https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/microsoft_word"
)
def build_config(self): def build_config(self):
return { return {
@ -17,11 +18,7 @@ class UnstructuredWordDocumentLoaderComponent(CustomComponent):
"type": "file", "type": "file",
"suffixes": [".docx", ".doc"], "suffixes": [".docx", ".doc"],
}, },
"metadata": { "metadata": {"display_name": "Metadata", "required": False, "type": "dict"},
"display_name": "Metadata",
"required": False,
"type": "dict"
},
} }
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document: def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:

View file

@ -1,12 +1,14 @@
from langflow import CustomComponent from langflow import CustomComponent
from typing import Optional, Any, Dict from typing import Optional, Any, Dict
from langchain.field_typing import Embeddings from langflow.field_typing import Embeddings
class HuggingFaceEmbeddingsComponent(CustomComponent): class HuggingFaceEmbeddingsComponent(CustomComponent):
display_name = "HuggingFaceEmbeddings" display_name = "HuggingFaceEmbeddings"
description = "HuggingFace sentence_transformers embedding models." description = "HuggingFace sentence_transformers embedding models."
documentation = "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/sentence_transformers" documentation = (
"https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/sentence_transformers"
)
def build_config(self): def build_config(self):
return { return {

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from pydantic import SecretStr from pydantic import SecretStr
from typing import Optional, Dict, Any from typing import Optional, Dict, Any
from langchain.field_typing import BaseLanguageModel from langflow.field_typing import BaseLanguageModel
class AnthropicComponent(CustomComponent): class AnthropicComponent(CustomComponent):
display_name = "Anthropic" display_name = "Anthropic"
@ -40,7 +40,13 @@ class AnthropicComponent(CustomComponent):
# Here we are returning a placeholder class as the Anthropic class is not defined # Here we are returning a placeholder class as the Anthropic class is not defined
# This is to comply with the type hints required by the CustomComponent # This is to comply with the type hints required by the CustomComponent
class Anthropic(BaseLanguageModel): class Anthropic(BaseLanguageModel):
def __init__(self, api_key: Optional[SecretStr], api_url: Optional[str], model_kwargs: Optional[Dict[str, Any]] = None, temperature: Optional[float] = None): def __init__(
self,
api_key: Optional[SecretStr],
api_url: Optional[str],
model_kwargs: Optional[Dict[str, Any]] = None,
temperature: Optional[float] = None,
):
# Initialize Anthropic model with the provided arguments # Initialize Anthropic model with the provided arguments
super().__init__() super().__init__()
self.api_key = api_key self.api_key = api_key

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.llms import BaseLLM from langchain.llms import BaseLLM
from typing import Optional, Dict, Union, Any from typing import Optional, Dict, Union, Any
from langchain.field_typing import BaseLanguageModel from langflow.field_typing import BaseLanguageModel
class ChatOpenAIComponent(CustomComponent): class ChatOpenAIComponent(CustomComponent):
display_name = "ChatOpenAI" display_name = "ChatOpenAI"
@ -69,7 +69,6 @@ class ChatOpenAIComponent(CustomComponent):
openai_api_key: Optional[str] = None, openai_api_key: Optional[str] = None,
temperature: float = 0.7, temperature: float = 0.7,
) -> Union[BaseLanguageModel, BaseLLM]: ) -> Union[BaseLanguageModel, BaseLLM]:
# Assuming there is a class `ChatOpenAI` that takes these parameters # Assuming there is a class `ChatOpenAI` that takes these parameters
# The `ChatOpenAI` class must be imported or defined elsewhere in the actual implementation # The `ChatOpenAI` class must be imported or defined elsewhere in the actual implementation
return ChatOpenAI( return ChatOpenAI(

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import JsonSpec, Tool from langflow.field_typing import JsonSpec, Tool
class JsonToolkitComponent(CustomComponent): class JsonToolkitComponent(CustomComponent):
display_name = "JsonToolkit" display_name = "JsonToolkit"

View file

@ -1,8 +1,8 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.field_typing import AgentExecutor, TextRequestsWrapper from langflow.field_typing import AgentExecutor, TextRequestsWrapper
from typing import Callable from typing import Callable
class OpenAPIToolkitComponent(CustomComponent): class OpenAPIToolkitComponent(CustomComponent):
display_name = "OpenAPIToolkit" display_name = "OpenAPIToolkit"
description = "Toolkit for interacting with an OpenAPI API." description = "Toolkit for interacting with an OpenAPI API."

View file

@ -1,13 +1,13 @@
from langflow import CustomComponent from langflow import CustomComponent
from typing import Optional, List from typing import Optional, List
from langchain.vectorstores import Pinecone from langchain.vectorstores import Pinecone
from langchain.field_typing import ( from langflow.field_typing import (
Document, Document,
Embeddings, Embeddings,
NestedDict, NestedDict,
) )
class PineconeComponent(CustomComponent): class PineconeComponent(CustomComponent):
display_name = "Pinecone" display_name = "Pinecone"
description = "Construct Pinecone wrapper from raw documents." description = "Construct Pinecone wrapper from raw documents."
@ -20,7 +20,7 @@ class PineconeComponent(CustomComponent):
"namespace": {"display_name": "Namespace"}, "namespace": {"display_name": "Namespace"},
"pinecone_api_key": {"display_name": "Pinecone API Key", "default": ""}, "pinecone_api_key": {"display_name": "Pinecone API Key", "default": ""},
"pinecone_env": {"display_name": "Pinecone Environment", "default": ""}, "pinecone_env": {"display_name": "Pinecone Environment", "default": ""},
"search_kwargs": {"display_name": "Search Kwargs", "default": '{}'}, "search_kwargs": {"display_name": "Search Kwargs", "default": "{}"},
} }
def build( def build(

View file

@ -1,9 +1,9 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.vectorstores import Qdrant from langchain_community.vectorstores.qdrant import Qdrant
from typing import Optional, List from typing import Optional, List
from langflow.field_typing import Document, Embeddings, NestedDict from langflow.field_typing import Document, Embeddings, NestedDict
class QdrantComponent(CustomComponent): class QdrantComponent(CustomComponent):
display_name = "Qdrant" display_name = "Qdrant"
description = "Construct Qdrant wrapper from a list of texts." description = "Construct Qdrant wrapper from a list of texts."

View file

@ -1,13 +1,13 @@
from langflow import CustomComponent from langflow import CustomComponent
from typing import Optional, List from typing import Optional, List
from langchain.vectorstores import SupabaseVectorStore from langchain.vectorstores import SupabaseVectorStore
from langchain.field_typing import ( from langflow.field_typing import (
Document, Document,
Embeddings, Embeddings,
NestedDict, NestedDict,
) )
class SupabaseComponent(CustomComponent): class SupabaseComponent(CustomComponent):
display_name = "Supabase" display_name = "Supabase"
description = "Return VectorStore initialized from texts and embeddings." description = "Return VectorStore initialized from texts and embeddings."
@ -27,11 +27,11 @@ class SupabaseComponent(CustomComponent):
self, self,
embedding: Embeddings, embedding: Embeddings,
documents: Optional[List[Document]] = None, documents: Optional[List[Document]] = None,
query_name: str = '', query_name: str = "",
search_kwargs: NestedDict = {}, search_kwargs: NestedDict = {},
supabase_service_key: str = '', supabase_service_key: str = "",
supabase_url: str = '', supabase_url: str = "",
table_name: str = '', table_name: str = "",
) -> SupabaseVectorStore: ) -> SupabaseVectorStore:
return SupabaseVectorStore( return SupabaseVectorStore(
documents=documents, documents=documents,