forked from danmohad/khod-kaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkhod_kaar.py
55 lines (39 loc) · 1.93 KB
/
khod_kaar.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
"""
File: khod_kaar.py
Author: Danyal Mohaddes
Description: This file contains the top-level functions for running the program.
"""
import argparse
from Roles import Roles
from Agent import Agent
def khod_kaar(agent) -> None:
"""Top-level function to allow integration tests in CI.
Arguments:
none
Returns:
none"""
while not agent.satisfied():
agent.memory.memorize(agent.model.send_prompt(agent.memory.memories), Roles.assistant.name)
agent.status_check()
agent.memory.memorize(agent.system.execute(agent.memory.memories[-1]['content']), Roles.user.name)
agent.status_check()
agent.memory.short_to_long_term()
def parse_args() -> argparse.Namespace:
"""Wrapper function for argparse to perform command-line argument parsing.
Arguments:
none
Returns:
object containing parsed command-line arguments"""
# Initialize parser
parser = argparse.ArgumentParser()
# Add optional arguments for ease of testing
parser.add_argument("-o", "--objective", help = "Input objective (starting with the word 'to ...')", type=str)
parser.add_argument("-t", "--temperature", help = "Input LLM prompting temperature [0,1] (default: 1.0)", type=float, default=1.0)
parser.add_argument("-m", "--model", help = "Input LLM model (default: gpt-4)", type=str, default="gpt-4")
parser.add_argument("-d", "--output_dir", help = "Directory on disk to save outputs (default: ./output/)", type=str, default="./output/")
parser.add_argument("-a", "--autopilot", help = "DANGEROUS: accept all commands until program self-terminates", action=argparse.BooleanOptionalAction)
# Read and return arguments from command line
return parser.parse_args()
if __name__ == "__main__":
"""Clause to allow running the program as an executable."""
khod_kaar(Agent(parse_args()))