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