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: Enable sorting of chat inputs to improve UI message speed #4480

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/backend/base/langflow/graph/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,8 @@ def sort_vertices(

vertices_layers = self.layered_topological_sort(vertices)
vertices_layers = self.sort_by_avg_build_time(vertices_layers)
# vertices_layers = self.sort_chat_inputs_first(vertices_layers)
# Sort the chat inputs first to speed up sending the User message to the UI
vertices_layers = self.sort_chat_inputs_first(vertices_layers)
# Now we should sort each layer in a way that we make sure
# vertex V does not depend on vertex V+1
vertices_layers = self.sort_layer_by_dependency(vertices_layers)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/unit/test_chat_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def consume_and_assert_stream(r):
assert parsed["event"] == "vertices_sorted"
ids = parsed["data"]["ids"]
ids.sort()
assert ids == ["ChatInput-CIGht", "Memory-amN4Z"]
assert ids == ["ChatInput-CIGht"]

to_run = parsed["data"]["to_run"]
to_run.sort()
Expand Down
2 changes: 1 addition & 1 deletion src/backend/tests/unit/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async def test_get_vertices(client, added_flow_webhook_test, logged_in_headers):
# The important part is before the - (ConversationBufferMemory, PromptTemplate, ChatOpenAI, LLMChain)
ids = [_id.split("-")[0] for _id in response.json()["ids"]]

assert set(ids) == {"Webhook", "ChatInput"}
assert set(ids) == {"ChatInput"}


async def test_build_vertex_invalid_flow_id(client, logged_in_headers):
Expand Down
Loading