Find answers from the community

Updated 4 days ago

lets say i am using the AgentWorkflow and I want a planning agent to use OpenAI o1 models

@kapa.ai lets say i am using the AgentWorkflow and I want a planning agent to use OpenAI o1 models that do not allow for system prompts and cannot do function calling, how would you recommend building this as an agent system to tie in the AgentWorkflow?
k
3 comments
Please stand by @cmosguy as I search the knowledge base. I normally take about 15 seconds or so. :wave:
----------------------
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:

  1. 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

  1. 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:

Plain Text
   from llama_index.llms.keywordsai import KeywordsAI

   llm = KeywordsAI(model="YOUR_O1_MODEL_NAME")
   


LlamaIndex API Reference: KeywordsAI

  1. Implement the planning agent:
    Create a custom planning agent that extends the ReActAgent, incorporating the modifications mentioned above.
  1. Integrate with AgentWorkflow:
    Use the custom planning agent as part of your AgentWorkflow:
```python
from llama_index.core.agent.workflow import AgentWorkflow
planning_agent = CustomPlanningAgent(
name="planner",
description="Creates plans for complex tasks",
llm=llm,
tools=[...], # Define appropriate tools for planning
)

workflow = AgentWorkflow(
agents=[planning_agent, ...], # Add other agents as needed
root_agent="planner"
)
```

  1. Handle state and context:
    Since O1 models don't support function calling, you'll need to manage the state and context of the planning process manually within your custom agent implementation.
By following these steps, you can create a planning agent that works with O1 models and integrates with the AgentWorkflow system. Keep in mind that this approach may require more custom implementation compared to using models with built-in function calling support.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord