|
a |
|
b/app.py |
|
|
1 |
#!/usr/bin/env python |
|
|
2 |
# -*- coding: UTF-8 -*- |
|
|
3 |
''' |
|
|
4 |
@Project :Auto-BioinfoGPT |
|
|
5 |
@File :app.py |
|
|
6 |
@Author :Juexiao Zhou |
|
|
7 |
@Contact : juexiao.zhou@gmail.com |
|
|
8 |
@Date :2023/5/2 10:51 |
|
|
9 |
''' |
|
|
10 |
|
|
|
11 |
from src.agent import Agent |
|
|
12 |
import yaml |
|
|
13 |
import argparse |
|
|
14 |
import time |
|
|
15 |
|
|
|
16 |
def main(init_data_list, |
|
|
17 |
output_dir, |
|
|
18 |
init_goal_description, |
|
|
19 |
model_engine, |
|
|
20 |
openai_api, |
|
|
21 |
execute, |
|
|
22 |
blacklist, |
|
|
23 |
gui_mode, |
|
|
24 |
cpu, |
|
|
25 |
rag): |
|
|
26 |
AIAgent = Agent(initial_data_list=init_data_list, |
|
|
27 |
output_dir=output_dir, |
|
|
28 |
initial_goal_description=init_goal_description, |
|
|
29 |
model_engine=model_engine, |
|
|
30 |
openai_api=openai_api, |
|
|
31 |
execute=execute, |
|
|
32 |
blacklist=blacklist, |
|
|
33 |
gui_mode=gui_mode, |
|
|
34 |
cpu=cpu, |
|
|
35 |
rag=rag) |
|
|
36 |
AIAgent.run() |
|
|
37 |
|
|
|
38 |
if __name__ == '__main__': |
|
|
39 |
|
|
|
40 |
parser = argparse.ArgumentParser(description="ABC", add_help=False) |
|
|
41 |
parser.add_argument('--config', |
|
|
42 |
help='path/to/config.yaml', |
|
|
43 |
default='./examples/case1.1/config.yaml') |
|
|
44 |
parser.add_argument('--openai', |
|
|
45 |
help='openai api', |
|
|
46 |
default='SET_YOUR_OPENAI_API') |
|
|
47 |
parser.add_argument('--model', |
|
|
48 |
help='name of model engine, e.g. gpt-4, please refer to model zoo', |
|
|
49 |
default='gpt-4') |
|
|
50 |
parser.add_argument('--execute', |
|
|
51 |
help='execute code or only write codes', |
|
|
52 |
default=False, |
|
|
53 |
type=bool) |
|
|
54 |
parser.add_argument('--blacklist', |
|
|
55 |
help='list of softwares in blacklist, default: java,perl,annovar', |
|
|
56 |
default='java,perl,annovar,Cutadapt,STAR', |
|
|
57 |
type=str) |
|
|
58 |
parser.add_argument('--gui_mode', |
|
|
59 |
default=False, |
|
|
60 |
type=bool) |
|
|
61 |
parser.add_argument('--cpu', |
|
|
62 |
default=False, |
|
|
63 |
type=bool) |
|
|
64 |
parser.add_argument('--rag', |
|
|
65 |
help='Use RAG or not', |
|
|
66 |
default=False, |
|
|
67 |
type=bool) |
|
|
68 |
args = parser.parse_args() |
|
|
69 |
|
|
|
70 |
print(""" |
|
|
71 |
|
|
|
72 |
/$$$$$$ /$$ /$$$$$$$ /$$$$$$ |
|
|
73 |
/$$__ $$ | $$ | $$__ $$ /$$__ $$ |
|
|
74 |
| $$ \ $$ /$$ /$$ /$$$$$$ /$$$$$$ | $$ \ $$| $$ \ $$ |
|
|
75 |
| $$$$$$$$| $$ | $$|_ $$_/ /$$__ $$| $$$$$$$ | $$$$$$$$ |
|
|
76 |
| $$__ $$| $$ | $$ | $$ | $$ \ $$| $$__ $$| $$__ $$ |
|
|
77 |
| $$ | $$| $$ | $$ | $$ /$$| $$ | $$| $$ \ $$| $$ | $$ |
|
|
78 |
| $$ | $$| $$$$$$/ | $$$$/| $$$$$$/| $$$$$$$/| $$ | $$ |
|
|
79 |
|__/ |__/ \______/ \___/ \______/ |_______/ |__/ |__/ |
|
|
80 |
|
|
|
81 |
Automated Bioinformatics Analysis |
|
|
82 |
www.joshuachou.ink |
|
|
83 |
""") |
|
|
84 |
|
|
|
85 |
with open(args.config, 'r') as file: |
|
|
86 |
configs = yaml.safe_load(file) |
|
|
87 |
print(configs) |
|
|
88 |
init_data_list = configs['data_list'] |
|
|
89 |
output_dir = configs['output_dir'] |
|
|
90 |
init_goal_description = configs['goal_description'] |
|
|
91 |
start_time = time.time() |
|
|
92 |
main(init_data_list, |
|
|
93 |
output_dir, |
|
|
94 |
init_goal_description, |
|
|
95 |
args.model, |
|
|
96 |
args.openai, |
|
|
97 |
args.execute, |
|
|
98 |
args.blacklist, |
|
|
99 |
args.gui_mode, |
|
|
100 |
args.cpu, |
|
|
101 |
args.rag) |
|
|
102 |
end_time = time.time() |
|
|
103 |
print(f'\033[31m[Total time cost: {end_time-start_time}]\033[0m') |
|
|
104 |
|