|
|
|
@ -41,6 +41,7 @@ class AgentManager:
|
|
|
|
|
builder = AgentBuilder(self.toolsets)
|
|
|
|
|
builder.build_parser()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callbacks = []
|
|
|
|
|
eval_callback = EVALCallbackHandler()
|
|
|
|
|
eval_callback.set_parser(builder.get_parser())
|
|
|
|
@ -51,16 +52,16 @@ class AgentManager:
|
|
|
|
|
execution_callback.set_parser(builder.get_parser())
|
|
|
|
|
callbacks.append(execution_callback)
|
|
|
|
|
|
|
|
|
|
#llm init
|
|
|
|
|
callback_manager = CallbackManager(callbacks)
|
|
|
|
|
builder.build_llm(callback_manager, openai_api_key)
|
|
|
|
|
|
|
|
|
|
if builder.llm is None:
|
|
|
|
|
raise ValueError('LLM not created')
|
|
|
|
|
|
|
|
|
|
builder.build_global_tools()
|
|
|
|
|
|
|
|
|
|
#agent init
|
|
|
|
|
agent = builder.get_agent()
|
|
|
|
|
|
|
|
|
|
if not agent:
|
|
|
|
|
raise ValueError("Agent not created")
|
|
|
|
|
|
|
|
|
@ -76,19 +77,19 @@ class AgentManager:
|
|
|
|
|
for tool in tools:
|
|
|
|
|
tool.callback_manager = callback_manager
|
|
|
|
|
|
|
|
|
|
executor_args = {
|
|
|
|
|
'agent': agent,
|
|
|
|
|
'tools': tools,
|
|
|
|
|
'memory': memory,
|
|
|
|
|
'callback_manager': callback_manager,
|
|
|
|
|
'verbose': True
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
executor = AgentExecutor.from_agent_and_tools(**executor_args)
|
|
|
|
|
# Ensure the 'agent' key is present in the values dictionary
|
|
|
|
|
# values = {'agent': agent, 'tools': tools}
|
|
|
|
|
|
|
|
|
|
if not hasattr(executor, 'agent'):
|
|
|
|
|
raise ValueError("Executor does not have an 'agent' attribute")
|
|
|
|
|
executor = AgentExecutor.from_agent_and_tools(
|
|
|
|
|
agent=agent,
|
|
|
|
|
tools=tools,
|
|
|
|
|
memory=memory,
|
|
|
|
|
callback_manager=callback_manager,
|
|
|
|
|
verbose=True,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if 'agent' not in executor.__dict__:
|
|
|
|
|
executor.__dict__['agent'] = agent
|
|
|
|
|
self.executors[session] = executor
|
|
|
|
|
|
|
|
|
|
return executor
|
|
|
|
|