Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add structured planning agent #13149

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
942 changes: 942 additions & 0 deletions docs/docs/examples/agent/structured_planner.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/docs/module_guides/deploying/agents/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For more detailed guides on how to use specific tools, check out our [tools modu
- [Multi Document Agents](../../../examples/agent/multi_document_agents.ipynb)
- [Agent Builder](../../../examples/agent/agent_builder.ipynb)
- [Parallel Function Calling](../../../examples/agent/openai_agent_parallel_function_calling.ipynb)
- [Agent with Planning](../../../examples/agent/structured_planner.ipynb)

## [Beta] OpenAI Assistant Agent

Expand Down Expand Up @@ -49,4 +50,5 @@ For more detailed guides on how to use specific tools, check out our [tools modu

- [Agent Runner](../../../examples/agent/agent_runner/agent_runner.ipynb)
- [Agent Runner RAG](../../../examples/agent/agent_runner/agent_runner_rag.ipynb)
- [Agent with Planning](../../../examples/agent/structured_planner.ipynb)
- [Controllable Agent Runner](../../../examples/agent/agent_runner/agent_runner_rag_controllable.ipynb)
19 changes: 19 additions & 0 deletions docs/docs/module_guides/deploying/agents/usage_pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ query_engine_tools = [
outer_agent = ReActAgent.from_tools(query_engine_tools, llm=llm, verbose=True)
```

## Agent With Planning

Breaking down an initial task into easier-to-digest sub-tasks is a powerful pattern.

LlamaIndex provides an agent planning module that does just this:

```python
from llama_index.agent.openai import OpenAIAgentWorker
from llama_index.core.agent import (
StructuredPlannerAgent,
FunctionCallingAgentWorker,
)

worker = FunctionCallingAgentWorker.from_tools(tools, llm=llm)
agent = StructuredPlannerAgent(worker)
```

See more in the [complete guide](../../../examples/agent/structured_planner.ipynb)

## Lower-Level API

The OpenAIAgent and ReActAgent are simple wrappers on top of an `AgentRunner` interacting with an `AgentWorker`.
Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ nav:
- ./examples/agent/coa_agent.ipynb
- ./examples/agent/lats_agent.ipynb
- ./examples/agent/llm_compiler.ipynb
- ./examples/agent/structured_planner.ipynb
- Callbacks:
- ./examples/callbacks/HoneyHiveLlamaIndexTracer.ipynb
- ./examples/callbacks/PromptLayerHandler.ipynb
Expand Down
2 changes: 2 additions & 0 deletions llama-index-core/llama_index/core/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from llama_index.core.agent.react.step import ReActAgentWorker
from llama_index.core.agent.react_multimodal.step import MultimodalReActAgentWorker
from llama_index.core.agent.runner.base import AgentRunner
from llama_index.core.agent.runner.planner import StructuredPlannerAgent
from llama_index.core.agent.runner.parallel import ParallelAgentRunner
from llama_index.core.agent.types import Task
from llama_index.core.chat_engine.types import AgentChatResponse
from llama_index.core.agent.function_calling.step import FunctionCallingAgentWorker

__all__ = [
"AgentRunner",
"StructuredPlannerAgent",
"ParallelAgentRunner",
"ReActAgentWorker",
"ReActAgent",
Expand Down