fix: filtering now happening in property when possible
This commit is contained in:
parent
550a1706cf
commit
413d87257b
3 changed files with 15 additions and 8 deletions
|
|
@ -35,7 +35,7 @@ class AgentCreator(LangChainTypeCreator):
|
|||
# Now this is a generator
|
||||
def to_list(self) -> List[str]:
|
||||
names = []
|
||||
for name, agent in self.type_to_loader_dict.items():
|
||||
for _, agent in self.type_to_loader_dict.items():
|
||||
agent_name = (
|
||||
agent.function_name()
|
||||
if hasattr(agent, "function_name")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ class ChainCreator(LangChainTypeCreator):
|
|||
from langflow.interface.chains.custom import CUSTOM_CHAINS
|
||||
|
||||
self.type_dict.update(CUSTOM_CHAINS)
|
||||
# Filter according to settings.chains
|
||||
self.type_dict = {
|
||||
name: chain
|
||||
for name, chain in self.type_dict.items()
|
||||
if name in settings.chains or settings.dev
|
||||
}
|
||||
return self.type_dict
|
||||
|
||||
def get_signature(self, name: str) -> Optional[Dict]:
|
||||
|
|
@ -32,12 +38,8 @@ class ChainCreator(LangChainTypeCreator):
|
|||
def to_list(self) -> List[str]:
|
||||
custom_chains = list(get_custom_nodes("chains").keys())
|
||||
default_chains = list(self.type_to_loader_dict.keys())
|
||||
# Check if the chain is in the settings
|
||||
return [
|
||||
chain
|
||||
for chain in default_chains + custom_chains
|
||||
if chain in settings.chains or settings.dev
|
||||
]
|
||||
|
||||
return default_chains + custom_chains
|
||||
|
||||
|
||||
chain_creator = ChainCreator()
|
||||
|
|
|
|||
|
|
@ -24,12 +24,17 @@ class PromptCreator(LangChainTypeCreator):
|
|||
prompt_name: import_class(f"langchain.prompts.{prompt_name}")
|
||||
# if prompt_name is not lower case it is a class
|
||||
for prompt_name in prompts.__all__
|
||||
if not prompt_name.islower() and prompt_name in settings.prompts
|
||||
}
|
||||
# Merge CUSTOM_PROMPTS into self.type_dict
|
||||
from langflow.interface.prompts.custom import CUSTOM_PROMPTS
|
||||
|
||||
self.type_dict.update(CUSTOM_PROMPTS)
|
||||
# Now filter according to settings.prompts
|
||||
self.type_dict = {
|
||||
name: prompt
|
||||
for name, prompt in self.type_dict.items()
|
||||
if name in settings.prompts or settings.dev
|
||||
}
|
||||
return self.type_dict
|
||||
|
||||
def get_signature(self, name: str) -> Optional[Dict]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue