Skip to content

Commit da978c4

Browse files
committed
fix: update llms and embeddings docs to use the new ReAct agent
1 parent 330c00e commit da978c4

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

docs/llms_and_embeddings.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,29 @@ Both classes integrate seamlessly with LlamaIndex components:
105105
### Using with Agents
106106

107107
```python
108-
from llama_index.core.agent import ReActAgent
109-
from llama_index.core.tools import FunctionTool
110-
from uipath_llamaindex.llms import UiPathOpenAI
108+
import asyncio
109+
from llama_index.core.agent.workflow import ReActAgent
110+
from uipath_llamaindex.llms import UiPathOpenAI, OpenAIModel
111111

112112
def multiply(a: int, b: int) -> int:
113-
"""Multiply two integers and returns the result."""
113+
"""Multiply two integers and returns the result integer"""
114114
return a * b
115115

116-
multiply_tool = FunctionTool.from_defaults(fn=multiply)
116+
117+
def add(a: int, b: int) -> int:
118+
"""Add two integers and returns the result integer"""
119+
return a + b
117120

118121
# Create agent with UiPath LLM
119-
agent = ReActAgent.from_tools(
120-
[multiply_tool],
121-
llm=UiPathOpenAI(model=OpenAIModel.GPT_4O_2024_11_20)
122-
)
122+
agent = ReActAgent(
123+
tools=[multiply, add],
124+
llm=UiPathOpenAI(model=OpenAIModel.GPT_4O_2024_11_20))
125+
126+
async def main():
127+
handler = agent.run("What is 2+(2*4)?")
128+
response = await handler
123129

124-
response = agent.chat("What is 21 multiplied by 2?")
130+
asyncio.run(main())
125131
```
126132

127133
### Using with VectorStoreIndex

0 commit comments

Comments
 (0)