Skip to content

Commit

Permalink
modify run_action on helper to adjust for spaces cpu computing-disabl…
Browse files Browse the repository at this point in the history
…e llama guard
  • Loading branch information
prgrmcode committed Dec 31, 2024
1 parent f64c5f4 commit 74a57f9
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,35 +595,31 @@ def run_action(message: str, history: list, game_state: Dict) -> str:
print(f"\nSafety Check Result: {'SAFE' if safe else 'UNSAFE'}")
logger.info(f"Safety check result: {'SAFE' if safe else 'UNSAFE'}")

if not safe:
logging.warning("Unsafe content detected - blocking response")
print("Unsafe content detected - Response blocked")
return "This response was blocked for safety reasons."

# # Add quest progress checks
# if game_state["current_quest"]:
# quest = game_state["current_quest"]
# # Check for quest completion keywords
# if any(
# word in message.lower() for word in ["investigate", "explore", "search"]
# ):
# if (
# "mist" in message.lower()
# and quest["title"] == "Investigate the Mist"
# ):
# game_state["player"].complete_quest(quest)
# response += "\n\nQuest Complete: Investigate the Mist! (+100 exp)"

if safe:
# Check for quest completion
quest_completed, quest_message = check_quest_completion(message, game_state)
if quest_completed:
response += quest_message

# Check for item updates
inventory_update = update_game_inventory(game_state, response)
if inventory_update:
response += inventory_update
# if not safe:
# logging.warning("Unsafe content detected - blocking response")
# print("Unsafe content detected - Response blocked")
# return "This response was blocked for safety reasons."

# if safe:
# # Check for quest completion
# quest_completed, quest_message = check_quest_completion(message, game_state)
# if quest_completed:
# response += quest_message

# # Check for item updates
# inventory_update = update_game_inventory(game_state, response)
# if inventory_update:
# response += inventory_update

# Check for quest completion
quest_completed, quest_message = check_quest_completion(message, game_state)
if quest_completed:
response += quest_message

# Check for item updates
inventory_update = update_game_inventory(game_state, response)
if inventory_update:
response += inventory_update

# Validate response
return response if response else "You look around carefully."
Expand Down

0 comments on commit 74a57f9

Please sign in to comment.