Upload 14 files
Browse files- ExtendLibraryFlow.yaml +3 -0
- run_ExtendLibrary.py +63 -0
ExtendLibraryFlow.yaml
CHANGED
|
@@ -51,6 +51,7 @@ subflows_config:
|
|
| 51 |
Executor:
|
| 52 |
subflows_config:
|
| 53 |
write_code:
|
|
|
|
| 54 |
subflows_config:
|
| 55 |
CodeGenerator:
|
| 56 |
backend:
|
|
@@ -58,6 +59,8 @@ subflows_config:
|
|
| 58 |
model_name:
|
| 59 |
openai: gpt-4
|
| 60 |
azure: azure/gpt-4
|
|
|
|
|
|
|
| 61 |
re_plan:
|
| 62 |
subflows_config:
|
| 63 |
Controller:
|
|
|
|
| 51 |
Executor:
|
| 52 |
subflows_config:
|
| 53 |
write_code:
|
| 54 |
+
memory_files: ???
|
| 55 |
subflows_config:
|
| 56 |
CodeGenerator:
|
| 57 |
backend:
|
|
|
|
| 59 |
model_name:
|
| 60 |
openai: gpt-4
|
| 61 |
azure: azure/gpt-4
|
| 62 |
+
test:
|
| 63 |
+
memory_files: ???
|
| 64 |
re_plan:
|
| 65 |
subflows_config:
|
| 66 |
Controller:
|
run_ExtendLibrary.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 9 |
+
from flows import logging
|
| 10 |
+
from flows.flow_cache import CACHING_PARAMETERS, clear_cache
|
| 11 |
+
|
| 12 |
+
CACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching
|
| 13 |
+
# clear_cache() # Uncomment this line to clear the cache
|
| 14 |
+
|
| 15 |
+
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"},
|
| 22 |
+
{"url": "Tachi67/PlanWriterFlowModule", "revision": "main"},
|
| 23 |
+
{"url": "Tachi67/ReplanningFlowModule", "revision": "main"},
|
| 24 |
+
{"url": "Tachi67/CodeWriterFlowModule", "revision": "main"},
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
from flows import flow_verse
|
| 28 |
+
|
| 29 |
+
flow_verse.sync_dependencies(dependencies)
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
# ~~~ make sure to set the openai api key in the envs ~~~
|
| 33 |
+
key = os.getenv("OPENAI_API_KEY")
|
| 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)
|