From 37d339f9d105bd753ba52ee68687e30efa3e8cb9 Mon Sep 17 00:00:00 2001 From: Kittensx Date: Mon, 9 Dec 2024 21:39:21 -0800 Subject: [PATCH] Add files via upload --- 02_ Or Functionality/prompt_parser.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/02_ Or Functionality/prompt_parser.py b/02_ Or Functionality/prompt_parser.py index 6cfa260..24cbb06 100644 --- a/02_ Or Functionality/prompt_parser.py +++ b/02_ Or Functionality/prompt_parser.py @@ -146,6 +146,12 @@ def collect_steps(steps, tree): #print("Invalid tree structure:", tree) #return [] res = [steps] # Always include the final step + def resolve_tree(tree): + """Recursively resolve a tree node to its final string representation.""" + if isinstance(tree, lark.Tree): + # Recursively resolve each child + return "".join(resolve_tree(child) for child in tree.children) + return str(tree) class CollectSteps(lark.Visitor): def alternate1(self, tree):