Mini_DungeonGame / main.py
sqfoo's picture
Upload folder using huggingface_hub
0f3ad1b verified
Raw
History Blame Contribute Delete
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())