Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider remove_example_flows param on query on GET flows endpoint #3967

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/backend/base/langflow/api/v1/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,20 @@ def read_flows(
flows = [flow for flow in flows if flow.is_component]
flow_ids = [flow.id for flow in flows]
# with the session get the flows that DO NOT have a user_id
folder = session.exec(select(Folder).where(Folder.name == STARTER_FOLDER_NAME)).first()

if not remove_example_flows and not components_only:
try:
folder = session.exec(select(Folder).where(Folder.name == STARTER_FOLDER_NAME)).first()

example_flows = folder.flows if folder else []
for example_flow in example_flows:
if example_flow.id not in flow_ids:
flows.append(example_flow) # type: ignore
except Exception as e:
logger.error(e)

if remove_example_flows:
flows = [flow for flow in flows if flow.folder_id != folder.id]

except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) from e
return [jsonable_encoder(flow) for flow in flows]
Expand Down
Loading