Spaces:
Sleeping
Sleeping
Download main.py from sqfoo/Mini_DungeonGame: direct link, hf CLI and curl.
- Browser
- Download file 867 Bytes
-
https://huggingface.co/spaces/sqfoo/Mini_DungeonGame/resolve/ccef4f75d3396d2c62de856476f48383c8b7e2d4/main.py
- Command line
-
hf download hf://spaces/sqfoo/Mini_DungeonGame@ccef4f75d3396d2c62de856476f48383c8b7e2d4/main.py
-
curl -L -o main.py https://huggingface.co/spaces/sqfoo/Mini_DungeonGame/resolve/ccef4f75d3396d2c62de856476f48383c8b7e2d4/main.py
867 Bytes
| from dotenv import load_dotenv | |
| load_dotenv('./.env') | |
| from settings import EVENTS | |
| from player import Player | |
| from llm import * | |
| from utils import PROMPT, INPUT_PROMPT, extract_after_final_answer | |
| loc = 0 | |
| cur = EVENTS[loc] | |
| player = Player('player-1') | |
| model = setup_model(HUGGINGFACE) | |
| while loc != -1 and loc < 10: | |
| print(f'Title: {cur.get_title()}') | |
| print(f'{cur.get_description()}') | |
| response = input("Human Response: ") | |
| response = model.invoke(PROMPT + INPUT_PROMPT.format(response)) | |
| response = extract_after_final_answer(response.content) | |
| loc = cur._next(response, player) | |
| attribute = player.get_attribute() | |
| print(response, loc) | |
| if attribute['hp'] <= 0 or attribute['mp'] <= 0: | |
| loc = -1 | |
| cur = EVENTS[loc] | |
| print('*'*20) | |
| print(f'Title: {cur.get_title()}') | |
| print(f'{cur.get_description()}') | |
| print(player.get_attribute()) | |