Tachi67 commited on
Commit
33af44a
·
1 Parent(s): 4ea6de0

Upload run_ExtendLibrary.py

Browse files
Files changed (1) hide show
  1. run_ExtendLibrary.py +34 -11
run_ExtendLibrary.py CHANGED
@@ -16,6 +16,8 @@ logging.set_verbosity_debug()
16
  logging.auto_set_dir()
17
 
18
  dependencies = [
 
 
19
  {"url": "Tachi67/ExtendLibraryFlowModule", "revision": "main"},
20
  {"url": "Tachi67/AbstractBossFlowModule", "revision": "main"},
21
  {"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"},
@@ -34,30 +36,51 @@ if __name__ == "__main__":
34
  api_information = [ApiInfo(backend_used="openai", api_key=os.getenv("OPENAI_API_KEY"))]
35
  path_to_output_file = None
36
 
37
- # ~~~ setting api information into config ~~~
38
  current_dir = os.getcwd()
39
- cfg_path = os.path.join(current_dir, "CodeWriterFlow.yaml")
40
  cfg = read_yaml_file(cfg_path)
41
- cfg["subflows_config"]["Controller"]["backend"]["api_infos"] = api_information
42
- cfg["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["CodeGenerator"]["backend"]["api_infos"] = api_information
 
 
 
 
 
 
43
 
44
- # ~~~ setting code library into config ~~~
45
  code_lib_file_loc = os.path.join(current_dir, "library.py")
 
 
46
  with open(code_lib_file_loc, 'w') as file:
47
  pass
48
- cfg["subflows_config"]["Executor"]["subflows_config"]["write_code"]["memory_files"] = {"code_library": code_lib_file_loc}
49
- cfg["subflows_config"]["Executor"]["subflows_config"]["test"]["memory_files"] = {"code_library": code_lib_file_loc}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  # ~~~ instantiating the flow and input data ~~~
52
- CodeWriterFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
53
  input_data = {
54
- "goal": "create a function that adds two numbers and returns the result",
55
  }
56
  input_message = InputMessage.build(
57
  data_dict=input_data,
58
  src_flow="Launcher",
59
- dst_flow=CodeWriterFlow.name
60
  )
61
 
62
  # ~~~ calling the flow ~~~
63
- output_message = CodeWriterFlow(input_message)
 
16
  logging.auto_set_dir()
17
 
18
  dependencies = [
19
+ {"url": "aiflows/HumanStandardInputFlowModule", "revision": "5683a922372c5fa90be9f6447d6662d8d80341fc"},
20
+ {"url": "aiflows/ChatFlowModule", "revision": "a749ad10ed39776ba6721c37d0dc22af49ca0f17"},
21
  {"url": "Tachi67/ExtendLibraryFlowModule", "revision": "main"},
22
  {"url": "Tachi67/AbstractBossFlowModule", "revision": "main"},
23
  {"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"},
 
36
  api_information = [ApiInfo(backend_used="openai", api_key=os.getenv("OPENAI_API_KEY"))]
37
  path_to_output_file = None
38
 
 
39
  current_dir = os.getcwd()
40
+ cfg_path = os.path.join(current_dir, "ExtendLibraryFlow.yaml")
41
  cfg = read_yaml_file(cfg_path)
42
+ # ~~~ setting api information into config ~~~
43
+ cfg["subflows_config"]["Planner"]["subflows_config"]["Controller"]["backend"]["api_infos"] = api_information
44
+ cfg["subflows_config"]["Planner"]["subflows_config"]["Executor"]["subflows_config"]["write_plan"]["subflows_config"]["PlanGenerator"]["backend"]["api_infos"] = api_information
45
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Controller"]["backend"]["api_infos"] = api_information
46
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["Controller"]["backend"]["api_infos"] = api_information
47
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["CodeGenerator"]["backend"]["api_infos"] = api_information
48
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["re_plan"]["subflows_config"]["Controller"]["backend"]["api_infos"] = api_information
49
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["re_plan"]["subflows_config"]["Executor"]["subflows_config"]["write_plan"]["subflows_config"]["PlanGenerator"]["backend"]["api_infos"] = api_information
50
 
51
+ # ~~~ setting memory files into config ~~~
52
  code_lib_file_loc = os.path.join(current_dir, "library.py")
53
+ plan_file_loc = os.path.join(current_dir, "plan_extlib.txt")
54
+ logs_file_loc = os.path.join(current_dir, "logs_extlib.txt")
55
  with open(code_lib_file_loc, 'w') as file:
56
  pass
57
+ with open(plan_file_loc, 'w') as file:
58
+ pass
59
+ with open(logs_file_loc, 'w') as file:
60
+ pass
61
+ memfiles_extlib = {}
62
+ memfiles_writecode_interactivecoder = {}
63
+ memfiles_writecode_test = {}
64
+ memfiles_extlib["plan"] = plan_file_loc
65
+ memfiles_extlib["logs"] = logs_file_loc
66
+ memfiles_extlib["code_library"] = code_lib_file_loc
67
+ memfiles_writecode_interactivecoder["code_library"] = code_lib_file_loc
68
+ memfiles_writecode_test["code_library"] = code_lib_file_loc
69
+ cfg["memory_files"] = memfiles_extlib
70
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["Executor"]["subflows_config"]["write_code"]["memory_files"] = memfiles_writecode_interactivecoder
71
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["Executor"]["subflows_config"]["test"]["memory_files"] = memfiles_writecode_test
72
+
73
 
74
  # ~~~ instantiating the flow and input data ~~~
75
+ ExtendLibraryFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
76
  input_data = {
77
+ "goal": "Write a function that adds up two numbers",
78
  }
79
  input_message = InputMessage.build(
80
  data_dict=input_data,
81
  src_flow="Launcher",
82
+ dst_flow=ExtendLibraryFlow.name
83
  )
84
 
85
  # ~~~ calling the flow ~~~
86
+ output_message = ExtendLibraryFlow(input_message)