File size: 1,626 Bytes
e0487cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163be46
e0487cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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  # Set to True in order to disable caching

logging.set_verbosity_debug()
logging.auto_set_dir()

dependencies = [
    {"url": "aiflows/InteractivePlanGenFlowModule", "revision": "main"},
]

from aiflows import flow_verse

flow_verse.sync_dependencies(dependencies)

if __name__ == "__main__":
    # ~~~ make sure to set the openai api key in the envs ~~~
    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, "InteractivePlanGenFlow.yaml")
    cfg = read_yaml_file(cfg_path)

    with open(os.path.join(current_dir, "example_plan.txt"), "w") as f:
        pass

    # configuring api information
    quick_load(cfg, api_information)

    InteractivePlanGenFlow = hydra.utils.instantiate(cfg, _recursive_=False, _convert_="partial")


    input_data = {
        "goal": "write a function to add up two numbers",
        "plan_file_location": os.path.join(current_dir, "example_plan.txt")
    }
    input_message = InputMessage.build(
        data_dict=input_data,
        src_flow="Launcher",
        dst_flow=InteractivePlanGenFlow.name
    )

    # ~~~ calling the flow ~~~
    output_message = InteractivePlanGenFlow(input_message)

    print(output_message.data)