diff --git a/cookbook/frozenlake/frozenlake_react_agent.py b/cookbook/frozenlake/frozenlake_react_agent.py index 4f6538d5..1dceb0ea 100644 --- a/cookbook/frozenlake/frozenlake_react_agent.py +++ b/cookbook/frozenlake/frozenlake_react_agent.py @@ -68,10 +68,7 @@ class FrozenLakeReactAgent: return yaml.safe_load(f) except FileNotFoundError: logger.warning("Prompt file not found, using default prompts") - return { - "frozenlake_sys_prompt_no_slippery": "You are playing FrozenLake. Navigate from S to G avoiding H.", - "frozenlake_sys_prompt_slippery": "You are playing FrozenLake. Navigate from S to G avoiding H. Ice is slippery!" - } + raise FileNotFoundError("Prompt file not found. Please check your current path (should be ./cook/frozenlake) and try again.") def call_llm(self, messages: List[Dict]) -> str: """Call LLM with retry logic""" @@ -158,8 +155,7 @@ class FrozenLakeReactAgent: r'["\']action["\']\s*:\s*["\']([0-3])["\']', r'"action"\s*:\s*"([0-3])"', r"'action'\s*:\s*'([0-3])'", - r'\baction["\']?\s*[:=]\s*["\']?([0-3])', - r'\b([0-3])\b(?=\s*$)', # Single digit at end + r'\baction["\']?\s*[:=]\s*["\']?([0-3])' ] for pattern in patterns: @@ -223,6 +219,7 @@ class FrozenLakeReactAgent: for step in range(self.max_steps): # Get action from LLM response = self.call_llm(messages) + logger.info(response) action = self.action_parser(response) messages.append({"role": "assistant", "content": response}) diff --git a/cookbook/frozenlake/quickstart.md b/cookbook/frozenlake/quickstart.md index bed7afaa..2dbd81b0 100644 --- a/cookbook/frozenlake/quickstart.md +++ b/cookbook/frozenlake/quickstart.md @@ -51,10 +51,13 @@ reme \ vector_store.default.backend=local ``` -Load default memory library for FrozenLake: +Add your api key for agent: ```bash +export OPENAI_API_KEY="xxx" +export OPENAI_BASE_URL="xxx" ``` + ## Run Experiments ### 1. Quick Test: Performance Evaluation Only (Default) @@ -62,6 +65,7 @@ Load default memory library for FrozenLake: Run the main experiment script to test agent performance using existing memory: ```bash +cd cookbook/frozenlake python run_frozenlake.py ``` @@ -131,14 +135,6 @@ python run_exp_statistic.py - Calculates performance metrics - Generates comparative analysis -## Understanding Results - -The experiment evaluates agent performance on FrozenLake maps: - -- **Success Rate**: Percentage of episodes where the agent reaches the goal -- **With vs. Without Memory**: Compares performance with and without task memory -- **Slippery vs. Non-slippery**: Compares performance in different environment dynamics - ### Output Files - `./exp_result/*_training.jsonl`: Results from training phase