Merge branch 'update_lc' of personal:logspace-ai/langflow into update_lc

This commit is contained in:
anovazzi1 2024-01-10 08:39:58 -03:00
commit 84c85727a8
10 changed files with 51 additions and 45 deletions

View file

@ -10,7 +10,7 @@ class AZLyricsLoaderComponent(CustomComponent):
def build_config(self): def build_config(self):
return { return {
"metadata": {"display_name": "Metadata", "type": "dict", "default": {}, "show": True}, "metadata": {"display_name": "Metadata", "field_type": "dict", "value": {}, "show": True},
"web_path": {"display_name": "Web Page", "type": "str", "required": True, "show": True}, "web_path": {"display_name": "Web Page", "type": "str", "required": True, "show": True},
} }

View file

@ -17,10 +17,11 @@ class AirbyteJSONLoaderComponent(CustomComponent):
"type": "file", "type": "file",
"fileTypes": ["json"], "fileTypes": ["json"],
"required": True, "required": True,
"field_type": "file",
}, },
"metadata": { "metadata": {
"display_name": "Metadata", "display_name": "Metadata",
"type": "dict", "field_type": "dict",
"required": False, "required": False,
}, },
} }

View file

@ -17,12 +17,13 @@ class BSHTMLLoaderComponent(CustomComponent):
"type": "file", "type": "file",
"suffixes": [".html"], "suffixes": [".html"],
"file_types": ["html"], "file_types": ["html"],
"field_type": "file",
}, },
"metadata": { "metadata": {
"display_name": "Metadata", "display_name": "Metadata",
"required": False, "required": False,
"show": True, "show": True,
"type": "dict", "field_type": "dict",
}, },
} }

View file

@ -1,8 +1,8 @@
from langchain import CustomComponent from langflow import CustomComponent
from typing import Optional, Dict, List from typing import Optional, Dict, List
from langchain.loaders import CSVLoader from langchain_community.document_loaders.csv_loader import CSVLoader
from langchain.documents import Document from langchain.docstore.document import Document
class CSVLoaderComponent(CustomComponent): class CSVLoaderComponent(CustomComponent):
display_name = "CSVLoader" display_name = "CSVLoader"
@ -15,6 +15,7 @@ class CSVLoaderComponent(CustomComponent):
"required": True, "required": True,
"suffixes": [".csv"], "suffixes": [".csv"],
"file_types": ["csv"], "file_types": ["csv"],
"field_type": "file",
}, },
"metadata": { "metadata": {
"display_name": "Metadata", "display_name": "Metadata",
@ -25,6 +26,6 @@ class CSVLoaderComponent(CustomComponent):
def build( def build(
self, self,
file_path: str, file_path: str,
metadata: Optional[Dict[str, str]] = None, metadata: dict
) -> List[Document]: ) -> List[Document]:
return CSVLoader(file_path=file_path, metadata=metadata).load() return CSVLoader(file_path=file_path, metadata=metadata).load()

View file

@ -1,5 +1,5 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.documents import Document from langchain.docstore.document import Document
from typing import Optional, Dict from typing import Optional, Dict
from langflow.field_typing import TemplateField from langflow.field_typing import TemplateField
@ -11,13 +11,13 @@ class CoNLLULoaderComponent(CustomComponent):
def build_config(self): def build_config(self):
return { return {
"file_path": TemplateField( "file_path": {
display_name="File Path", "display_name": "File Path",
required=True, "required": True,
type="file", "suffixes": [".conllu"],
file_types=["conllu"], "file_types": ["conllu"],
suffixes=[".conllu"], "field_type": "file",
), },
"metadata": TemplateField( "metadata": TemplateField(
display_name="Metadata", display_name="Metadata",
required=False, required=False,
@ -25,7 +25,7 @@ class CoNLLULoaderComponent(CustomComponent):
), ),
} }
def build(self, file_path: str, metadata: Optional[Dict[str, str]] = None) -> Document: def build(self, file_path: str, metadata: dict) -> Document:
# Here, you would use the actual class that loads CoNLL-U files. # Here, you would use the actual class that loads CoNLL-U files.
# As I don't have the specific class, I'm returning an instance of Document. # As I don't have the specific class, I'm returning an instance of Document.
# In a real scenario, you should replace the below Document with the actual loader class. # In a real scenario, you should replace the below Document with the actual loader class.

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.document_loaders import Document from langchain.docstore.document import Document
from typing import Optional, Dict from typing import Optional, Dict
class CollegeConfidentialLoaderComponent(CustomComponent): class CollegeConfidentialLoaderComponent(CustomComponent):
@ -10,14 +10,14 @@ class CollegeConfidentialLoaderComponent(CustomComponent):
def build_config(self): def build_config(self):
return { return {
"metadata": {"display_name": "Metadata", "default": {}}, "metadata": {"display_name": "Metadata", "values": {}},
"web_path": {"display_name": "Web Page", "required": True}, "web_path": {"display_name": "Web Page", "required": True},
} }
def build( def build(
self, self,
web_path: str, web_path: str,
metadata: Optional[Dict] = None, metadata: Optional[dict] = {}
) -> Document: ) -> Document:
# Assuming there is a loader class `CollegeConfidentialLoader` that takes `metadata` and `web_path` as arguments # Assuming there is a loader class `CollegeConfidentialLoader` that takes `metadata` and `web_path` as arguments
# Replace `CollegeConfidentialLoader` with the actual class name if different # Replace `CollegeConfidentialLoader` with the actual class name if different

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.data_connections import Document from langchain.docstore.document import Document
from typing import Optional, Dict, Any from typing import Optional, Dict, Any
class DirectoryLoaderComponent(CustomComponent): class DirectoryLoaderComponent(CustomComponent):
@ -9,14 +9,14 @@ class DirectoryLoaderComponent(CustomComponent):
def build_config(self) -> Dict[str, Any]: def build_config(self) -> Dict[str, Any]:
return { return {
"glob": {"display_name": "Glob Pattern", "default": "**/*.txt"}, "glob": {"display_name": "Glob Pattern", "value": "**/*.txt"},
"load_hidden": {"display_name": "Load Hidden Files", "default": False, "advanced": True}, "load_hidden": {"display_name": "Load Hidden Files", "value": False, "advanced": True},
"max_concurrency": {"display_name": "Max Concurrency", "default": 10, "advanced": True}, "max_concurrency": {"display_name": "Max Concurrency", "value": 10, "advanced": True},
"metadata": {"display_name": "Metadata", "default": {}}, "metadata": {"display_name": "Metadata", "value": {}},
"path": {"display_name": "Local Directory"}, "path": {"display_name": "Local Directory"},
"recursive": {"display_name": "Recursive", "default": True, "advanced": True}, "recursive": {"display_name": "Recursive", "value": True, "advanced": True},
"silent_errors": {"display_name": "Silent Errors", "default": False, "advanced": True}, "silent_errors": {"display_name": "Silent Errors", "value": False, "advanced": True},
"use_multithreading": {"display_name": "Use Multithreading", "default": True, "advanced": True}, "use_multithreading": {"display_name": "Use Multithreading", "value": True, "advanced": True},
} }
def build( def build(
@ -25,7 +25,7 @@ class DirectoryLoaderComponent(CustomComponent):
path: str, path: str,
load_hidden: Optional[bool] = False, load_hidden: Optional[bool] = False,
max_concurrency: Optional[int] = 10, max_concurrency: Optional[int] = 10,
metadata: Optional[Dict[str, Any]] = None, metadata: Optional[dict] = {},
recursive: Optional[bool] = True, recursive: Optional[bool] = True,
silent_errors: Optional[bool] = False, silent_errors: Optional[bool] = False,
use_multithreading: Optional[bool] = True, use_multithreading: Optional[bool] = True,

View file

@ -17,12 +17,13 @@ class EverNoteLoaderComponent(CustomComponent):
"show": True, "show": True,
"type": "file", "type": "file",
"file_types": ["xml"], "file_types": ["xml"],
"field_type": "file",
}, },
"metadata": { "metadata": {
"display_name": "Metadata", "display_name": "Metadata",
"required": False, "required": False,
"show": True, "show": True,
"type": "dict", "field_type": "dict",
}, },
} }

View file

@ -1,6 +1,6 @@
from langflow import CustomComponent from langflow import CustomComponent
from langchain.documents import Document from langchain.docstore.document import Document
from typing import Optional, Dict from typing import Optional, Dict
class FacebookChatLoaderComponent(CustomComponent): class FacebookChatLoaderComponent(CustomComponent):
@ -15,10 +15,12 @@ class FacebookChatLoaderComponent(CustomComponent):
"required": True, "required": True,
"suffixes": [".json"], "suffixes": [".json"],
"file_types": ["json"], "file_types": ["json"],
"field_type": "file",
}, },
"metadata": { "metadata": {
"display_name": "Metadata", "display_name": "Metadata",
"required": False, "required": False,
"field_type": "dict",
}, },
} }
@ -27,4 +29,4 @@ class FacebookChatLoaderComponent(CustomComponent):
# and returns a Document object. Replace 'FacebookChatLoader' with the actual class name. # and returns a Document object. Replace 'FacebookChatLoader' with the actual class name.
# As per the JSON, the output type is 'Document', which is part of langchain.documents. # As per the JSON, the output type is 'Document', which is part of langchain.documents.
# Therefore, the 'FacebookChatLoader' should be imported or defined elsewhere in the codebase. # Therefore, the 'FacebookChatLoader' should be imported or defined elsewhere in the codebase.
return FacebookChatLoader(file_path=file_path, metadata=metadata) return FacebookChatLoader(file_path=file_path, metadata=metadata)

View file

@ -9,25 +9,25 @@ class VertexAIEmbeddingsComponent(CustomComponent):
def build_config(self): def build_config(self):
return { return {
"client": {"display_name": "Client", "advanced": True}, "credentials": {"display_name": "Credentials", "value": '', "file_types": ['json'],"field_type": "file"},
"credentials": {"display_name": "Credentials", "default": '', "file_types": ['json']}, "instance": {"display_name": "instance", "advanced": True, "field_type": "dict"},
"location": {"display_name": "Location", "default": 'us-central1', "advanced": True}, "location": {"display_name": "Location", "value": 'us-central1', "advanced": True},
"max_output_tokens": {"display_name": "Max Output Tokens", "default": 128}, "max_output_tokens": {"display_name": "Max Output Tokens", "value": 128},
"max_retries": {"display_name": "Max Retries", "default": 6, "advanced": True}, "max_retries": {"display_name": "Max Retries", "value": 6, "advanced": True},
"model_name": {"display_name": "Model Name", "default": 'textembedding-gecko'}, "model_name": {"display_name": "Model Name", "value": 'textembedding-gecko'},
"n": {"display_name": "N", "default": 1, "advanced": True}, "n": {"display_name": "N", "value": 1, "advanced": True},
"project": {"display_name": "Project", "advanced": True}, "project": {"display_name": "Project", "advanced": True},
"request_parallelism": {"display_name": "Request Parallelism", "default": 5, "advanced": True}, "request_parallelism": {"display_name": "Request Parallelism", "value": 5, "advanced": True},
"stop": {"display_name": "Stop", "advanced": True}, "stop": {"display_name": "Stop", "advanced": True},
"streaming": {"display_name": "Streaming", "default": False, "advanced": True}, "streaming": {"display_name": "Streaming", "value": False, "advanced": True},
"temperature": {"display_name": "Temperature", "default": 0.0}, "temperature": {"display_name": "Temperature", "value": 0.0},
"top_k": {"display_name": "Top K", "default": 40, "advanced": True}, "top_k": {"display_name": "Top K", "value": 40, "advanced": True},
"top_p": {"display_name": "Top P", "default": 0.95, "advanced": True}, "top_p": {"display_name": "Top P", "value": 0.95, "advanced": True},
} }
def build( def build(
self, self,
client: Optional[str] = None, instance: Optional[str] = None,
credentials: Optional[str] = None, credentials: Optional[str] = None,
location: str = 'us-central1', location: str = 'us-central1',
max_output_tokens: int = 128, max_output_tokens: int = 128,
@ -43,7 +43,7 @@ class VertexAIEmbeddingsComponent(CustomComponent):
top_p: float = 0.95, top_p: float = 0.95,
) -> VertexAIEmbeddings: ) -> VertexAIEmbeddings:
return VertexAIEmbeddings( return VertexAIEmbeddings(
client=client, instance=instance,
credentials=credentials, credentials=credentials,
location=location, location=location,
max_output_tokens=max_output_tokens, max_output_tokens=max_output_tokens,