File size: 867 Bytes
0f3ad1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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())