From e5ffea6401319e0096fbac194fb853977b32f077 Mon Sep 17 00:00:00 2001 From: kumaranant1 Date: Sat, 4 Apr 2026 03:58:28 +0530 Subject: [PATCH] fix: prompt formation bug --- step_anticipation/src/models/llm_hf.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/step_anticipation/src/models/llm_hf.py b/step_anticipation/src/models/llm_hf.py index 3c65463..8a43394 100644 --- a/step_anticipation/src/models/llm_hf.py +++ b/step_anticipation/src/models/llm_hf.py @@ -144,17 +144,9 @@ def anticipation( else: remove_toySequence = False - # ! Don't know why it was inside the loop - # >>> prompt_builder = load_data(f"{CONTEXT_PROMPT_PATH}/context_prompt.json") init = prompt_builder[prompt_context]["init"] - if remove_toySequence: - prompt_ = f"{prompt}{init} {toy_class}\n" - else: - prompt_ = f"{prompt}{init} {toy}\n" - # <<< - for i in range(len(seq)): if type_prompt == "emoji": hist, action = ["👉"] + seq[:i], seq[i] @@ -169,6 +161,12 @@ def anticipation( print(f"[INFO] >>> {hist} -> {action}") + # reinitialize prompt_ for each step + if remove_toySequence: + prompt_ = f"{prompt}{init} {toy_class}\n" + else: + prompt_ = f"{prompt}{init} {toy}\n" + input_builder = prompt_builder[prompt_context]["input"] prompt_ += f"{input_builder}\n {', '.join(map(str, hist))}\n"