|
import os |
|
|
|
import hydra |
|
|
|
from flows.backends.api_info import ApiInfo |
|
from flows.messages import InputMessage |
|
from flows.utils.general_helpers import read_yaml_file |
|
from flows.utils.general_helpers import update_api_infos |
|
|
|
from flows import logging |
|
from flows.flow_cache import CACHING_PARAMETERS, clear_cache |
|
|
|
CACHING_PARAMETERS.do_caching = False |
|
|
|
|
|
logging.set_verbosity_debug() |
|
logging.auto_set_dir() |
|
|
|
dependencies = [ |
|
{"url": "aiflows/HumanStandardInputFlowModule", "revision": "5683a922372c5fa90be9f6447d6662d8d80341fc"}, |
|
{"url": "aiflows/ChatFlowModule", "revision": "a749ad10ed39776ba6721c37d0dc22af49ca0f17"}, |
|
{"url": "Tachi67/AbstractBossFlowModule", "revision": "main"}, |
|
{"url": "Tachi67/MemoryReadingFlowModule", "revision": "main"}, |
|
{"url": "Tachi67/PlanWriterFlowModule", "revision": "main"}, |
|
{"url": "Tachi67/ExtendLibraryFlowModule", "revision": "main"}, |
|
{"url": "Tachi67/RunCodeFlowModule", "revision": "main"}, |
|
{"url": "Tachi67/ReplanningFlowModule", "revision": "main"}, |
|
{"url": "Tachi67/CoderFlowModule", "revision": "main"}, |
|
] |
|
|
|
from flows import flow_verse |
|
|
|
flow_verse.sync_dependencies(dependencies) |
|
|
|
def set_up_memfiles(): |
|
code_lib_file_loc = os.path.join(current_dir, "library.py") |
|
coder_plan_file_loc = os.path.join(current_dir, "plan_coder.txt") |
|
coder_logs_file_loc = os.path.join(current_dir, "logs_coder.txt") |
|
extlib_plan_file_loc = os.path.join(current_dir, "plan_extlib.txt") |
|
extlib_logs_file_loc = os.path.join(current_dir, "logs_extlib.txt") |
|
with open(code_lib_file_loc, 'w') as file: |
|
pass |
|
with open(coder_plan_file_loc, 'w') as file: |
|
pass |
|
with open(coder_logs_file_loc, 'w') as file: |
|
pass |
|
with open(extlib_plan_file_loc, 'w') as file: |
|
pass |
|
with open(extlib_logs_file_loc, 'w') as file: |
|
pass |
|
|
|
memfiles_coder = {} |
|
memfiles_extlib = {} |
|
memfiles_writecode_interactivecoder = {} |
|
memfiles_writecode_test = {} |
|
memfiles_coder["plan"] = coder_plan_file_loc |
|
memfiles_coder["logs"] = coder_logs_file_loc |
|
memfiles_coder["code_library"] = code_lib_file_loc |
|
memfiles_extlib["plan"] = extlib_plan_file_loc |
|
memfiles_extlib["logs"] = extlib_logs_file_loc |
|
memfiles_extlib["code_library"] = code_lib_file_loc |
|
memfiles_writecode_interactivecoder["code_library"] = code_lib_file_loc |
|
memfiles_writecode_test["code_library"] = code_lib_file_loc |
|
cfg["memory_files"] = memfiles_coder |
|
cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["extend_library"]["memory_files"] = memfiles_extlib |
|
cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["extend_library"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"][ |
|
"subflows_config"]["Executor"]["subflows_config"]["write_code"][ |
|
"memory_files"] = memfiles_writecode_interactivecoder |
|
cfg["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["extend_library"]["subflows_config"]["CtrlExMem"]["subflows_config"]["Executor"]["subflows_config"]["write_code"][ |
|
"subflows_config"]["Executor"]["subflows_config"]["test"]["memory_files"] = memfiles_writecode_test |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
key = os.getenv("OPENAI_API_KEY") |
|
api_information = [ApiInfo(backend_used="openai", api_key=os.getenv("OPENAI_API_KEY"))] |
|
path_to_output_file = None |
|
|
|
current_dir = os.getcwd() |
|
cfg_path = os.path.join(current_dir, "CoderFlow.yaml") |
|
cfg = read_yaml_file(cfg_path) |
|
|
|
|
|
update_api_infos(cfg, api_information) |
|
|
|
|
|
set_up_memfiles() |
|
|
|
|
|
CoderFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial") |
|
input_data = { |
|
|
|
|
|
"goal": "fetch google's stock prices using yfinance for the last 6 months and print the first 10 entries" |
|
} |
|
input_message = InputMessage.build( |
|
data_dict=input_data, |
|
src_flow="Launcher", |
|
dst_flow=CoderFlow.name |
|
) |
|
|
|
|
|
output_message = CoderFlow(input_message) |
|
|
|
|
|
print(output_message) |