-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathassemble.py
41 lines (28 loc) · 1.27 KB
/
assemble.py
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
import argparse
import os
import dotenv
from gentopia import chat
from gentopia.assembler.agent_assembler import AgentAssembler
from gentopia.output import enable_log
def main():
enable_log(log_level='info')
dotenv.load_dotenv(".env")
parser = argparse.ArgumentParser(description='Assemble an agent with given name.')
parser.add_argument('name', type=str, help='Name of the agent to assemble.')
parser.add_argument('--print_agent', action='store_true', help='Print the agent if specified.')
args = parser.parse_args()
agent_name = args.name
print_agent = args.print_agent
# check if agent_name is under directory ./gentpool/pool/
if not os.path.exists(f'./gentpool/pool/{agent_name}'):
raise ValueError(f'Agent {agent_name} does not exist. Check ./gentpool/pool/ for available agents.')
agent_config_path = f'./gentpool/pool/{agent_name}/agent.yaml'
assembler = AgentAssembler(file=agent_config_path)
# # assembler.manager = LocalLLMManager()
# print(f">>> Assembling agent {agent_name}...")
agent = assembler.get_agent()
if agent.name != agent_name:
raise ValueError(f"Agent name mismatch. Expected {agent_name}, got {agent.name}.")
chat(agent, verbose=print_agent)
if __name__ == '__main__':
main()