Bladeren bron

Improve error message for missing action in output

Updated error handling to provide clearer feedback when no action is found in model output.
lime_ning 5 maanden geleden
bovenliggende
commit
6aa6e97b4d
1 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen
  1. 5 2
      docs/chapter1/Chapter1-Introduction-to-Agents.md

+ 5 - 2
docs/chapter1/Chapter1-Introduction-to-Agents.md

@@ -431,8 +431,11 @@ for i in range(5): # Set maximum number of loops
     # 3.3. Parse and execute action
     action_match = re.search(r"Action: (.*)", llm_output, re.DOTALL)
     if not action_match:
-        print("Parse error: Action not found in model output.")
-        break
+        observation = "Error: No action found. Please explicitly use Action: finish(...) or other actions."
+        observation_str = f"Observation: {observation}"
+        print(f"{observation_str}\n" + "="*40)
+        prompt_history.append(observation_str)
+        continue
     action_str = action_match.group(1).strip()
 
     if action_str.startswith("finish"):