-
Notifications
You must be signed in to change notification settings - Fork 3
/
main2.py
77 lines (67 loc) · 2.56 KB
/
main2.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import argparse
from voyager import MultiAgentVoyager
import time
from api_keys import openai_api_key
from datetime import datetime
import voyager.utils as U
# Argument parser
parser = argparse.ArgumentParser(description='Running Voyager with different sets of parameters.')
parser.add_argument('--port', type=int, default=49172, help='MC port number (default: 49172)')
# parser.add_argument('--server_port', type=int, default=3000, help='Server port number (default: 3000)')
args = parser.parse_args()
mc_port = args.port
options = {
'azure_login': None,
'mc_port': mc_port,
'openai_api_key': openai_api_key,
# skill_library_dir=skill_library_dir, # Load a learned skill library.
# ckpt_dir: ckpt_dir, # Feel free to use a new dir. Do not use the same dir as skill library because new events will still be recorded to ckpt_dir.
'resume':False, # Do not resume from a skill library because this is not learning.
'env_wait_ticks':80,
# 'env_request_timeout': 600,
'action_agent_task_max_retries':50,
'action_agent_show_chat_log':True,
'action_agent_temperature':0.3,
'action_agent_model_name': "gpt-4-0613", # #"gpt-4-0613",
'critic_agent_model_name': "gpt-4-0613", #"gpt-3.5-turbo", #"gpt-4-0613",
}
multi_options = {
'scenario_file': "cleanup.json",
'continuous': True,
'episode_timeout': 120, #120,
'num_episodes': 1,
'negotiator_model_name': "gpt-4-0613",
'negotiator_temperature': 0.7,
'options': options
}
start_time = time.time()
for contract_i in range(4, 10):
save_dir = f"saves/cleanup/contract{contract_i}"
U.f_mkdir(save_dir)
contract_env = MultiAgentVoyager(
**multi_options,
contract_mode = "auto",
save_dir=f"{save_dir}/contract_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
)
contract_env.load_scenario(reset='hard')
for i in range(3):
try:
contract_env.negotiate_contract()
break
except:
print('negotiation failed')
continue
if contract_env.contract is None:
raise Exception('Contract negotiation failed after 3 tries')
contract = contract_env.contract
contract_env.close()
for game in range(5):
multi_agent = MultiAgentVoyager(
**multi_options,
contract_mode = "manual",
contract=contract,
save_dir=f"{save_dir}/game{game}_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
)
multi_agent.run()
multi_agent.close()
print(f"Contract {contract} completed. {time.time() - start_time} seconds elapsed.")