Tachi67 commited on
Commit
6146371
1 Parent(s): c6a9af7

Upload 16 files

Browse files
Controller_JarvisFlow.yaml CHANGED
@@ -34,7 +34,7 @@ backend:
34
  azure: azure/gpt-4
35
 
36
  commands:
37
- call_coder:
38
  description: "Instruct the coder to write and run code to finish your given goal."
39
  input_args: [ "goal" ]
40
  re_plan:
@@ -77,7 +77,7 @@ system_message_prompt_template:
77
  0.1 Whenever the user demands to quit or terminate the current process, call `manual_finish` command.
78
  0.2 Whenever in doubt, or you have something to ask, or confirm to the user, call `ask_user` with your question.
79
  0.3 During the execution of the plan, if something goes wrong, call the `re_plan` with detailed information about what was wrong.
80
- 1. If the current step of plan can be achieved by writing and running code, call `call_coder` with the goal of the current step of plan.
81
  2. Whenever you have done one step of the plan, do the following:
82
  2.1 Reflect on what plan you are having right now.
83
  2.2 Reflect on which step of the plan you just finished.
@@ -98,11 +98,11 @@ system_message_prompt_template:
98
  ### Beginning of an example execution: ###
99
  Plan: 1. Download the weather data from Paris on 19. Dec. 2021. 2. Send the weather data to an email address. 3. Give a final answer.
100
  Your actions:
101
- 1. Call `call_coder` with the goal of the first step of the plan. Code is written and run, the weather data is downloaded.
102
  2. You call `update_plan` with the plan you just generated, it is exactly the same as the plan you have now, but with the current step of plan marked as done.
103
  3. You call `intermediate_answer` with the result of the step you just finished.
104
  4. The user is happy with the intermediate result, you proceed to the next step of the plan.
105
- 5. Call `call_coder` with the goal of the second step of the plan. Code is written and run, the weather data is sent to an email address.
106
  6. You call `update_plan` with the plan you just generated, it is exactly the same as the plan you have now, but with the current step of plan marked as done.
107
  7. You call `intermediate_answer` with the result of the step you just finished.
108
  8. The user is happy with the intermediate result, you proceed to the next step of the plan.
 
34
  azure: azure/gpt-4
35
 
36
  commands:
37
+ Coder:
38
  description: "Instruct the coder to write and run code to finish your given goal."
39
  input_args: [ "goal" ]
40
  re_plan:
 
77
  0.1 Whenever the user demands to quit or terminate the current process, call `manual_finish` command.
78
  0.2 Whenever in doubt, or you have something to ask, or confirm to the user, call `ask_user` with your question.
79
  0.3 During the execution of the plan, if something goes wrong, call the `re_plan` with detailed information about what was wrong.
80
+ 1. If the current step of plan can be achieved by writing and running code, call `Coder` with the goal of the current step of plan.
81
  2. Whenever you have done one step of the plan, do the following:
82
  2.1 Reflect on what plan you are having right now.
83
  2.2 Reflect on which step of the plan you just finished.
 
98
  ### Beginning of an example execution: ###
99
  Plan: 1. Download the weather data from Paris on 19. Dec. 2021. 2. Send the weather data to an email address. 3. Give a final answer.
100
  Your actions:
101
+ 1. Call `Coder` with the goal of the first step of the plan. Code is written and run, the weather data is downloaded.
102
  2. You call `update_plan` with the plan you just generated, it is exactly the same as the plan you have now, but with the current step of plan marked as done.
103
  3. You call `intermediate_answer` with the result of the step you just finished.
104
  4. The user is happy with the intermediate result, you proceed to the next step of the plan.
105
+ 5. Call `Coder` with the goal of the second step of the plan. Code is written and run, the weather data is sent to an email address.
106
  6. You call `update_plan` with the plan you just generated, it is exactly the same as the plan you have now, but with the current step of plan marked as done.
107
  7. You call `intermediate_answer` with the result of the step you just finished.
108
  8. The user is happy with the intermediate result, you proceed to the next step of the plan.
CtrlExMem_JarvisFlow.yaml CHANGED
@@ -19,11 +19,12 @@ subflows_config:
19
  Executor:
20
  _target_: flows.base_flows.BranchingFlow.instantiate_from_default_config
21
  subflows_config:
22
- call_coder:
23
  _target_: Tachi67.CoderFlowModule.CoderFlow.instantiate_from_default_config
24
  memory_files: ???
25
  subflows_config:
26
  Planner:
 
27
  _target_: Tachi67.CoderFlowModule.Planner_CoderFlow.instantiate_from_default_config
28
  subflows_config:
29
  Controller:
 
19
  Executor:
20
  _target_: flows.base_flows.BranchingFlow.instantiate_from_default_config
21
  subflows_config:
22
+ Coder:
23
  _target_: Tachi67.CoderFlowModule.CoderFlow.instantiate_from_default_config
24
  memory_files: ???
25
  subflows_config:
26
  Planner:
27
+ #TODO remove this line
28
  _target_: Tachi67.CoderFlowModule.Planner_CoderFlow.instantiate_from_default_config
29
  subflows_config:
30
  Controller:
JarvisFlow.yaml CHANGED
@@ -1,7 +1,7 @@
1
  name: JarvisFlow
2
  description: Jarvis, an agent with structured llms and tools able to process user requests, write and execute code, with external memory mechanisms.
3
 
4
- target_: Tachi67.JarvisFlowModule.JarvisFlow.instantiate_from_default_config
5
 
6
  memory_files: ???
7
 
@@ -43,24 +43,6 @@ subflows_config:
43
  azure: azure/gpt-4
44
  Executor:
45
  subflows_config:
46
- re_plan:
47
- subflows_config:
48
- Controller:
49
- backend:
50
- api_infos: ???
51
- model_name:
52
- openai: gpt-4
53
- azure: azure/gpt-4
54
- Executor:
55
- subflows_config:
56
- write_plan:
57
- subflows_config:
58
- PlanGenerator:
59
- backend:
60
- api_infos: ???
61
- model_name:
62
- openai: gpt-4
63
- azure: azure/gpt-4
64
  Coder:
65
  memory_files: ???
66
  subflows_config:
@@ -179,4 +161,22 @@ subflows_config:
179
  api_infos: ???
180
  model_name:
181
  openai: gpt-4
182
- azure: azure/gpt-4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  name: JarvisFlow
2
  description: Jarvis, an agent with structured llms and tools able to process user requests, write and execute code, with external memory mechanisms.
3
 
4
+ _target_: Tachi67.JarvisFlowModule.JarvisFlow.instantiate_from_default_config
5
 
6
  memory_files: ???
7
 
 
43
  azure: azure/gpt-4
44
  Executor:
45
  subflows_config:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  Coder:
47
  memory_files: ???
48
  subflows_config:
 
161
  api_infos: ???
162
  model_name:
163
  openai: gpt-4
164
+ azure: azure/gpt-4
165
+ re_plan:
166
+ subflows_config:
167
+ Controller:
168
+ backend:
169
+ api_infos: ???
170
+ model_name:
171
+ openai: gpt-4
172
+ azure: azure/gpt-4
173
+ Executor:
174
+ subflows_config:
175
+ write_plan:
176
+ subflows_config:
177
+ PlanGenerator:
178
+ backend:
179
+ api_infos: ???
180
+ model_name:
181
+ openai: gpt-4
182
+ azure: azure/gpt-4
Planner_JarvisFlow.yaml CHANGED
@@ -47,7 +47,7 @@ subflows_config:
47
  2. Give a final answer.**
48
 
49
  Here are some criteria you should consider in order to write a good plan:
50
- 1. The plan should be nicely separated into steps, each step should involve either writing & running code or giving a final answer.
51
  2. Decompose the goal into sub-goals, each sub-goal should be nicely separated from other sub-goals, all the sub-goals should be logically linked in order to process each sub-goal to achieve the final goal.
52
 
53
  Performance Evaluation:
 
47
  2. Give a final answer.**
48
 
49
  Here are some criteria you should consider in order to write a good plan:
50
+ 1. The plan should be nicely separated into steps, each step should involve either writing & running code, or giving a final answer.
51
  2. Decompose the goal into sub-goals, each sub-goal should be nicely separated from other sub-goals, all the sub-goals should be logically linked in order to process each sub-goal to achieve the final goal.
52
 
53
  Performance Evaluation:
run_Jarvis.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import hydra
4
+
5
+ from flows.backends.api_info import ApiInfo
6
+ from flows.messages import InputMessage
7
+ from flows.utils.general_helpers import read_yaml_file
8
+ from flows.utils.general_helpers import update_api_infos
9
+
10
+ from flows import logging
11
+ from flows.flow_cache import CACHING_PARAMETERS, clear_cache
12
+
13
+ CACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching
14
+ # clear_cache() # Uncomment this line to clear the cache
15
+
16
+ logging.set_verbosity_debug()
17
+ logging.auto_set_dir()
18
+
19
+ dependencies = [
20
+ {"url": "aiflows/HumanStandardInputFlowModule", "revision": "5683a922372c5fa90be9f6447d6662d8d80341fc"},
21
+ {"url": "aiflows/ChatFlowModule", "revision": "a749ad10ed39776ba6721c37d0dc22af49ca0f17"},
22
+ {"url": "Tachi67/AbstractBossFlowModule", "revision": "main"},
23
+ {"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"},
24
+ {"url": "Tachi67/PlanWriterFlowModule", "revision": "main"},
25
+ {"url": "Tachi67/ExtendLibraryFlowModule", "revision": "main"},
26
+ {"url": "Tachi67/RunCodeFlowModule", "revision": "main"},
27
+ {"url": "Tachi67/ReplanningFlowModule", "revision": "main"},
28
+ {"url": "Tachi67/CoderFlowModule", "revision": "main"},
29
+ {"url": "Tachi67/JarvisFlowModule", "revision": "main"},
30
+ ]
31
+
32
+ from flows import flow_verse
33
+
34
+ flow_verse.sync_dependencies(dependencies)
35
+
36
+ def set_up_memfiles(cfg):
37
+ code_lib_file_loc = os.path.join(current_dir, "library.py")
38
+ jarvis_plan_file_loc = os.path.join(current_dir, "plan_jarvis.txt")
39
+ jarvis_logs_file_loc = os.path.join(current_dir, "logs_jarvis.txt")
40
+ coder_plan_file_loc = os.path.join(current_dir, "plan_coder.txt")
41
+ coder_logs_file_loc = os.path.join(current_dir, "logs_coder.txt")
42
+ extlib_plan_file_loc = os.path.join(current_dir, "plan_extlib.txt")
43
+ extlib_logs_file_loc = os.path.join(current_dir, "logs_extlib.txt")
44
+ with open(code_lib_file_loc, 'w') as file:
45
+ pass
46
+ with open(jarvis_plan_file_loc, 'w') as file:
47
+ pass
48
+ with open(jarvis_logs_file_loc, 'w') as file:
49
+ pass
50
+ with open(coder_plan_file_loc, 'w') as file:
51
+ pass
52
+ with open(coder_logs_file_loc, 'w') as file:
53
+ pass
54
+ with open(extlib_plan_file_loc, 'w') as file:
55
+ pass
56
+ with open(extlib_logs_file_loc, 'w') as file:
57
+ pass
58
+
59
+ memfiles_jarvis = {}
60
+ memfiles_coder = {}
61
+ memfiles_extlib = {}
62
+ memfiles_writecode_interactivecoder = {}
63
+ memfiles_writecode_test = {}
64
+ memfiles_jarvis["plan"] = jarvis_plan_file_loc
65
+ memfiles_jarvis["logs"] = jarvis_logs_file_loc
66
+ memfiles_coder["plan"] = coder_plan_file_loc
67
+ memfiles_coder["logs"] = coder_logs_file_loc
68
+ memfiles_coder["code_library"] = code_lib_file_loc
69
+ memfiles_extlib["plan"] = extlib_plan_file_loc
70
+ memfiles_extlib["logs"] = extlib_logs_file_loc
71
+ memfiles_extlib["code_library"] = code_lib_file_loc
72
+ memfiles_writecode_interactivecoder["code_library"] = code_lib_file_loc
73
+ memfiles_writecode_test["code_library"] = code_lib_file_loc
74
+ cfg["memory_files"] = memfiles_jarvis
75
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["Coder"]["memory_files"] = memfiles_coder
76
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["Coder"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["extend_library"]["memory_files"] = memfiles_extlib
77
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["Coder"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["extend_library"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"][
78
+ "subflows_config"]["Executor"]["subflows_config"]["write_code"][
79
+ "memory_files"] = memfiles_writecode_interactivecoder
80
+ cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["Coder"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["extend_library"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"][
81
+ "subflows_config"]["Executor"]["subflows_config"]["test"]["memory_files"] = memfiles_writecode_test
82
+
83
+
84
+ if __name__ == "__main__":
85
+ # ~~~ make sure to set the openai api key in the envs ~~~
86
+ key = os.getenv("OPENAI_API_KEY")
87
+ api_information = [ApiInfo(backend_used="openai", api_key=os.getenv("OPENAI_API_KEY"))]
88
+ path_to_output_file = None
89
+
90
+ current_dir = os.getcwd()
91
+ cfg_path = os.path.join(current_dir, "JarvisFlow.yaml")
92
+ cfg = read_yaml_file(cfg_path)
93
+
94
+ # ~~~ setting api information into config ~~~
95
+ update_api_infos(cfg, api_information)
96
+
97
+ # ~~~ setting memory files into config ~~~
98
+ set_up_memfiles(cfg)
99
+
100
+ # ~~~ instantiating the flow and input data ~~~
101
+ JarvisFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
102
+ input_data = {
103
+ #"goal": "define a calculator that supports addition and multiplication on complex numbers",
104
+ #"goal": "define a calculator that supports addition on complex numbers"
105
+ "goal": "fetch google's stock prices using yfinance for the last 6 months and print the first 10 entries"
106
+ }
107
+ input_message = InputMessage.build(
108
+ data_dict=input_data,
109
+ src_flow="Launcher",
110
+ dst_flow=JarvisFlow.name
111
+ )
112
+
113
+ # ~~~ calling the flow ~~~
114
+ output_message = JarvisFlow(input_message)
115
+
116
+ # ~~~ printing the output ~~~
117
+ print(output_message)