----------------------
The
agent_worker
is a key component in the LlamaIndex framework. It controls the step-wise execution of a Task. You can create an
agent_worker
by using different classes depending on your needs. Here are some examples from the extracts:
- Using
CustomSimpleAgentWorker
class for a custom agent:
from llama_index.agent import CustomSimpleAgentWorker
class MyAgentWorker(CustomSimpleAgentWorker):
"""Custom agent worker."""
# define class here
pass
You can find more details in the
Custom Agent Notebook Guide ().
source ()
- Using
QueryPipelineAgentWorker
class for a Query Pipeline agent:
from llama_index.core.agent import QueryPipelineAgentWorker, AgentRunner
from llama_index.core.callbacks import CallbackManager
agent_worker = QueryPipelineAgentWorker(qp)
agent = AgentRunner(
agent_worker, callback_manager=CallbackManager([]), verbose=True
)
source ()
- Using
LLMCompilerAgentWorker
class for a LLM Compiler agent:
from llama_index.core.agent import AgentRunner
from llama_index.llms.openai import OpenAI
llm = OpenAI(model="gpt-4")
agent_worker = LLMCompilerAgentWorker.from_tools(
query_engine_tools,
llm=llm,
verbose=True,
callback_manager=callback_manager,
)
agent = AgentRunner(agent_worker, callback_manager=callback_manager)
source ()