Find answers from the community

Updated 7 months ago

What's the difference between ReAct Agent and OpenAI Agent?

@kapa.ai What's the difference between ReAct Agent and OpenAI Agent?
k
3 comments
Please stand by @praveenks30#120294 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
The ReAct Agent and OpenAI Agent are both components of LlamaIndex, but they serve different purposes and are used in different contexts.

The ReAct Agent is a part of LlamaIndex's core modules and is designed to reason over a set of tools to achieve an end goal. It can be used with any sufficiently capable Language Model (LLM), including OpenAI models. The ReAct Agent can use tools that are Python functions or LlamaIndex query engines. Here's an example of how to set up a ReAct Agent:

Plain Text
from llama_index.core.tools import FunctionTool
from llama_index.llms.openai import OpenAI
from llama_index.core.agent import ReActAgent

# define sample Tool
def multiply(a: int, b: int) -> int:
 """Multiply two integers and returns the result integer"""
    return a * b

multiply_tool = FunctionTool.from_defaults(fn=multiply)

# initialize llm
llm = OpenAI(model="gpt-3.5-turbo-0613")

# initialize ReAct agent
agent = ReActAgent.from_tools([multiply_tool], llm=llm, verbose=True)

(Source: LlamaIndex Documentation ())

On the other hand, the OpenAI Agent is a specific implementation of an agent in LlamaIndex that uses OpenAI's models. It's used to set up an agent that can interact with OpenAI's models and perform tasks like automated reasoning over your data. Here's an example of how to set up an OpenAI Agent:

```python
from llama_index.core.agent import AgentRunner, ReActAgent
from llama_index.agent.openai import OpenAIAgentWorker, OpenAIAgent
from llama_index.agent.openai import OpenAIAgentWorker

agent_llm = OpenAI(model="gpt-3.5-turbo")
agent = ReActAgent.from_tools(
query_engine_tools, llm=agent_llm, verbose=True, max_iterations=20
)
```
(Source: LlamaIndex Documentation ())

In summary, the ReAct Agent is a more general component that can work with any LLM and a set of tools, while the OpenAI Agent is a specific implementation that works with OpenAI's models.
----------------------
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