add example run
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import os
import hydra
from aiflows.messages import InputMessagefrom aiflows.utils.general_helpers import read_yaml_file
from aiflows import loggingfrom aiflows.flow_cache import CACHING_PARAMETERS, clear_cache
CACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching# clear_cache() # Uncomment this line to clear the cache
logging.set_verbosity_debug()logging.auto_set_dir()
dependencies = [ {"url": "aiflows/CodeFileEditFlowModule", "revision": "main"},]
from aiflows import flow_verse
flow_verse.sync_dependencies(dependencies)
if __name__ == "__main__": current_dir = os.getcwd() cfg_path = os.path.join(current_dir, "CodeFileEditAtomicFlow.yaml") cfg = read_yaml_file(cfg_path)
with open(os.path.join(current_dir, "library.py"), "w") as file: pass
memory_files = {"code_library": os.path.join(current_dir, "library.py")}
# ~~~ instantiating the flow and input data ~~~ CodeFileEditFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial") code = """print("Hello World!") """ input_data = { "language_of_code": "Python", "code": code, "memory_files": memory_files } input_message = InputMessage.build( data_dict=input_data, src_flow="Launcher", dst_flow=CodeFileEditFlow.name )
# ~~~ calling the flow ~~~ output_message = CodeFileEditFlow(input_message)
# By now, the code should have been written to the temp file called temp.py in the same directory as library.py print(output_message.data)run.pyAdded+55