| 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 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": "Tachi67/ContentWriterFlowModule", "revision": "main"}, |
| {"url": "Tachi67/InteractiveCodeGenFlowModule", "revision": "main"}, |
| {"url": "Tachi67/CodeWriterFlowModule", "revision": "main"}, |
| {"url": "aiflows/ChatFlowModule", "revision": "a749ad10ed39776ba6721c37d0dc22af49ca0f17"}, |
| ] |
|
|
| from flows import flow_verse |
|
|
| flow_verse.sync_dependencies(dependencies) |
|
|
| 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, "CodeWriterFlow.yaml") |
| cfg = read_yaml_file(cfg_path) |
| cfg["subflows_config"]["Controller"]["backend"]["api_infos"] = api_information |
| cfg["subflows_config"]["Executor"]["subflows_config"]["write_code"]["subflows_config"]["CodeGenerator"]["backend"]["api_infos"] = api_information |
|
|
| |
| code_lib_file_loc = os.path.join(current_dir, "library.py") |
| with open(code_lib_file_loc, 'w') as file: |
| pass |
| cfg["subflows_config"]["Executor"]["subflows_config"]["write_code"]["memory_files"] = {"code_library": code_lib_file_loc} |
| cfg["subflows_config"]["Executor"]["subflows_config"]["test"]["memory_files"] = {"code_library": code_lib_file_loc} |
|
|
| |
| CodeWriterFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial") |
| input_data = { |
| "goal": "create a function that adds two numbers and returns the result", |
| } |
| input_message = InputMessage.build( |
| data_dict=input_data, |
| src_flow="Launcher", |
| dst_flow=CodeWriterFlow.name |
| ) |
|
|
| |
| output_message = CodeWriterFlow(input_message) |
|
|