chore(RetrievalQAWithSourcesChain.py): reorder imports to improve readability and maintain consistency

chore(AZLyricsLoader.py): reorder imports to improve readability and maintain consistency

chore(AirbyteJSONLoader.py): reorder imports to improve readability and maintain consistency

chore(CoNLLULoader.py): add import for List from typing module to fix type hinting

chore(CollegeConfidentialLoader.py): add import for List from typing module to fix type hinting

chore(EverNoteLoader.py): reorder imports to improve readability and maintain consistency

chore(FacebookChatLoader.py): add import for List from typing module to fix type hinting

chore(GitbookLoader.py): reorder imports to improve readability and maintain consistency

chore(HNLoader.py): add import for List from typing module to fix type hinting

chore(IMSDbLoader.py): add import for List from typing module to fix type hinting

chore(TextLoader.py): reorder imports to improve readability and maintain consistency

chore(CohereEmbeddings.py): change default value of cohere_api_key parameter to an empty string

chore(OpenAIEmbeddings.py): change default values of allowed_special, disallowed_special, chunk_size, embedding_ctx_length, max_retries, show_progress_bar, skip_empty, and tikToken_enable parameters to their respective types
This commit is contained in:
anovazzi1 2024-01-25 19:11:06 -03:00
commit fa4a01caed
13 changed files with 31 additions and 28 deletions

View file

@ -1,6 +1,7 @@
from typing import Optional
from langchain.chains import BaseQAWithSourcesChain, RetrievalQAWithSourcesChain
from langchain.chains import RetrievalQAWithSourcesChain
from langchain.chains.qa_with_sources.base import BaseQAWithSourcesChain
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
from langflow import CustomComponent

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent
from langflow.field_typing import Document
from typing import Optional, Dict
from typing import List, Optional, Dict
from langchain_community.document_loaders.azlyrics import AZLyricsLoader
@ -15,7 +15,7 @@ class AZLyricsLoaderComponent(CustomComponent):
"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 = "") -> List[Document]:
documents = AZLyricsLoader(web_path=web_path).load()
if metadata:
for document in documents:

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent
from langflow.field_typing import Document
from typing import Optional, Dict
from typing import List, Optional, Dict
from langchain_community.document_loaders.airbyte_json import AirbyteJSONLoader
@ -26,7 +26,7 @@ class AirbyteJSONLoaderComponent(CustomComponent):
},
}
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
def build(self, file_path: str, metadata: Optional[Dict] = None) -> List[Document]:
documents = AirbyteJSONLoader(file_path=file_path).load()
if metadata:
for document in documents:

View file

@ -1,3 +1,4 @@
from typing import List
from langflow import CustomComponent
from langchain.docstore.document import Document
from langchain_community.document_loaders.conllu import CoNLLULoader
@ -24,7 +25,7 @@ class CoNLLULoaderComponent(CustomComponent):
},
}
def build(self, file_path: str, metadata: dict) -> Document:
def build(self, file_path: str, metadata: dict) -> List[Document]:
documents = CoNLLULoader(file_path=file_path).load()
if metadata:
for document in documents:

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent
from langchain.docstore.document import Document
from typing import Optional
from typing import Optional, List
from langchain_community.document_loaders.college_confidential import CollegeConfidentialLoader
@ -17,7 +17,7 @@ class CollegeConfidentialLoaderComponent(CustomComponent):
"web_path": {"display_name": "Web Page", "required": True},
}
def build(self, web_path: str, metadata: Optional[dict] = {}) -> Document:
def build(self, web_path: str, metadata: Optional[dict] = {}) -> List[Document]:
documents = CollegeConfidentialLoader(web_path=web_path).load()
if metadata:
for document in documents:

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent
from langflow.field_typing import Document
from typing import Optional, Dict
from typing import List, Optional, Dict
from langchain_community.document_loaders.evernote import EverNoteLoader
@ -27,7 +27,7 @@ class EverNoteLoaderComponent(CustomComponent):
},
}
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
def build(self, file_path: str, metadata: Optional[Dict] = None) -> List[Document]:
documents = EverNoteLoader(file_path=file_path).load()
if metadata:
for document in documents:

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent
from langchain.docstore.document import Document
from typing import Optional, Dict
from typing import List, Optional, Dict
from langchain_community.document_loaders.facebook_chat import FacebookChatLoader
@ -26,8 +26,8 @@ class FacebookChatLoaderComponent(CustomComponent):
},
}
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
documents = FacebookChatLoader(file_path=file_path).load()
def build(self, file_path: str, metadata: Optional[Dict] = None) -> List[Document]:
documents = FacebookChatLoader(path=file_path).load()
if metadata:
for document in documents:
if not document.metadata:

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent
from langflow.field_typing import Document
from typing import Optional, Dict
from typing import List, Optional, Dict
from langchain_community.document_loaders.gitbook import GitbookLoader
@ -21,7 +21,7 @@ class GitbookLoaderComponent(CustomComponent):
},
}
def build(self, metadata: Optional[Dict] = None, web_page: str = "") -> Document:
def build(self, metadata: Optional[Dict] = None, web_page: str = "") -> List[Document]:
documents = GitbookLoader(web_page=web_page).load()
if metadata:
for document in documents:

View file

@ -1,6 +1,7 @@
from langflow import CustomComponent
from typing import Optional, Dict
from typing import List, Optional, Dict
from langchain_community.document_loaders.hn import HNLoader
from langflow.field_typing import Document
class HNLoaderComponent(CustomComponent):
@ -17,7 +18,7 @@ class HNLoaderComponent(CustomComponent):
self,
web_path: str,
metadata: Optional[Dict] = None,
) -> HNLoader:
) -> List[Document]:
documents = HNLoader(web_path=web_path).load()
if metadata:
for document in documents:

View file

@ -2,7 +2,7 @@ from langflow import CustomComponent
from langflow.field_typing import Document
from langchain_community.document_loaders.imsdb import IMSDbLoader
from typing import Dict, Optional
from typing import Dict, List, Optional
class IMSDbLoaderComponent(CustomComponent):
@ -19,7 +19,7 @@ class IMSDbLoaderComponent(CustomComponent):
self,
metadata: Optional[Dict] = None,
web_path: str = "",
) -> Document:
) -> List[Document]:
documents = IMSDbLoader(web_path=web_path).load()
if metadata:
for document in documents:

View file

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

View file

@ -21,7 +21,7 @@ class CohereEmbeddingsComponent(CustomComponent):
def build(
self,
request_timeout: Optional[float] = None,
cohere_api_key: str = None,
cohere_api_key: str = "",
max_retries: Optional[int] = None,
model: str = "embed-english-v2.0",
truncate: Optional[str] = None,

View file

@ -68,13 +68,13 @@ class OpenAIEmbeddingsComponent(CustomComponent):
self,
default_headers: Optional[Dict[str, str]] = None,
default_query: Optional[NestedDict] = {},
allowed_special: Optional[List[str]] = [],
allowed_special: List[str] = [],
disallowed_special: List[str] = ["all"],
chunk_size: Optional[int] = 1000,
chunk_size: int = 1000,
client: Optional[Any] = None,
deployment: str = "text-embedding-ada-002",
embedding_ctx_length: Optional[int] = 8191,
max_retries: Optional[int] = 6,
embedding_ctx_length: int = 8191,
max_retries: int = 6,
model: str = "text-embedding-ada-002",
model_kwargs: NestedDict = {},
openai_api_base: Optional[str] = None,
@ -84,9 +84,9 @@ class OpenAIEmbeddingsComponent(CustomComponent):
openai_organization: Optional[str] = None,
openai_proxy: Optional[str] = None,
request_timeout: Optional[float] = None,
show_progress_bar: Optional[bool] = False,
skip_empty: Optional[bool] = False,
tikToken_enable: Optional[bool] = True,
show_progress_bar: bool = False,
skip_empty: bool = False,
tikToken_enable: bool = True,
tiktoken_model_name: Optional[str] = None,
) -> Union[OpenAIEmbeddings, Callable]:
return OpenAIEmbeddings(