Repository navigation
Expand file tree
/
Copy pathcli.py
More file actions
58 lines (42 loc) · 1.6 KB
/
Copy pathcli.py
File metadata and controls
58 lines (42 loc) · 1.6 KB
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
import os
# set the environment variable "CONFIG_PATH" to the path of the configuration file
os.environ['CONFIG_PATH'] = "./config/config.yaml"
import torch
from src.coordinator import coordinating
from src.process_pool import DataStructurePool
from src.utils import (print_tips, visualize_agent_response)
def cli():
print_tips("Welcome!", text_color="green", emoji="smiley")
# init_execution_cache()
# init_assessment_cache()
# empty_output_folder()
# set the start method of the multiprocessing module to "spawn"
torch.multiprocessing.set_start_method("spawn")
# create a data structure pool
data_structure_pool = DataStructurePool()
# warm up the pool
data_structure_pool.warmup_pool()
while True:
messages = []
# get input from the user
message = input("[ User ]: ")
if message == "exit":
break
# add the input message to the list of messages
messages.append({"role": "user", "content": message})
# send messages to the coordinator
final_response, results_of_each_stage = coordinating(
messages=messages,
data_structure_pool=data_structure_pool,
return_planning_results=False,
return_execution_results=False,
skip_planning=False,
)
visualize_agent_response(final_response)
print("CLI stopped.")
# release the data structure pool
data_structure_pool.release_pool()
# destroy the data structure pool
del data_structure_pool
if __name__ == "__main__":
cli()