Skip to content

Commit

Permalink
Update chat.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gsukanto authored Aug 13, 2024
1 parent ae6d7f2 commit aff91ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/app/usecases/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def trace_to_root(
"""Trace message map from leaf node to root node."""
result = []
if not node_id or node_id == "system":
node_id = "instruction" if "instruction" in message_map else "system"
if message_map:
node_id = list(message_map.keys())[-1]
else:
node_id = "system"

current_node = message_map.get(node_id)
while current_node:
Expand Down

0 comments on commit aff91ec

Please sign in to comment.