Add STARTER_FOLDER_NAME filter to read_flows function

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-06 11:37:19 -03:00
commit 308c27c381

View file

@ -10,6 +10,7 @@ from sqlmodel import Session, select
from langflow.api.utils import remove_api_keys, validate_is_component
from langflow.api.v1.schemas import FlowListCreate, FlowListRead
from langflow.initial_setup.setup import STARTER_FOLDER_NAME
from langflow.services.auth.utils import get_current_active_user
from langflow.services.database.models.flow import (
Flow,
@ -57,7 +58,9 @@ def read_flows(
# with the session get the flows that DO NOT have a user_id
try:
example_flows = session.exec(
select(Flow).where(Flow.user_id == None)
select(Flow).where(
Flow.user_id == None, Flow.folder == STARTER_FOLDER_NAME
)
).all() # noqa
flows.extend(example_flows)
except Exception as e: