| import os |
|
|
| import hydra |
|
|
| from aiflows.backends.api_info import ApiInfo |
| from aiflows.messages import InputMessage |
| from aiflows.utils.general_helpers import read_yaml_file, quick_load |
|
|
| from aiflows import logging |
| from aiflows.flow_cache import CACHING_PARAMETERS, clear_cache |
|
|
| CACHING_PARAMETERS.do_caching = False |
|
|
| logging.set_verbosity_debug() |
| logging.auto_set_dir() |
|
|
| dependencies = [ |
| {"url": "aiflows/InteractiveCodeGenFlowModule", "revision": "main"}, |
| ] |
|
|
| from aiflows 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"))] |
| current_dir = os.getcwd() |
| cfg_path = os.path.join(current_dir, "InteractiveCodeGenFlow.yaml") |
| cfg = read_yaml_file(cfg_path) |
|
|
| |
| with open(os.path.join(current_dir, "example_library.py"), 'w') as f: |
| pass |
| memory_files = {"code_library": os.path.join(current_dir, "example_library.py")} |
| cfg["memory_files"] = memory_files |
|
|
| |
| quick_load(cfg, api_information) |
|
|
| InteractiveCodeGenFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial") |
|
|
|
|
| input_data = { |
| "goal": "write a function to add up two numbers" |
| } |
| input_message = InputMessage.build( |
| data_dict=input_data, |
| src_flow="Launcher", |
| dst_flow=InteractiveCodeGenFlow.name |
| ) |
|
|
| |
| output_message = InteractiveCodeGenFlow(input_message) |
|
|
| print(output_message.data) |