Spaces:
Sleeping
Sleeping
put every f string into verbose (because f string only support \ for python 3.12+)
Browse files
agent.py
CHANGED
|
@@ -285,7 +285,8 @@ class StudentAgent:
|
|
| 285 |
|
| 286 |
old_state = current_state
|
| 287 |
if current_location != last_location:
|
| 288 |
-
|
|
|
|
| 289 |
observation += f"\n[INFO] You have moved from {last_location} to a new location: {current_location}."
|
| 290 |
if current_location in locations_visited and current_state in self.location_state.get(current_location, set()):
|
| 291 |
observation += " You've been here before, read the observation carefully, is it new? If not return where you came."
|
|
@@ -372,7 +373,8 @@ class StudentAgent:
|
|
| 372 |
# Track location
|
| 373 |
location = await client.call_tool("current_location", {})
|
| 374 |
location = self._extract_result(location)
|
| 375 |
-
|
|
|
|
| 376 |
last_location = current_location
|
| 377 |
current_location = location
|
| 378 |
if current_location != last_location:
|
|
@@ -404,7 +406,8 @@ class StudentAgent:
|
|
| 404 |
self.internal_map[new_position[0]][new_position[1]][new_position[2]] = "Inaccessible"
|
| 405 |
self.position = new_position
|
| 406 |
else:
|
| 407 |
-
|
|
|
|
| 408 |
# Update history
|
| 409 |
self.history.append({
|
| 410 |
"step": step,
|
|
@@ -443,10 +446,12 @@ class StudentAgent:
|
|
| 443 |
else:
|
| 444 |
self.location_state[current_location] = set([current_obs])
|
| 445 |
|
| 446 |
-
print(
|
| 447 |
-
print(f"
|
| 448 |
-
|
| 449 |
-
|
|
|
|
|
|
|
| 450 |
|
| 451 |
return RunResult(
|
| 452 |
final_score=self.score,
|
|
@@ -654,7 +659,8 @@ async def test_agent():
|
|
| 654 |
verbose=True,
|
| 655 |
)
|
| 656 |
|
| 657 |
-
print(
|
|
|
|
| 658 |
print(f"Final Score: {result.final_score}")
|
| 659 |
print(f"Moves: {result.moves}")
|
| 660 |
print(f"Locations: {len(result.locations_visited)}")
|
|
|
|
| 285 |
|
| 286 |
old_state = current_state
|
| 287 |
if current_location != last_location:
|
| 288 |
+
if verbose:
|
| 289 |
+
print(f"[DEBUG] Moved to new location: {current_location}. Resetting tried actions for this state.")
|
| 290 |
observation += f"\n[INFO] You have moved from {last_location} to a new location: {current_location}."
|
| 291 |
if current_location in locations_visited and current_state in self.location_state.get(current_location, set()):
|
| 292 |
observation += " You've been here before, read the observation carefully, is it new? If not return where you came."
|
|
|
|
| 373 |
# Track location
|
| 374 |
location = await client.call_tool("current_location", {})
|
| 375 |
location = self._extract_result(location)
|
| 376 |
+
if verbose:
|
| 377 |
+
print(f"[DEBUG] Current location: {location}")
|
| 378 |
last_location = current_location
|
| 379 |
current_location = location
|
| 380 |
if current_location != last_location:
|
|
|
|
| 406 |
self.internal_map[new_position[0]][new_position[1]][new_position[2]] = "Inaccessible"
|
| 407 |
self.position = new_position
|
| 408 |
else:
|
| 409 |
+
if verbose:
|
| 410 |
+
print(f"[DEBUG] New position {new_position} is out of bounds. Not updating position.")
|
| 411 |
# Update history
|
| 412 |
self.history.append({
|
| 413 |
"step": step,
|
|
|
|
| 446 |
else:
|
| 447 |
self.location_state[current_location] = set([current_obs])
|
| 448 |
|
| 449 |
+
print()
|
| 450 |
+
print(f"[FINAL SCORE] {self.score} after {moves} moves and visiting {len(locations_visited)} locations.")
|
| 451 |
+
if verbose:
|
| 452 |
+
print(f"The locations are: {', '.join(locations_visited)}")
|
| 453 |
+
print(f"Have visited states: {len(self.history_state_tried_action)}")
|
| 454 |
+
print(f"The sates are: \n {'\nState:\n'.join(list(self.history_state_tried_action.keys())[-5:])}")
|
| 455 |
|
| 456 |
return RunResult(
|
| 457 |
final_score=self.score,
|
|
|
|
| 659 |
verbose=True,
|
| 660 |
)
|
| 661 |
|
| 662 |
+
print()
|
| 663 |
+
print(f"{'=' * 50}")
|
| 664 |
print(f"Final Score: {result.final_score}")
|
| 665 |
print(f"Moves: {result.moves}")
|
| 666 |
print(f"Locations: {len(result.locations_visited)}")
|