----------------------
To build a planning agent using OpenAI O1 models (which don't support system prompts or function calling) within the AgentWorkflow system, we need to make some adaptations. Here's a recommended approach based on the information from the knowledge sources:
- Use ReActAgent instead of FunctionAgent:
Since O1 models don't support function calling, we should use the ReActAgent, which works with any LLM. The ReActAgent uses a structured approach to decompose tasks into thoughts and actions.
LlamaIndex API Reference: ReActAgent- Customize the ReActAgent for O1 models:
We need to modify the ReActAgent to work with O1 models' limitations. Here's how we can do this:
a. Use a custom formatter:
Create a custom ReActChatFormatter that doesn't include a system prompt. Instead, incorporate the agent's instructions into the user message.
b. Modify the reasoning process:
Adjust the reasoning steps to fit within the context of a user message, since we can't use system prompts.
c. Use the KeywordsAI LLM wrapper:
LlamaIndex provides a KeywordsAI wrapper for O1 models that automatically adjusts the message roles:
from llama_index.llms.keywordsai import KeywordsAI
llm = KeywordsAI(model="YOUR_O1_MODEL_NAME")
LlamaIndex API Reference: KeywordsAI- Implement the planning agent:
Create a custom planning agent that extends the ReActAgent, incorporating the modifications mentioned above.
- Integrate with AgentWorkflow:
Use the custom planning agent as part of your AgentWorkflow:
```python
from llama_index.core.agent.workflow import AgentWorkflow