forked from agiresearch/AIOS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
118 lines (94 loc) · 3.25 KB
/
Copy pathmain.py
File metadata and controls
118 lines (94 loc) · 3.25 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This is a main script that tests the functionality of specific agents.
# It requires no user input.
from aios.utils.utils import (
parse_global_args,
)
import os
import warnings
from aios.hooks.llm import useFactory, useKernel, useFIFOScheduler
from aios.utils.utils import delete_directories
from dotenv import load_dotenv
def clean_cache(root_directory):
targets = {
".ipynb_checkpoints",
"__pycache__",
".pytest_cache",
"context_restoration",
}
delete_directories(root_directory, targets)
def main():
# parse arguments and set configuration for this run accordingly
main_id = os.getpid()
print(f"Main ID is: {main_id}")
warnings.filterwarnings("ignore")
parser = parse_global_args()
args = parser.parse_args()
llm_name = args.llm_name
max_gpu_memory = args.max_gpu_memory
eval_device = args.eval_device
max_new_tokens = args.max_new_tokens
scheduler_log_mode = args.scheduler_log_mode
agent_log_mode = args.agent_log_mode
llm_kernel_log_mode = args.llm_kernel_log_mode
use_backend = args.use_backend
load_dotenv()
llm = useKernel(
llm_name=llm_name,
max_gpu_memory=max_gpu_memory,
eval_device=eval_device,
max_new_tokens=max_new_tokens,
log_mode=llm_kernel_log_mode,
use_backend=use_backend
)
# run agents concurrently for maximum efficiency using a scheduler
startScheduler, stopScheduler = useFIFOScheduler(
llm=llm,
log_mode=scheduler_log_mode,
get_queue_message=None
)
submitAgent, awaitAgentExecution = useFactory(
log_mode=agent_log_mode,
max_workers=64
)
startScheduler()
# register your agents and submit agent tasks
""" submitAgent(
agent_name="example/academic_agent",
task_input="Find recent papers on the impact of social media on mental health in adolescents."
)
"""
"""
submitAgent(
agent_name="om-raheja/transcribe_agent",
task_input="listen to my yap for 5 seconds and write a response to it"
)
"""
"""
submitAgent(
agent_name="example/cocktail_mixlogist",
task_input="Create a cocktail for a summer garden party. Guests enjoy refreshing, citrusy flavors. Available ingredients include vodka, gin, lime, lemon, mint, and various fruit juices."
)
"""
"""
submitAgent(
agent_name="example/cook_therapist",
task_input="Develop a low-carb, keto-friendly dinner that is flavorful and satisfying."
)
"""
agent_tasks = [
["example/academic_agent", "Tell me what is the prollm paper mainly about"]
# ["example/cocktail_mixlogist", "Create a cocktail for a summer garden party. Guests enjoy refreshing, citrusy flavors. Available ingredients include vodka, gin, lime, lemon, mint, and various fruit juices."]
]
agent_ids = []
for agent_name, task_input in agent_tasks:
agent_id = submitAgent(
agent_name=agent_name,
task_input=task_input
)
agent_ids.append(agent_id)
for agent_id in agent_ids:
awaitAgentExecution(agent_id)
stopScheduler()
clean_cache(root_directory="./")
if __name__ == "__main__":
main()