add api info configure
Browse files
run.py
CHANGED
|
@@ -4,7 +4,7 @@ import hydra
|
|
| 4 |
|
| 5 |
from aiflows.backends.api_info import ApiInfo
|
| 6 |
from aiflows.messages import InputMessage
|
| 7 |
-
from aiflows.utils.general_helpers import read_yaml_file
|
| 8 |
|
| 9 |
from aiflows import logging
|
| 10 |
from aiflows.flow_cache import CACHING_PARAMETERS, clear_cache
|
|
@@ -23,13 +23,20 @@ from aiflows import flow_verse
|
|
| 23 |
flow_verse.sync_dependencies(dependencies)
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
| 26 |
current_dir = os.getcwd()
|
| 27 |
cfg_path = os.path.join(current_dir, "CodeGeneratorAtomicFlow.yaml")
|
| 28 |
cfg = read_yaml_file(cfg_path)
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
CodeGenFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
|
| 31 |
|
| 32 |
-
with os.path.join(current_dir, "example_library.py") as f:
|
| 33 |
pass
|
| 34 |
|
| 35 |
memory_files = {"code_library": os.path.join(current_dir, "example_library.py")}
|
|
|
|
| 4 |
|
| 5 |
from aiflows.backends.api_info import ApiInfo
|
| 6 |
from aiflows.messages import InputMessage
|
| 7 |
+
from aiflows.utils.general_helpers import read_yaml_file, quick_load
|
| 8 |
|
| 9 |
from aiflows import logging
|
| 10 |
from aiflows.flow_cache import CACHING_PARAMETERS, clear_cache
|
|
|
|
| 23 |
flow_verse.sync_dependencies(dependencies)
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
| 26 |
+
# ~~~ make sure to set the openai api key in the envs ~~~
|
| 27 |
+
key = os.getenv("OPENAI_API_KEY")
|
| 28 |
+
api_information = [ApiInfo(backend_used="openai", api_key=os.getenv("OPENAI_API_KEY"))]
|
| 29 |
current_dir = os.getcwd()
|
| 30 |
cfg_path = os.path.join(current_dir, "CodeGeneratorAtomicFlow.yaml")
|
| 31 |
cfg = read_yaml_file(cfg_path)
|
| 32 |
|
| 33 |
+
|
| 34 |
+
# configuring api information
|
| 35 |
+
quick_load(cfg, api_information)
|
| 36 |
+
|
| 37 |
CodeGenFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")
|
| 38 |
|
| 39 |
+
with open(os.path.join(current_dir, "example_library.py"), 'w') as f:
|
| 40 |
pass
|
| 41 |
|
| 42 |
memory_files = {"code_library": os.path.join(current_dir, "example_library.py")}
|