Fix imports and formatting issues
This commit is contained in:
parent
87d2db11ac
commit
a3cc0c7fa6
66 changed files with 326 additions and 344 deletions
|
|
@ -2,6 +2,7 @@ from langflow import CustomComponent
|
|||
from langflow.field_typing import BaseLanguageModel, AgentExecutor
|
||||
from langchain_experimental.agents.agent_toolkits.csv.base import create_csv_agent
|
||||
|
||||
|
||||
class CSVAgentComponent(CustomComponent):
|
||||
display_name = "CSVAgent"
|
||||
description = "Construct a CSV agent from a CSV and tools."
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.agents import AgentExecutor,create_json_agent
|
||||
from langchain.agents import AgentExecutor, create_json_agent
|
||||
from langflow.field_typing import (
|
||||
BaseLanguageModel,
|
||||
)
|
||||
from langchain_community.agent_toolkits.base import BaseToolkit
|
||||
|
||||
|
||||
class JsonAgentComponent(CustomComponent):
|
||||
display_name = "JsonAgent"
|
||||
description = "Construct a json agent from an LLM and tools."
|
||||
|
|
@ -20,4 +21,4 @@ class JsonAgentComponent(CustomComponent):
|
|||
llm: BaseLanguageModel,
|
||||
toolkit: BaseToolkit,
|
||||
) -> AgentExecutor:
|
||||
return create_json_agent(llm=llm, toolkit=toolkit)
|
||||
return create_json_agent(llm=llm, toolkit=toolkit)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Union, Callable
|
||||
from langchain.agents import AgentExecutor
|
||||
|
|
@ -6,7 +5,8 @@ from langflow.field_typing import BaseLanguageModel
|
|||
from langchain_community.agent_toolkits.sql.base import create_sql_agent
|
||||
from langchain.sql_database import SQLDatabase
|
||||
from langchain_community.agent_toolkits import SQLDatabaseToolkit
|
||||
|
||||
|
||||
|
||||
class SQLAgentComponent(CustomComponent):
|
||||
display_name = "SQLAgent"
|
||||
description = "Construct an SQL agent from an LLM and tools."
|
||||
|
|
@ -15,7 +15,7 @@ class SQLAgentComponent(CustomComponent):
|
|||
return {
|
||||
"llm": {"display_name": "LLM"},
|
||||
"database_uri": {"display_name": "Database URI"},
|
||||
"verbose": {"display_name": "Verbose", "value": False,"advanced": True},
|
||||
"verbose": {"display_name": "Verbose", "value": False, "advanced": True},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.agents import AgentExecutor, create_vectorstore_agent
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreToolkit
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreToolkit
|
||||
from typing import Union, Callable
|
||||
from langflow.field_typing import BaseLanguageModel
|
||||
|
||||
|
||||
class VectorStoreAgentComponent(CustomComponent):
|
||||
display_name = "VectorStoreAgent"
|
||||
description = "Construct an agent from a Vector Store."
|
||||
|
|
@ -20,4 +20,4 @@ class VectorStoreAgentComponent(CustomComponent):
|
|||
llm: BaseLanguageModel,
|
||||
vector_store_toolkit: VectorStoreToolkit,
|
||||
) -> Union[AgentExecutor, Callable]:
|
||||
return create_vectorstore_agent(llm=llm,toolkit=vector_store_toolkit)
|
||||
return create_vectorstore_agent(llm=llm, toolkit=vector_store_toolkit)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain_core.language_models.base import BaseLanguageModel
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreRouterToolkit
|
||||
from langchain.agents import create_vectorstore_router_agent
|
||||
from typing import Callable
|
||||
|
||||
|
||||
class VectorStoreRouterAgentComponent(CustomComponent):
|
||||
display_name = "VectorStoreRouterAgent"
|
||||
description = "Construct an agent from a Vector Store Router."
|
||||
|
|
@ -15,9 +15,5 @@ class VectorStoreRouterAgentComponent(CustomComponent):
|
|||
"vectorstoreroutertoolkit": {"display_name": "Vector Store Router Toolkit"},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
llm: BaseLanguageModel,
|
||||
vectorstoreroutertoolkit: VectorStoreRouterToolkit
|
||||
) -> Callable:
|
||||
return create_vectorstore_router_agent(llm=llm,toolkit=vectorstoreroutertoolkit)
|
||||
def build(self, llm: BaseLanguageModel, vectorstoreroutertoolkit: VectorStoreRouterToolkit) -> Callable:
|
||||
return create_vectorstore_router_agent(llm=llm, toolkit=vectorstoreroutertoolkit)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
from typing import List
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langchain.agents import ZeroShotAgent
|
||||
from langchain_core.tools import BaseTool
|
||||
from typing import List, Optional
|
||||
from langflow import CustomComponent
|
||||
from langflow.components.chains.LLMChain import LLMChain
|
||||
|
||||
|
||||
class ZeroShotAgentComponent(CustomComponent):
|
||||
display_name = "ZeroShotAgent"
|
||||
description = "Construct an agent from an LLM and tools."
|
||||
|
|
@ -21,7 +22,7 @@ class ZeroShotAgentComponent(CustomComponent):
|
|||
self,
|
||||
llm: LLMChain,
|
||||
tools: List[BaseTool],
|
||||
prefix: Optional[str] = "Answer the following questions as best you can. You have access to the following tools:",
|
||||
suffix: Optional[str] = "Begin!\n\nQuestion: {input}\nThought:{agent_scratchpad}",
|
||||
prefix: str = "Answer the following questions as best you can. You have access to the following tools:",
|
||||
suffix: str = "Begin!\n\nQuestion: {input}\nThought:{agent_scratchpad}",
|
||||
) -> ZeroShotAgent:
|
||||
return ZeroShotAgent(llm_chain=llm, tools=tools, prefix=prefix, suffix=suffix)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import BaseLanguageModel, Chain
|
||||
from typing import Union, Callable
|
||||
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||
|
||||
|
||||
class CombineDocsChainComponent(CustomComponent):
|
||||
display_name = "CombineDocsChain"
|
||||
description = "Load question answering chain."
|
||||
|
|
@ -13,7 +13,7 @@ class CombineDocsChainComponent(CustomComponent):
|
|||
"llm": {"display_name": "LLM"},
|
||||
"chain_type": {
|
||||
"display_name": "Chain Type",
|
||||
"options": ['stuff', 'map_reduce', 'map_rerank', 'refine'],
|
||||
"options": ["stuff", "map_reduce", "map_rerank", "refine"],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ class CombineDocsChainComponent(CustomComponent):
|
|||
llm: BaseLanguageModel,
|
||||
chain_type: str,
|
||||
) -> Union[Chain, Callable]:
|
||||
if chain_type not in ['stuff', 'map_reduce', 'map_rerank', 'refine']:
|
||||
if chain_type not in ["stuff", "map_reduce", "map_rerank", "refine"]:
|
||||
raise ValueError(f"Invalid chain_type: {chain_type}")
|
||||
|
||||
return BaseCombineDocumentsChain()
|
||||
return BaseCombineDocumentsChain()
|
||||
|
|
|
|||
|
|
@ -28,5 +28,5 @@ class LLMChainComponent(CustomComponent):
|
|||
prompt: BasePromptTemplate,
|
||||
llm: BaseLanguageModel,
|
||||
memory: Optional[BaseMemory] = None,
|
||||
) -> Union[Chain, Callable,LLMChain]:
|
||||
) -> Union[Chain, Callable, LLMChain]:
|
||||
return LLMChain(prompt=prompt, llm=llm, memory=memory)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.chains import LLMCheckerChain
|
||||
from typing import Union, Callable
|
||||
|
|
@ -7,6 +6,7 @@ from langflow.field_typing import (
|
|||
Chain,
|
||||
)
|
||||
|
||||
|
||||
class LLMCheckerChainComponent(CustomComponent):
|
||||
display_name = "LLMCheckerChain"
|
||||
description = ""
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
from typing import Callable, Optional, Union
|
||||
|
||||
from langchain.chains import LLMChain, LLMMathChain
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langchain.chains import LLMChain,LLMMathChain
|
||||
from typing import Callable, Optional, Union
|
||||
from langflow.field_typing import (
|
||||
BaseLanguageModel,
|
||||
BaseMemory,
|
||||
Chain
|
||||
)
|
||||
from langflow.field_typing import BaseLanguageModel, BaseMemory, Chain
|
||||
|
||||
|
||||
class LLMMathChainComponent(CustomComponent):
|
||||
display_name = "LLMMathChain"
|
||||
|
|
@ -26,8 +24,8 @@ class LLMMathChainComponent(CustomComponent):
|
|||
self,
|
||||
llm: BaseLanguageModel,
|
||||
llm_chain: LLMChain,
|
||||
input_key: Optional[str]="question",
|
||||
output_key: Optional[str]="answer",
|
||||
input_key: str = "question",
|
||||
output_key: str = "answer",
|
||||
memory: Optional[BaseMemory] = None,
|
||||
) -> Union[LLMMathChain, Callable,Chain]:
|
||||
) -> Union[LLMMathChain, Callable, Chain]:
|
||||
return LLMMathChain(llm=llm, llm_chain=llm_chain, input_key=input_key, output_key=output_key, memory=memory)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
from typing import Callable, Optional, Union
|
||||
|
||||
from langflow import CustomComponent
|
||||
from typing import Optional, Union, Callable
|
||||
from langflow.field_typing import (
|
||||
BaseMemory,
|
||||
BaseRetriever)
|
||||
from langchain.chains.retrieval_qa.base import BaseRetrievalQA
|
||||
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||
from langchain.chains.retrieval_qa.base import BaseRetrievalQA, RetrievalQA
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import BaseMemory, BaseRetriever
|
||||
|
||||
|
||||
class RetrievalQAComponent(CustomComponent):
|
||||
display_name = "RetrievalQA"
|
||||
description = "Chain for question-answering against an index."
|
||||
|
|
@ -15,8 +15,8 @@ class RetrievalQAComponent(CustomComponent):
|
|||
"combine_documents_chain": {"display_name": "Combine Documents Chain"},
|
||||
"retriever": {"display_name": "Retriever"},
|
||||
"memory": {"display_name": "Memory", "required": False},
|
||||
"input_key": {"display_name": "Input Key","advanced":True},
|
||||
"output_key": {"display_name": "Output Key","advanced":True},
|
||||
"input_key": {"display_name": "Input Key", "advanced": True},
|
||||
"output_key": {"display_name": "Output Key", "advanced": True},
|
||||
"return_source_documents": {"display_name": "Return Source Documents"},
|
||||
}
|
||||
|
||||
|
|
@ -25,11 +25,11 @@ class RetrievalQAComponent(CustomComponent):
|
|||
combine_documents_chain: BaseCombineDocumentsChain,
|
||||
retriever: BaseRetriever,
|
||||
memory: Optional[BaseMemory] = None,
|
||||
input_key: Optional[str] = "query",
|
||||
output_key: Optional[str] = "result",
|
||||
return_source_documents: Optional[bool] = True,
|
||||
input_key: str = "query",
|
||||
output_key: str = "result",
|
||||
return_source_documents: bool = True,
|
||||
) -> Union[BaseRetrievalQA, Callable]:
|
||||
return BaseRetrievalQA(
|
||||
return RetrievalQA(
|
||||
combine_documents_chain=combine_documents_chain,
|
||||
retriever=retriever,
|
||||
memory=memory,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
from typing import Optional
|
||||
|
||||
from langchain.chains import BaseQAWithSourcesChain, RetrievalQAWithSourcesChain
|
||||
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langchain.chains import RetrievalQAWithSourcesChain
|
||||
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||
from typing import Optional
|
||||
from langflow.field_typing import (
|
||||
BaseMemory,
|
||||
BaseRetriever,
|
||||
BaseLanguageModel
|
||||
)
|
||||
from langflow.field_typing import BaseLanguageModel, BaseMemory, BaseRetriever
|
||||
|
||||
|
||||
class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
||||
display_name = "RetrievalQAWithSourcesChain"
|
||||
|
|
@ -18,14 +16,12 @@ class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
|||
"llm": {"display_name": "LLM"},
|
||||
"chain_type": {
|
||||
"display_name": "Chain Type",
|
||||
"options": ['stuff', 'map_reduce', 'map_rerank', 'refine'],
|
||||
"options": ["stuff", "map_reduce", "map_rerank", "refine"],
|
||||
},
|
||||
"memory": {"display_name": "Memory"},
|
||||
"return_source_documents": {"display_name": "Return Source Documents"},
|
||||
|
||||
}
|
||||
|
||||
|
||||
def build(
|
||||
self,
|
||||
retriever: BaseRetriever,
|
||||
|
|
@ -34,5 +30,12 @@ class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
|||
chain_type: str,
|
||||
memory: Optional[BaseMemory] = None,
|
||||
return_source_documents: Optional[bool] = True,
|
||||
) -> RetrievalQAWithSourcesChain:
|
||||
return RetrievalQAWithSourcesChain(combine_documents_chain=combine_documents_chain,memory=memory,return_source_documents=return_source_documents,retriever=retriever).from_chain_type(llm=llm, chain_type=chain_type)
|
||||
) -> BaseQAWithSourcesChain:
|
||||
return RetrievalQAWithSourcesChain.from_chain_type(
|
||||
llm=llm,
|
||||
chain_type=chain_type,
|
||||
combine_documents_chain=combine_documents_chain,
|
||||
memory=memory,
|
||||
return_source_documents=return_source_documents,
|
||||
retriever=retriever,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Callable, Union
|
||||
from langflow.field_typing import (
|
||||
BasePromptTemplate,
|
||||
BaseLanguageModel,
|
||||
Chain
|
||||
)
|
||||
from langflow.field_typing import BasePromptTemplate, BaseLanguageModel, Chain
|
||||
from langchain_community.utilities.sql_database import SQLDatabase
|
||||
from langchain_experimental.sql.base import SQLDatabaseChain
|
||||
|
||||
|
||||
class SQLDatabaseChainComponent(CustomComponent):
|
||||
display_name = "SQLDatabaseChain"
|
||||
description = ""
|
||||
|
|
@ -25,5 +21,5 @@ class SQLDatabaseChainComponent(CustomComponent):
|
|||
db: SQLDatabase,
|
||||
llm: BaseLanguageModel,
|
||||
prompt: BasePromptTemplate,
|
||||
) -> Union[Chain, Callable,SQLDatabaseChain]:
|
||||
) -> Union[Chain, Callable, SQLDatabaseChain]:
|
||||
return SQLDatabaseChain.from_llm(llm=llm, db=db, prompt=prompt)
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ class AZLyricsLoaderComponent(CustomComponent):
|
|||
|
||||
def build(self, metadata: Optional[Dict] = None, web_path: str = "") -> Document:
|
||||
documents = AZLyricsLoader(web_path=web_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
else:
|
||||
document.metadata.update(metadata)
|
||||
return documents
|
||||
return documents
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class AirbyteJSONLoaderComponent(CustomComponent):
|
|||
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
|
||||
documents = AirbyteJSONLoader(file_path=file_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import List
|
||||
from langchain_community.document_loaders.csv_loader import CSVLoader
|
||||
from langchain.docstore.document import Document
|
||||
|
||||
|
||||
class CSVLoaderComponent(CustomComponent):
|
||||
display_name = "CSVLoader"
|
||||
description = "Load a `CSV` file into a list of Documents."
|
||||
|
|
@ -23,13 +23,9 @@ class CSVLoaderComponent(CustomComponent):
|
|||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
file_path: str,
|
||||
metadata: dict
|
||||
) -> List[Document]:
|
||||
def build(self, file_path: str, metadata: dict) -> List[Document]:
|
||||
documents = CSVLoader(file_path=file_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class CoNLLULoaderComponent(CustomComponent):
|
|||
|
||||
def build(self, file_path: str, metadata: dict) -> Document:
|
||||
documents = CoNLLULoader(file_path=file_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.docstore.document import Document
|
||||
from typing import Optional
|
||||
from langchain_community.document_loaders.college_confidential import CollegeConfidentialLoader
|
||||
|
||||
|
||||
class CollegeConfidentialLoaderComponent(CustomComponent):
|
||||
display_name = "CollegeConfidentialLoader"
|
||||
description = "Load `College Confidential` webpages."
|
||||
documentation = "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/college_confidential"
|
||||
documentation = (
|
||||
"https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/college_confidential"
|
||||
)
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
|
|
@ -15,13 +17,9 @@ 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] = {}) -> Document:
|
||||
documents = CollegeConfidentialLoader(web_path=web_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.docstore.document import Document
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
|
||||
class DirectoryLoaderComponent(CustomComponent):
|
||||
display_name = "DirectoryLoader"
|
||||
description = "Load from a directory."
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from langflow.field_typing import Document
|
|||
from typing import Optional, Dict
|
||||
from langchain_community.document_loaders.evernote import EverNoteLoader
|
||||
|
||||
|
||||
class EverNoteLoaderComponent(CustomComponent):
|
||||
display_name = "EverNoteLoader"
|
||||
description = "Load from `EverNote`."
|
||||
|
|
@ -28,7 +29,7 @@ class EverNoteLoaderComponent(CustomComponent):
|
|||
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
|
||||
documents = EverNoteLoader(file_path=file_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.docstore.document import Document
|
||||
from typing import Optional, Dict
|
||||
from langchain_community.document_loaders.facebook_chat import FacebookChatLoader
|
||||
|
||||
|
||||
class FacebookChatLoaderComponent(CustomComponent):
|
||||
display_name = "FacebookChatLoader"
|
||||
description = "Load `Facebook Chat` messages directory dump."
|
||||
documentation = "https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/facebook_chat"
|
||||
documentation = (
|
||||
"https://python.langchain.com/docs/modules/data_connection/document_loaders/integrations/facebook_chat"
|
||||
)
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
|
|
@ -25,10 +28,10 @@ class FacebookChatLoaderComponent(CustomComponent):
|
|||
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
|
||||
documents = FacebookChatLoader(file_path=file_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
else:
|
||||
document.metadata.update(metadata)
|
||||
return documents
|
||||
return documents
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class GitbookLoaderComponent(CustomComponent):
|
|||
return {
|
||||
"metadata": {
|
||||
"display_name": "Metadata",
|
||||
"field_type":"dict",
|
||||
"field_type": "dict",
|
||||
"value": {},
|
||||
},
|
||||
"web_page": {
|
||||
|
|
@ -23,7 +23,7 @@ class GitbookLoaderComponent(CustomComponent):
|
|||
|
||||
def build(self, metadata: Optional[Dict] = None, web_page: str = "") -> Document:
|
||||
documents = GitbookLoader(web_page=web_page).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Optional, Dict
|
||||
from langchain_community.document_loaders.hn import HNLoader
|
||||
|
|
@ -10,25 +9,17 @@ class HNLoaderComponent(CustomComponent):
|
|||
|
||||
def build_config(self):
|
||||
return {
|
||||
"metadata": {
|
||||
"display_name": "Metadata",
|
||||
"value": {},
|
||||
"required": False,
|
||||
"field_type": "dict"
|
||||
},
|
||||
"web_path": {
|
||||
"display_name": "Web Page",
|
||||
"required": True
|
||||
},
|
||||
"metadata": {"display_name": "Metadata", "value": {}, "required": False, "field_type": "dict"},
|
||||
"web_path": {"display_name": "Web Page", "required": True},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
self,
|
||||
web_path: str,
|
||||
metadata: Optional[Dict] = None,
|
||||
metadata: Optional[Dict] = None,
|
||||
) -> HNLoader:
|
||||
documents = HNLoader(web_path=web_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from typing import Dict, List, Optional
|
||||
|
||||
from langchain_community.document_loaders.ifixit import IFixitLoader
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import Document
|
||||
from typing import Optional, Dict
|
||||
|
||||
|
||||
class IFixitLoaderComponent(CustomComponent):
|
||||
|
|
@ -14,7 +16,17 @@ class IFixitLoaderComponent(CustomComponent):
|
|||
"web_path": {"display_name": "Web Page", "type": "str"},
|
||||
}
|
||||
|
||||
def build(self, web_path: str, metadata: Optional[Dict] = None) -> Document:
|
||||
def build(self, web_path: str, metadata: Optional[Dict] = None) -> List[Document]:
|
||||
# Assuming IFixitLoader is the correct class name from the langchain library,
|
||||
# and it has a load method that returns a Document object.
|
||||
return IFixitLoader(web_path=web_path, metadata=metadata).load()
|
||||
if metadata is None:
|
||||
metadata = {}
|
||||
|
||||
docs = IFixitLoader(web_path=web_path).load()
|
||||
|
||||
if metadata:
|
||||
for doc in docs:
|
||||
if doc.metadata is None:
|
||||
doc.metadata = {}
|
||||
doc.metadata.update(metadata)
|
||||
return docs
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class IMSDbLoaderComponent(CustomComponent):
|
|||
web_path: str = "",
|
||||
) -> Document:
|
||||
documents = IMSDbLoader(web_path=web_path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.documents import Document
|
||||
from typing import Optional, Dict
|
||||
|
||||
class PyPDFDirectoryLoaderComponent(CustomComponent):
|
||||
display_name = "PyPDFDirectoryLoader"
|
||||
description = "Load a directory with `PDF` files using `pypdf` and chunks at character level."
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"metadata": {"display_name": "Metadata", "required": False},
|
||||
"path": {"display_name": "Local directory", "required": True},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
path: str,
|
||||
metadata: Optional[Dict] = None,
|
||||
) -> Document:
|
||||
# Assuming there is a PyPDFDirectoryLoader class that takes these parameters
|
||||
# Since the actual implementation is not provided, this is a placeholder
|
||||
return PyPDFDirectoryLoader(path=path, metadata=metadata)
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
from typing import Dict, List, Optional
|
||||
|
||||
from langchain_community.document_loaders.pdf import PyPDFLoader
|
||||
from langchain_core.documents import Document
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langchain.document_loaders import BaseLoader
|
||||
from typing import Optional, Dict
|
||||
|
||||
|
||||
class PyPDFLoaderComponent(CustomComponent):
|
||||
display_name = "PyPDFLoader"
|
||||
|
|
@ -22,10 +25,17 @@ class PyPDFLoaderComponent(CustomComponent):
|
|||
"required": False,
|
||||
"type": "dict",
|
||||
"show": True,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> BaseLoader:
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> List[Document]:
|
||||
# Assuming there is a PyPDFLoader class that takes file_path and metadata as parameters
|
||||
# and inherits from BaseLoader
|
||||
return PyPDFLoader(file_path=file_path, metadata=metadata)
|
||||
docs = PyPDFLoader(file_path=file_path).load()
|
||||
|
||||
if metadata:
|
||||
for doc in docs:
|
||||
if doc.metadata is None:
|
||||
doc.metadata = {}
|
||||
doc.metadata.update(metadata)
|
||||
return docs
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from langflow import CustomComponent
|
||||
from typing import Dict, Optional,List
|
||||
from typing import Dict, Optional, List
|
||||
from langchain_core.documents import Document
|
||||
from langchain_community.document_loaders.readthedocs import ReadTheDocsLoader
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ class ReadTheDocsLoaderComponent(CustomComponent):
|
|||
|
||||
def build_config(self):
|
||||
return {
|
||||
"metadata": {"display_name": "Metadata", "default": {},"field_type": "dict"},
|
||||
"metadata": {"display_name": "Metadata", "default": {}, "field_type": "dict"},
|
||||
"path": {"display_name": "Local directory", "required": True},
|
||||
}
|
||||
|
||||
|
|
@ -20,10 +20,10 @@ class ReadTheDocsLoaderComponent(CustomComponent):
|
|||
metadata: Optional[Dict] = None,
|
||||
) -> List[Document]:
|
||||
documents = ReadTheDocsLoader(path=path).load()
|
||||
if(metadata):
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
else:
|
||||
document.metadata.update(metadata)
|
||||
return documents
|
||||
return documents
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.documents import Document
|
||||
from typing import Optional, Dict
|
||||
|
||||
|
||||
class SRTLoaderComponent(CustomComponent):
|
||||
display_name = "SRTLoader"
|
||||
description = "Load `.srt` (subtitle) files."
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Optional, Dict, List
|
||||
from langchain_core.documents import Document
|
||||
from langchain_community.document_loaders.slack_directory import SlackDirectoryLoader
|
||||
|
||||
|
||||
class SlackDirectoryLoaderComponent(CustomComponent):
|
||||
display_name = "SlackDirectoryLoader"
|
||||
description = "Load from a `Slack` directory dump."
|
||||
|
|
@ -10,7 +11,7 @@ class SlackDirectoryLoaderComponent(CustomComponent):
|
|||
|
||||
def build_config(self):
|
||||
return {
|
||||
"zip_path": {"display_name": "Path to zip file","field_type": "file","file_types":[".zip"]},
|
||||
"zip_path": {"display_name": "Path to zip file", "field_type": "file", "file_types": [".zip"]},
|
||||
"metadata": {"display_name": "Metadata", "field_type": "dict"},
|
||||
"workspace_url": {"display_name": "Workspace URL"},
|
||||
}
|
||||
|
|
@ -21,8 +22,8 @@ class SlackDirectoryLoaderComponent(CustomComponent):
|
|||
metadata: Optional[Dict] = None,
|
||||
workspace_url: Optional[str] = None,
|
||||
) -> List[Document]:
|
||||
documents = SlackDirectoryLoader(zip_path=zip_path,workspace_url=workspace_url).load()
|
||||
if(metadata):
|
||||
documents = SlackDirectoryLoader(zip_path=zip_path, workspace_url=workspace_url).load()
|
||||
if metadata:
|
||||
for document in documents:
|
||||
if not document.metadata:
|
||||
document.metadata = metadata
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.data_connections import Document
|
||||
from typing import Optional, Dict
|
||||
|
||||
|
||||
class TextLoaderComponent(CustomComponent):
|
||||
display_name = "TextLoader"
|
||||
description = "Load text file."
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from typing import Dict, List, Optional
|
||||
|
||||
from langchain import CustomComponent
|
||||
from langflow.field_typing import Document
|
||||
from typing import Optional, Dict
|
||||
from langchain_community.document_loaders import UnstructuredHTMLLoader
|
||||
from langchain_core.documents import Document
|
||||
|
||||
|
||||
class UnstructuredHTMLLoaderComponent(CustomComponent):
|
||||
|
|
@ -14,7 +16,14 @@ class UnstructuredHTMLLoaderComponent(CustomComponent):
|
|||
"metadata": {"display_name": "Metadata"},
|
||||
}
|
||||
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> Document:
|
||||
def build(self, file_path: str, metadata: Optional[Dict] = None) -> List[Document]:
|
||||
# Assuming the existence of a function or class named UnstructuredHTMLLoader that
|
||||
# loads HTML and creates a Document object; Replace with actual implementation.
|
||||
return UnstructuredHTMLLoader(file_path=file_path, metadata=metadata)
|
||||
docs = UnstructuredHTMLLoader(file_path=file_path).load()
|
||||
|
||||
if metadata:
|
||||
for doc in docs:
|
||||
if doc.metadata is None:
|
||||
doc.metadata = {}
|
||||
doc.metadata.update(metadata)
|
||||
return docs
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.document_loaders import Document
|
||||
from typing import Optional, Dict
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from typing import Optional
|
||||
|
||||
from langchain_community.embeddings.cohere import CohereEmbeddings
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langchain_community.embeddings.cohere import CohereEmbeddings
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class CohereEmbeddingsComponent(CustomComponent):
|
||||
|
|
@ -10,7 +11,7 @@ class CohereEmbeddingsComponent(CustomComponent):
|
|||
|
||||
def build_config(self):
|
||||
return {
|
||||
"cohere_api_key": {"display_name": "Cohere API Key","password":True},
|
||||
"cohere_api_key": {"display_name": "Cohere API Key", "password": True},
|
||||
"model": {"display_name": "Model", "default": "embed-english-v2.0", "advanced": True},
|
||||
"truncate": {"display_name": "Truncate", "advanced": True},
|
||||
"max_retries": {"display_name": "Max Retries", "advanced": True},
|
||||
|
|
@ -24,7 +25,7 @@ class CohereEmbeddingsComponent(CustomComponent):
|
|||
max_retries: Optional[int] = None,
|
||||
model: str = "embed-english-v2.0",
|
||||
truncate: Optional[str] = None,
|
||||
user_agent: Optional[str] = "langchain",
|
||||
user_agent: str = "langchain",
|
||||
) -> CohereEmbeddings:
|
||||
return CohereEmbeddings(
|
||||
max_retries=max_retries,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from langflow import CustomComponent
|
|||
from typing import Optional, Dict
|
||||
from langchain_community.embeddings.huggingface import HuggingFaceEmbeddings
|
||||
|
||||
|
||||
class HuggingFaceEmbeddingsComponent(CustomComponent):
|
||||
display_name = "HuggingFaceEmbeddings"
|
||||
description = "HuggingFace sentence_transformers embedding models."
|
||||
|
|
@ -12,8 +13,8 @@ class HuggingFaceEmbeddingsComponent(CustomComponent):
|
|||
def build_config(self):
|
||||
return {
|
||||
"cache_folder": {"display_name": "Cache Folder", "advanced": True},
|
||||
"encode_kwargs": {"display_name": "Encode Kwargs", "advanced": True,"field_type":"dict"},
|
||||
"model_kwargs": {"display_name": "Model Kwargs","field_type":"dict", "advanced": True},
|
||||
"encode_kwargs": {"display_name": "Encode Kwargs", "advanced": True, "field_type": "dict"},
|
||||
"model_kwargs": {"display_name": "Model Kwargs", "field_type": "dict", "advanced": True},
|
||||
"model_name": {"display_name": "Model Name"},
|
||||
"multi_process": {"display_name": "Multi Process", "advanced": True},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ class OpenAIEmbeddingsComponent(CustomComponent):
|
|||
"max_retries": {"display_name": "Max Retries", "advanced": True},
|
||||
"model": {"display_name": "Model", "advanced": True},
|
||||
"model_kwargs": {"display_name": "Model Kwargs", "advanced": True},
|
||||
"openai_api_base": {"display_name": "OpenAI API Base","password":True, "advanced": True},
|
||||
"openai_api_key": {"display_name": "OpenAI API Key","password":True},
|
||||
"openai_api_type": {"display_name": "OpenAI API Type", "advanced": True,"password":True},
|
||||
"openai_api_base": {"display_name": "OpenAI API Base", "password": True, "advanced": True},
|
||||
"openai_api_key": {"display_name": "OpenAI API Key", "password": True},
|
||||
"openai_api_type": {"display_name": "OpenAI API Type", "advanced": True, "password": True},
|
||||
"openai_api_version": {
|
||||
"display_name": "OpenAI API Version",
|
||||
"advanced": True,
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.embeddings import VertexAIEmbeddings
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class VertexAIEmbeddingsComponent(CustomComponent):
|
||||
display_name = "VertexAIEmbeddings"
|
||||
description = "Google Cloud VertexAI embedding models."
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"credentials": {"display_name": "Credentials", "value": '', "file_types": ['.json'],"field_type": "file"},
|
||||
"credentials": {"display_name": "Credentials", "value": "", "file_types": [".json"], "field_type": "file"},
|
||||
"instance": {"display_name": "instance", "advanced": True, "field_type": "dict"},
|
||||
"location": {"display_name": "Location", "value": 'us-central1', "advanced": True},
|
||||
"location": {"display_name": "Location", "value": "us-central1", "advanced": True},
|
||||
"max_output_tokens": {"display_name": "Max Output Tokens", "value": 128},
|
||||
"max_retries": {"display_name": "Max Retries", "value": 6, "advanced": True},
|
||||
"model_name": {"display_name": "Model Name", "value": 'textembedding-gecko'},
|
||||
"model_name": {"display_name": "Model Name", "value": "textembedding-gecko"},
|
||||
"n": {"display_name": "N", "value": 1, "advanced": True},
|
||||
"project": {"display_name": "Project", "advanced": True},
|
||||
"request_parallelism": {"display_name": "Request Parallelism", "value": 5, "advanced": True},
|
||||
|
|
@ -29,10 +29,10 @@ class VertexAIEmbeddingsComponent(CustomComponent):
|
|||
self,
|
||||
instance: Optional[str] = None,
|
||||
credentials: Optional[str] = None,
|
||||
location: str = 'us-central1',
|
||||
location: str = "us-central1",
|
||||
max_output_tokens: int = 128,
|
||||
max_retries: int = 6,
|
||||
model_name: str = 'textembedding-gecko',
|
||||
model_name: str = "textembedding-gecko",
|
||||
n: int = 1,
|
||||
project: Optional[str] = None,
|
||||
request_parallelism: int = 5,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from langflow import CustomComponent
|
||||
from typing import Optional
|
||||
from langflow.field_typing import BaseLanguageModel,NestedDict
|
||||
from langflow.field_typing import BaseLanguageModel, NestedDict
|
||||
from langchain_community.llms.anthropic import Anthropic
|
||||
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class AnthropicComponent(CustomComponent):
|
|||
},
|
||||
"model_kwargs": {
|
||||
"display_name": "Model Kwargs",
|
||||
"field_type": 'NestedDict',
|
||||
"field_type": "NestedDict",
|
||||
"advanced": True,
|
||||
},
|
||||
"temperature": {
|
||||
|
|
@ -42,4 +42,4 @@ class AnthropicComponent(CustomComponent):
|
|||
anthropic_api_url=anthropic_api_url,
|
||||
model_kwargs=model_kwargs,
|
||||
temperature=temperature,
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class AzureChatOpenAIComponent(CustomComponent):
|
|||
"2023-07-01-preview",
|
||||
"2023-08-01-preview",
|
||||
"2023-09-01-preview",
|
||||
"2023-12-01-preview"
|
||||
"2023-12-01-preview",
|
||||
]
|
||||
|
||||
def build_config(self):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain_community.llms.ctransformers import CTransformers
|
||||
from typing import Optional, Dict
|
||||
|
||||
|
||||
class CTransformersComponent(CustomComponent):
|
||||
display_name = "CTransformers"
|
||||
description = "C Transformers LLM models"
|
||||
|
|
@ -11,16 +11,21 @@ class CTransformersComponent(CustomComponent):
|
|||
def build_config(self):
|
||||
return {
|
||||
"model": {"display_name": "Model", "required": True},
|
||||
"model_file": {"display_name": "Model File", "required": False,"field_type":"file", "file_types":[".bin"]},
|
||||
"model_file": {
|
||||
"display_name": "Model File",
|
||||
"required": False,
|
||||
"field_type": "file",
|
||||
"file_types": [".bin"],
|
||||
},
|
||||
"model_type": {"display_name": "Model Type", "required": True},
|
||||
"config": {"display_name": "Config", "advanced": True, "required": False,"field_type":"dict","value":'{"top_k":40,"top_p":0.95,"temperature":0.8,"repetition_penalty":1.1,"last_n_tokens":64,"seed":-1,"max_new_tokens":256,"stop":"","stream":"False","reset":"True","batch_size":8,"threads":-1,"context_length":-1,"gpu_layers":0}'}
|
||||
"config": {
|
||||
"display_name": "Config",
|
||||
"advanced": True,
|
||||
"required": False,
|
||||
"field_type": "dict",
|
||||
"value": '{"top_k":40,"top_p":0.95,"temperature":0.8,"repetition_penalty":1.1,"last_n_tokens":64,"seed":-1,"max_new_tokens":256,"stop":"","stream":"False","reset":"True","batch_size":8,"threads":-1,"context_length":-1,"gpu_layers":0}',
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
model: str,
|
||||
model_file: str,
|
||||
model_type: str,
|
||||
config: Optional[Dict] = None
|
||||
) -> CTransformers:
|
||||
def build(self, model: str, model_file: str, model_type: str, config: Optional[Dict] = None) -> CTransformers:
|
||||
return CTransformers(model=model, model_file=model_file, model_type=model_type, config=config)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Optional, Union, Callable
|
||||
from langflow.field_typing import BaseLanguageModel
|
||||
from langchain_community.chat_models.anthropic import ChatAnthropic
|
||||
|
||||
|
||||
class ChatAnthropicComponent(CustomComponent):
|
||||
display_name = "ChatAnthropic"
|
||||
description = "`Anthropic` chat large language models."
|
||||
|
|
@ -21,7 +22,7 @@ class ChatAnthropicComponent(CustomComponent):
|
|||
},
|
||||
"model_kwargs": {
|
||||
"display_name": "Model Kwargs",
|
||||
"field_type": 'dict',
|
||||
"field_type": "dict",
|
||||
"advanced": True,
|
||||
},
|
||||
"temperature": {
|
||||
|
|
@ -37,7 +38,6 @@ class ChatAnthropicComponent(CustomComponent):
|
|||
model_kwargs: dict = {},
|
||||
temperature: Optional[float] = None,
|
||||
) -> Union[BaseLanguageModel, Callable]:
|
||||
|
||||
return ChatAnthropic(
|
||||
anthropic_api_key=anthropic_api_key,
|
||||
anthropic_api_url=anthropic_api_url,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from langflow import CustomComponent
|
||||
from langchain.llms import BaseLLM
|
||||
from typing import Optional, Union
|
||||
|
||||
from langchain.llms import BaseLLM
|
||||
from langchain_community.chat_models.openai import ChatOpenAI
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import BaseLanguageModel, NestedDict
|
||||
|
||||
|
||||
|
|
@ -66,12 +68,12 @@ class ChatOpenAIComponent(CustomComponent):
|
|||
self,
|
||||
max_tokens: Optional[int] = 256,
|
||||
model_kwargs: Optional[NestedDict] = {},
|
||||
model_name: Optional[str] = "gpt-4-1106-preview",
|
||||
model_name: str = "gpt-4-1106-preview",
|
||||
openai_api_base: Optional[str] = None,
|
||||
openai_api_key: Optional[str] = None,
|
||||
temperature: float = 0.7,
|
||||
) -> Union[BaseLanguageModel, BaseLLM]:
|
||||
if(not openai_api_base):
|
||||
if not openai_api_base:
|
||||
openai_api_base = "https://api.openai.com/v1"
|
||||
return ChatOpenAI(
|
||||
max_tokens=max_tokens,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
from langflow import CustomComponent
|
||||
from typing import List, Optional, Union
|
||||
from langchain_core.messages.base import BaseMessage
|
||||
from langchain_community.chat_models.vertexai import ChatVertexAI
|
||||
from langflow.field_typing import BaseLanguageModel
|
||||
|
||||
from langchain.llms import BaseLLM
|
||||
from langchain_community.chat_models.vertexai import ChatVertexAI
|
||||
from langchain_core.messages.base import BaseMessage
|
||||
from langflow import CustomComponent
|
||||
from langflow.field_typing import BaseLanguageModel
|
||||
|
||||
|
||||
class ChatVertexAIComponent(CustomComponent):
|
||||
|
|
@ -63,10 +64,10 @@ class ChatVertexAIComponent(CustomComponent):
|
|||
self,
|
||||
credentials: Optional[str],
|
||||
project: str,
|
||||
examples: Optional[List[BaseMessage]]=[],
|
||||
location: Optional[str] = "us-central1",
|
||||
examples: Optional[List[BaseMessage]] = [],
|
||||
location: str = "us-central1",
|
||||
max_output_tokens: Optional[int] = 128,
|
||||
model_name: Optional[str] = "chat-bison",
|
||||
model_name: str = "chat-bison",
|
||||
temperature: Optional[float] = 0.0,
|
||||
top_k: Optional[int] = 40,
|
||||
top_p: Optional[float] = 0.95,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain_core.language_models.base import BaseLanguageModel
|
||||
from typing import Optional
|
||||
from langchain_community.llms.cohere import Cohere
|
||||
|
||||
|
||||
class CohereComponent(CustomComponent):
|
||||
display_name = "Cohere"
|
||||
description = "Cohere large language models."
|
||||
|
|
@ -11,23 +11,9 @@ class CohereComponent(CustomComponent):
|
|||
|
||||
def build_config(self):
|
||||
return {
|
||||
"cohere_api_key": {
|
||||
"display_name": "Cohere API Key",
|
||||
"type": "password",
|
||||
"password": True
|
||||
},
|
||||
"max_tokens": {
|
||||
"display_name": "Max Tokens",
|
||||
"default": 256,
|
||||
"type": "int",
|
||||
"show": True
|
||||
},
|
||||
"temperature": {
|
||||
"display_name": "Temperature",
|
||||
"default": 0.75,
|
||||
"type": "float",
|
||||
"show": True
|
||||
},
|
||||
"cohere_api_key": {"display_name": "Cohere API Key", "type": "password", "password": True},
|
||||
"max_tokens": {"display_name": "Max Tokens", "default": 256, "type": "int", "show": True},
|
||||
"temperature": {"display_name": "Temperature", "default": 0.75, "type": "float", "show": True},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
from typing import Optional, List, Dict, Any
|
||||
from langflow import CustomComponent
|
||||
from langchain_community.llms.llamacpp import LlamaCpp
|
||||
|
||||
|
||||
class LlamaCppComponent(CustomComponent):
|
||||
display_name = "LlamaCpp"
|
||||
description = "llama.cpp model."
|
||||
|
|
@ -24,7 +24,12 @@ class LlamaCppComponent(CustomComponent):
|
|||
"max_tokens": {"display_name": "Max Tokens", "advanced": True},
|
||||
"metadata": {"display_name": "Metadata", "advanced": True},
|
||||
"model_kwargs": {"display_name": "Model Kwargs", "advanced": True},
|
||||
"model_path": {"display_name": "Model Path","field_type":"file", "file_types":[".bin"],"required":True},
|
||||
"model_path": {
|
||||
"display_name": "Model Path",
|
||||
"field_type": "file",
|
||||
"file_types": [".bin"],
|
||||
"required": True,
|
||||
},
|
||||
"n_batch": {"display_name": "N Batch", "advanced": True},
|
||||
"n_ctx": {"display_name": "N Ctx", "advanced": True},
|
||||
"n_gpu_layers": {"display_name": "N GPU Layers", "advanced": True},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from typing import Dict, Optional
|
||||
|
||||
from langchain_openai.llms.base import OpenAI
|
||||
|
||||
from langflow import CustomComponent
|
||||
from typing import Optional, Dict
|
||||
from langchain_openai.llms.base import OpenAI
|
||||
|
||||
|
||||
class OpenAIComponent(CustomComponent):
|
||||
display_name = "OpenAI"
|
||||
|
|
@ -41,12 +43,12 @@ class OpenAIComponent(CustomComponent):
|
|||
self,
|
||||
max_tokens: Optional[int] = 256,
|
||||
model_kwargs: Optional[Dict] = None,
|
||||
model_name: Optional[str] = "text-davinci-003",
|
||||
model_name: str = "text-davinci-003",
|
||||
openai_api_base: Optional[str] = "",
|
||||
openai_api_key: str = "",
|
||||
temperature: Optional[float] = 0.7,
|
||||
) -> OpenAI:
|
||||
if(not openai_api_base):
|
||||
if not openai_api_base:
|
||||
openai_api_base = "https://api.openai.com/v1"
|
||||
return OpenAI(
|
||||
max_tokens=max_tokens,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.llms import BaseLLM
|
||||
from typing import Optional, Union, Callable, Dict
|
||||
from langchain_community.llms.vertexai import VertexAI
|
||||
|
||||
|
||||
class VertexAIComponent(CustomComponent):
|
||||
display_name = "VertexAI"
|
||||
description = "Google Vertex AI large language models"
|
||||
|
|
@ -20,7 +20,7 @@ class VertexAIComponent(CustomComponent):
|
|||
"location": {
|
||||
"display_name": "Location",
|
||||
"type": "str",
|
||||
"advanced":True,
|
||||
"advanced": True,
|
||||
"value": "us-central1",
|
||||
"required": False,
|
||||
},
|
||||
|
|
@ -29,14 +29,14 @@ class VertexAIComponent(CustomComponent):
|
|||
"field_type": "int",
|
||||
"value": 128,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"max_retries": {
|
||||
"display_name": "Max Retries",
|
||||
"type": "int",
|
||||
"value": 6,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"metadata": {
|
||||
"display_name": "Metadata",
|
||||
|
|
@ -51,7 +51,7 @@ class VertexAIComponent(CustomComponent):
|
|||
"required": False,
|
||||
},
|
||||
"n": {
|
||||
"advanced":True,
|
||||
"advanced": True,
|
||||
"display_name": "N",
|
||||
"field_type": "int",
|
||||
"value": 1,
|
||||
|
|
@ -68,42 +68,36 @@ class VertexAIComponent(CustomComponent):
|
|||
"field_type": "int",
|
||||
"value": 5,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"streaming": {
|
||||
"display_name": "Streaming",
|
||||
"field_type": "bool",
|
||||
"value": False,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"temperature": {
|
||||
"display_name": "Temperature",
|
||||
"field_type": "float",
|
||||
"value": 0.0,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
},
|
||||
"top_k": {
|
||||
"display_name": "Top K",
|
||||
"type": "int",
|
||||
"default": 40,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"top_k": {"display_name": "Top K", "type": "int", "default": 40, "required": False, "advanced": True},
|
||||
"top_p": {
|
||||
"display_name": "Top P",
|
||||
"field_type": "float",
|
||||
"value": 0.95,
|
||||
"required": False,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"tuned_model_name": {
|
||||
"display_name": "Tuned Model Name",
|
||||
"type": "str",
|
||||
"required": False,
|
||||
"value": None,
|
||||
"advanced":True
|
||||
"advanced": True,
|
||||
},
|
||||
"verbose": {
|
||||
"display_name": "Verbose",
|
||||
|
|
@ -111,10 +105,7 @@ class VertexAIComponent(CustomComponent):
|
|||
"value": False,
|
||||
"required": False,
|
||||
},
|
||||
"name":{
|
||||
"display_name":"Name",
|
||||
"field_type":"str"
|
||||
},
|
||||
"name": {"display_name": "Name", "field_type": "str"},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
@ -126,7 +117,7 @@ class VertexAIComponent(CustomComponent):
|
|||
metadata: Dict = None,
|
||||
model_name: str = "text-bison",
|
||||
n: int = 1,
|
||||
name:Optional[str] = None,
|
||||
name: Optional[str] = None,
|
||||
project: Optional[str] = None,
|
||||
request_parallelism: int = 5,
|
||||
streaming: bool = False,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.retrievers import MultiQueryRetriever
|
||||
from typing import Optional, Union, Callable
|
||||
|
|
@ -8,6 +7,7 @@ from langflow.field_typing import (
|
|||
BaseRetriever,
|
||||
)
|
||||
|
||||
|
||||
class MultiQueryRetrieverComponent(CustomComponent):
|
||||
display_name = "MultiQueryRetriever"
|
||||
description = "Initialize from llm using default template."
|
||||
|
|
@ -16,22 +16,25 @@ class MultiQueryRetrieverComponent(CustomComponent):
|
|||
def build_config(self):
|
||||
return {
|
||||
"llm": {"display_name": "LLM"},
|
||||
"prompt": {"display_name": "Prompt", "default": {
|
||||
"input_variables": ["question"],
|
||||
"input_types": {},
|
||||
"output_parser": None,
|
||||
"partial_variables": {},
|
||||
"template": 'You are an AI language model assistant. Your task is \n'
|
||||
'to generate 3 different versions of the given user \n'
|
||||
'question to retrieve relevant documents from a vector database. \n'
|
||||
'By generating multiple perspectives on the user question, \n'
|
||||
'your goal is to help the user overcome some of the limitations \n'
|
||||
'of distance-based similarity search. Provide these alternative \n'
|
||||
'questions separated by newlines. Original question: {question}',
|
||||
"template_format": "f-string",
|
||||
"validate_template": False,
|
||||
"_type": "prompt"
|
||||
}},
|
||||
"prompt": {
|
||||
"display_name": "Prompt",
|
||||
"default": {
|
||||
"input_variables": ["question"],
|
||||
"input_types": {},
|
||||
"output_parser": None,
|
||||
"partial_variables": {},
|
||||
"template": "You are an AI language model assistant. Your task is \n"
|
||||
"to generate 3 different versions of the given user \n"
|
||||
"question to retrieve relevant documents from a vector database. \n"
|
||||
"By generating multiple perspectives on the user question, \n"
|
||||
"your goal is to help the user overcome some of the limitations \n"
|
||||
"of distance-based similarity search. Provide these alternative \n"
|
||||
"questions separated by newlines. Original question: {question}",
|
||||
"template_format": "f-string",
|
||||
"validate_template": False,
|
||||
"_type": "prompt",
|
||||
},
|
||||
},
|
||||
"retriever": {"display_name": "Retriever"},
|
||||
"parser_key": {"display_name": "Parser Key", "default": "lines"},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.text_splitter import CharacterTextSplitter
|
||||
from langchain_core.documents.base import Document
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from typing import Optional
|
||||
from langflow import CustomComponent
|
||||
from langchain.text_splitter import Language
|
||||
|
||||
from langchain.schema import Document
|
||||
from langchain.text_splitter import Language
|
||||
|
||||
from langflow import CustomComponent
|
||||
|
||||
|
||||
class LanguageRecursiveTextSplitterComponent(CustomComponent):
|
||||
|
|
@ -48,7 +50,7 @@ class LanguageRecursiveTextSplitterComponent(CustomComponent):
|
|||
documents: list[Document],
|
||||
chunk_size: Optional[int] = 1000,
|
||||
chunk_overlap: Optional[int] = 200,
|
||||
separator_type: Optional[str] = "Python",
|
||||
separator_type: str = "Python",
|
||||
) -> list[Document]:
|
||||
"""
|
||||
Split text into chunks of a specified length.
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ class JsonToolkitComponent(CustomComponent):
|
|||
}
|
||||
|
||||
def build(self, spec: JsonSpec) -> JsonToolkit:
|
||||
return JsonToolkit(spec=spec)
|
||||
return JsonToolkit(spec=spec)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.vectorstores import VectorStore
|
||||
from typing import Union, Callable
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreInfo
|
||||
|
||||
|
||||
class VectorStoreInfoComponent(CustomComponent):
|
||||
display_name = "VectorStoreInfo"
|
||||
description = "Information about a VectorStore"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import List, Union
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreRouterToolkit
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreInfo
|
||||
from langflow.field_typing import BaseLanguageModel,Tool
|
||||
from langflow.field_typing import BaseLanguageModel, Tool
|
||||
|
||||
|
||||
class VectorStoreRouterToolkitComponent(CustomComponent):
|
||||
display_name = "VectorStoreRouterToolkit"
|
||||
|
|
@ -16,10 +16,8 @@ class VectorStoreRouterToolkitComponent(CustomComponent):
|
|||
}
|
||||
|
||||
def build(
|
||||
self,
|
||||
vectorstores: List[VectorStoreInfo],
|
||||
llm: BaseLanguageModel
|
||||
)->Union[Tool,VectorStoreRouterToolkit]:
|
||||
print("vectorstores",vectorstores)
|
||||
print("llm",llm)
|
||||
return VectorStoreRouterToolkit(vectorstores=vectorstores,llm=llm)
|
||||
self, vectorstores: List[VectorStoreInfo], llm: BaseLanguageModel
|
||||
) -> Union[Tool, VectorStoreRouterToolkit]:
|
||||
print("vectorstores", vectorstores)
|
||||
print("llm", llm)
|
||||
return VectorStoreRouterToolkit(vectorstores=vectorstores, llm=llm)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreToolkit
|
||||
from langchain.agents.agent_toolkits.vectorstore.toolkit import VectorStoreInfo
|
||||
|
|
@ -10,6 +9,7 @@ from langflow.field_typing import (
|
|||
)
|
||||
from typing import Union
|
||||
|
||||
|
||||
class VectorStoreToolkitComponent(CustomComponent):
|
||||
display_name = "VectorStoreToolkit"
|
||||
description = "Toolkit for interacting with a Vector Store."
|
||||
|
|
@ -24,5 +24,5 @@ class VectorStoreToolkitComponent(CustomComponent):
|
|||
self,
|
||||
vectorstore_info: VectorStoreInfo,
|
||||
llm: BaseLanguageModel,
|
||||
) -> Union[Tool,VectorStoreToolkit]:
|
||||
return VectorStoreToolkit(vectorstore_info=vectorstore_info,llm=llm)
|
||||
) -> Union[Tool, VectorStoreToolkit]:
|
||||
return VectorStoreToolkit(vectorstore_info=vectorstore_info, llm=llm)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from typing import Optional
|
||||
from langflow import CustomComponent
|
||||
|
||||
|
|
@ -30,8 +29,4 @@ class BingSearchAPIWrapperComponent(CustomComponent):
|
|||
k: Optional[int] = 10,
|
||||
) -> BingSearchAPIWrapper:
|
||||
# 'k' has a default value and is not shown (show=False), so it is hardcoded here
|
||||
return BingSearchAPIWrapper(
|
||||
bing_search_url=bing_search_url,
|
||||
bing_subscription_key=bing_subscription_key,
|
||||
k=k
|
||||
)
|
||||
return BingSearchAPIWrapper(bing_search_url=bing_search_url, bing_subscription_key=bing_subscription_key, k=k)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Union, Callable
|
||||
from langchain_community.utilities.google_search import GoogleSearchAPIWrapper
|
||||
|
|
@ -11,7 +10,7 @@ class GoogleSearchAPIWrapperComponent(CustomComponent):
|
|||
def build_config(self):
|
||||
return {
|
||||
"google_api_key": {"display_name": "Google API Key", "password": True},
|
||||
"google_cse_id": {"display_name": "Google CSE ID","password":True},
|
||||
"google_cse_id": {"display_name": "Google CSE ID", "password": True},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Dict, Optional
|
||||
|
||||
|
|
@ -21,15 +20,10 @@ class GoogleSerperAPIWrapperComponent(CustomComponent):
|
|||
"name": "result_key_for_type",
|
||||
"advanced": False,
|
||||
"dynamic": False,
|
||||
"info": '',
|
||||
"info": "",
|
||||
"field_type": "dict",
|
||||
"list": False,
|
||||
"value": {
|
||||
"news": "news",
|
||||
"places": "places",
|
||||
"images": "images",
|
||||
"search": "organic"
|
||||
}
|
||||
"value": {"news": "news", "places": "places", "images": "images", "search": "organic"},
|
||||
},
|
||||
"serper_api_key": {
|
||||
"display_name": "Serper API Key",
|
||||
|
|
@ -39,10 +33,10 @@ class GoogleSerperAPIWrapperComponent(CustomComponent):
|
|||
"name": "serper_api_key",
|
||||
"advanced": False,
|
||||
"dynamic": False,
|
||||
"info": '',
|
||||
"info": "",
|
||||
"type": "str",
|
||||
"list": False,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
@ -50,7 +44,4 @@ class GoogleSerperAPIWrapperComponent(CustomComponent):
|
|||
serper_api_key: str,
|
||||
result_key_for_type: Optional[Dict[str, str]] = None,
|
||||
) -> GoogleSerperAPIWrapper:
|
||||
return GoogleSerperAPIWrapper(
|
||||
result_key_for_type=result_key_for_type,
|
||||
serper_api_key=serper_api_key
|
||||
)
|
||||
return GoogleSerperAPIWrapper(result_key_for_type=result_key_for_type, serper_api_key=serper_api_key)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from langflow import CustomComponent
|
||||
from typing import Optional, Dict
|
||||
from langchain_community.utilities.searx_search import SearxSearchWrapper
|
||||
|
||||
|
||||
class SearxSearchWrapperComponent(CustomComponent):
|
||||
display_name = "SearxSearchWrapper"
|
||||
description = "Wrapper for Searx API."
|
||||
|
|
@ -8,17 +10,12 @@ class SearxSearchWrapperComponent(CustomComponent):
|
|||
def build_config(self):
|
||||
return {
|
||||
"headers": {
|
||||
"field_type":"dict",
|
||||
"field_type": "dict",
|
||||
"display_name": "Headers",
|
||||
"multiline": True,
|
||||
"value": '{"Authorization": "Bearer <token>"}'
|
||||
},
|
||||
"k": {
|
||||
"display_name": "k",
|
||||
"advanced": True,
|
||||
"field_type": "int",
|
||||
"value": 10
|
||||
"value": '{"Authorization": "Bearer <token>"}',
|
||||
},
|
||||
"k": {"display_name": "k", "advanced": True, "field_type": "int", "value": 10},
|
||||
"searx_host": {
|
||||
"display_name": "Searx Host",
|
||||
"field_type": "str",
|
||||
|
|
@ -32,5 +29,5 @@ class SearxSearchWrapperComponent(CustomComponent):
|
|||
k: Optional[int] = 10,
|
||||
headers: Optional[Dict[str, str]] = None,
|
||||
searx_host: Optional[str] = None,
|
||||
)->SearxSearchWrapper:
|
||||
return SearxSearchWrapper(headers=headers,k=k,searx_host=searx_host)
|
||||
) -> SearxSearchWrapper:
|
||||
return SearxSearchWrapper(headers=headers, k=k, searx_host=searx_host)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from langflow import CustomComponent
|
|||
from typing import Callable, Union
|
||||
from langchain_community.utilities.serpapi import SerpAPIWrapper
|
||||
|
||||
|
||||
class SerpAPIWrapperComponent(CustomComponent):
|
||||
display_name = "SerpAPIWrapper"
|
||||
description = "Wrapper around SerpAPI"
|
||||
|
|
@ -9,7 +10,13 @@ class SerpAPIWrapperComponent(CustomComponent):
|
|||
def build_config(self):
|
||||
return {
|
||||
"serpapi_api_key": {"display_name": "SerpAPI API Key", "type": "str", "password": True},
|
||||
"params": {"display_name": "Parameters", "type": "dict","advanced":True, "multiline": True,"value": '{"engine": "google","google_domain": "google.com","gl": "us","hl": "en"}'},
|
||||
"params": {
|
||||
"display_name": "Parameters",
|
||||
"type": "dict",
|
||||
"advanced": True,
|
||||
"multiline": True,
|
||||
"value": '{"engine": "google","google_domain": "google.com","gl": "us","hl": "en"}',
|
||||
},
|
||||
}
|
||||
|
||||
def build(
|
||||
|
|
@ -17,7 +24,4 @@ class SerpAPIWrapperComponent(CustomComponent):
|
|||
serpapi_api_key: str,
|
||||
params: dict,
|
||||
) -> Union[SerpAPIWrapper, Callable]: # Removed quotes around SerpAPIWrapper
|
||||
return SerpAPIWrapper(
|
||||
serpapi_api_key=serpapi_api_key,
|
||||
params=params
|
||||
)
|
||||
return SerpAPIWrapper(serpapi_api_key=serpapi_api_key, params=params)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Union, Callable
|
||||
from langchain_community.utilities.wikipedia import WikipediaAPIWrapper
|
||||
|
||||
# Assuming WikipediaAPIWrapper is a class that needs to be imported.
|
||||
# The import statement is not included as it is not provided in the JSON
|
||||
# The import statement is not included as it is not provided in the JSON
|
||||
# and the actual implementation details are unknown.
|
||||
|
||||
|
||||
class WikipediaAPIWrapperComponent(CustomComponent):
|
||||
display_name = "WikipediaAPIWrapper"
|
||||
description = "Wrapper around WikipediaAPI."
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from typing import Callable, Union
|
||||
from langchain_community.utilities.wolfram_alpha import WolframAlphaAPIWrapper
|
||||
# Since all the fields in the JSON have show=False, we will only create a basic component
|
||||
# without any configurable fields.
|
||||
|
||||
|
||||
class WolframAlphaAPIWrapperComponent(CustomComponent):
|
||||
display_name = "WolframAlphaAPIWrapper"
|
||||
description = "Wrapper for Wolfram Alpha."
|
||||
|
||||
def build_config(self):
|
||||
return {
|
||||
"appid": {"display_name": "App ID", "type": "str", "password": True}
|
||||
}
|
||||
return {"appid": {"display_name": "App ID", "type": "str", "password": True}}
|
||||
|
||||
def build(self,appid:str) -> Union[Callable, WolframAlphaAPIWrapper]:
|
||||
return WolframAlphaAPIWrapper(wolfram_alpha_appid=appid)
|
||||
def build(self, appid: str) -> Union[Callable, WolframAlphaAPIWrapper]:
|
||||
return WolframAlphaAPIWrapper(wolfram_alpha_appid=appid)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain_community.vectorstores.faiss import FAISS
|
||||
from typing import Optional, List, Union
|
||||
|
|
@ -9,6 +8,7 @@ from langflow.field_typing import (
|
|||
Embeddings,
|
||||
)
|
||||
|
||||
|
||||
class FAISSComponent(CustomComponent):
|
||||
display_name = "FAISS"
|
||||
description = "Construct FAISS wrapper from raw documents."
|
||||
|
|
@ -24,5 +24,5 @@ class FAISSComponent(CustomComponent):
|
|||
self,
|
||||
embedding: Embeddings,
|
||||
documents: Optional[List[Document]] = None,
|
||||
) -> Union[VectorStore,FAISS,BaseRetriever]:
|
||||
return FAISS.from_documents(documents=documents,embedding=embedding)
|
||||
) -> Union[VectorStore, FAISS, BaseRetriever]:
|
||||
return FAISS.from_documents(documents=documents, embedding=embedding)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.vectorstores import MongoDBAtlasVectorSearch
|
||||
from typing import Optional, List
|
||||
|
|
@ -8,6 +7,7 @@ from langflow.field_typing import (
|
|||
NestedDict,
|
||||
)
|
||||
|
||||
|
||||
class MongoDBAtlasComponent(CustomComponent):
|
||||
display_name = "MongoDB Atlas"
|
||||
description = "Construct a `MongoDB Atlas Vector Search` vector store from raw documents."
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ from langflow.field_typing import (
|
|||
from langchain.schema import BaseRetriever
|
||||
from langchain.vectorstores.base import VectorStore
|
||||
import pinecone
|
||||
|
||||
|
||||
class PineconeComponent(CustomComponent):
|
||||
display_name = "Pinecone"
|
||||
description = "Construct Pinecone wrapper from raw documents."
|
||||
|
|
@ -18,8 +20,8 @@ class PineconeComponent(CustomComponent):
|
|||
"embedding": {"display_name": "Embedding", "default": 1000},
|
||||
"index_name": {"display_name": "Index Name"},
|
||||
"namespace": {"display_name": "Namespace"},
|
||||
"pinecone_api_key": {"display_name": "Pinecone API Key", "default": "","password": True,"required": True},
|
||||
"pinecone_env": {"display_name": "Pinecone Environment", "default": "","required": True},
|
||||
"pinecone_api_key": {"display_name": "Pinecone API Key", "default": "", "password": True, "required": True},
|
||||
"pinecone_env": {"display_name": "Pinecone Environment", "default": "", "required": True},
|
||||
"search_kwargs": {"display_name": "Search Kwargs", "default": "{}"},
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +32,6 @@ class PineconeComponent(CustomComponent):
|
|||
index_name: Optional[str] = None,
|
||||
pinecone_api_key: Optional[str] = None,
|
||||
pinecone_env: Optional[str] = None,
|
||||
) -> Union[VectorStore,Pinecone,BaseRetriever]:
|
||||
pinecone.init(api_key=pinecone_api_key,environment=pinecone_env)
|
||||
return Pinecone.from_documents(documents=documents,embedding=embedding,index_name=index_name)
|
||||
) -> Union[VectorStore, Pinecone, BaseRetriever]:
|
||||
pinecone.init(api_key=pinecone_api_key, environment=pinecone_env)
|
||||
return Pinecone.from_documents(documents=documents, embedding=embedding, index_name=index_name)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from langflow import CustomComponent
|
||||
from typing import Optional, List,Union
|
||||
from typing import Optional, List, Union
|
||||
from langchain_community.vectorstores.supabase import SupabaseVectorStore
|
||||
from langflow.field_typing import (
|
||||
Document,
|
||||
|
|
@ -35,6 +35,13 @@ class SupabaseComponent(CustomComponent):
|
|||
supabase_service_key: str = "",
|
||||
supabase_url: str = "",
|
||||
table_name: str = "",
|
||||
) -> Union[VectorStore,SupabaseVectorStore,BaseRetriever]:
|
||||
) -> Union[VectorStore, SupabaseVectorStore, BaseRetriever]:
|
||||
supabase: Client = create_client(supabase_url, supabase_key=supabase_service_key)
|
||||
return SupabaseVectorStore.from_documents(documents=documents,embedding=embedding,query_name=query_name,search_kwargs=search_kwargs,client=supabase,table_name=table_name)
|
||||
return SupabaseVectorStore.from_documents(
|
||||
documents=documents,
|
||||
embedding=embedding,
|
||||
query_name=query_name,
|
||||
search_kwargs=search_kwargs,
|
||||
client=supabase,
|
||||
table_name=table_name,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import weaviate # type: ignore
|
||||
from typing import Optional, Union
|
||||
from langflow import CustomComponent
|
||||
|
||||
from langchain.vectorstores import Weaviate
|
||||
from langchain.schema import Document
|
||||
from langchain.vectorstores.base import VectorStore
|
||||
from langchain.schema import BaseRetriever
|
||||
import weaviate # type: ignore
|
||||
from langchain.embeddings.base import Embeddings
|
||||
from langchain.schema import BaseRetriever, Document
|
||||
from langchain.vectorstores import Weaviate
|
||||
from langchain.vectorstores.base import VectorStore
|
||||
|
||||
from langflow import CustomComponent
|
||||
|
||||
|
||||
class WeaviateVectorStore(CustomComponent):
|
||||
|
|
@ -45,7 +45,7 @@ class WeaviateVectorStore(CustomComponent):
|
|||
search_by_text: bool = False,
|
||||
api_key: Optional[str] = None,
|
||||
index_name: Optional[str] = None,
|
||||
text_key: Optional[str] = "text",
|
||||
text_key: str = "text",
|
||||
embedding: Optional[Embeddings] = None,
|
||||
documents: Optional[Document] = None,
|
||||
attributes: Optional[list] = None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue