A configurable ReAct agent. This agent leverages the AIQ toolkit plugin system and WorkflowBuilder to integrate pre-built and custom tools into the workflow. Key elements are summarized below:
- Pre-built Tools: Leverages core AIQ toolkit library agent and tools.
- ReAct agent: Performs reasoning between tool call; utilizes tool names and descriptions to appropriately route to the correct tool
- Custom Plugin System: Developers can bring in new tools using plugins.
- High-level API: Enables defining functions that transform into asynchronous LangChain tools.
- Agentic Workflows: Fully configurable via YAML for flexibility and productivity.
- Ease of Use: Simplifies developer experience and deployment.
If you have not already done so, follow the instructions in the Install Guide to create the development environment and install AIQ toolkit.
From the root directory of the AIQ toolkit library, run the following commands:
uv pip install -e .The code_generation and wiki_search tools are part of the aiqtoolkit[langchain] package. To install the package run the following command:
# local package install from source
uv pip install -e '.[langchain]'If you have not already done so, follow the Obtaining API Keys instructions to obtain an NVIDIA API key. You need to set your NVIDIA API key as an environment variable to access NVIDIA AI services:
export NVIDIA_API_KEY=<YOUR_API_KEY>The ReAct agent can be used as either a workflow or a function, and there's an example configuration that demonstrates both. If you’re looking for an example workflow where the ReAct agent runs as the main workflow, refer to config.yml. To see the ReAct agent used as a function within a workflow, alongside the Reasoning Agent, refer to config-reasoning.yml. This README primarily covers the former case, where the ReAct agent functions as the main workflow, in config.yml. For more details, refer to the ReAct agent documentation and the Reasoning agent documentation
Run the following command from the root of the AIQ toolkit repo to execute this workflow with the specified input:
aiq run --config_file=examples/intermediate/agents/react/configs/config.yml --input "who was Djikstra?"Expected Output
$ aiq run --config_file=examples/intermediate/agents/react/configs/config.yml --input "who was Djikstra?"
2025-04-23 14:59:18,848 - aiq.runtime.loader - WARNING - Loading module 'aiq_automated_description_generation.register' from entry point 'aiq_automated_description_generation' took a long time (508.361340 ms). Ensure all imports are inside your registered functions.
2025-04-23 14:59:19,123 - aiq.cli.commands.start - INFO - Starting AIQ toolkit from config file: 'examples/intermediate/agents/react/configs/config.yml'
2025-04-23 14:59:19,130 - aiq.cli.commands.start - WARNING - The front end type in the config file (fastapi) does not match the command name (console). Overwriting the config file front end.
2025-04-23 14:59:19,163 - aiq.profiler.utils - WARNING - Discovered frameworks: {<LLMFrameworkEnum.LANGCHAIN: 'langchain'>} in function code_generation_tool by inspecting source. It is recommended and more reliable to instead add the used LLMFrameworkEnum types in the framework_wrappers argument when calling @register_function.
2025-04-23 14:59:19,164 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Initializing code generation tool
Getting tool LLM from config
2025-04-23 14:59:19,182 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Filling tool's prompt variable from config
2025-04-23 14:59:19,182 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Initialized code generation tool
Configuration Summary:
--------------------
Workflow Type: react_agent
Number of Functions: 3
Number of LLMs: 1
Number of Embedders: 0
Number of Memory: 0
Number of Retrievers: 0
2025-04-23 14:59:20,179 - aiq.agent.react_agent.agent - INFO -
------------------------------
[AGENT]
Agent input: who was Djikstra?
Agent's thoughts:
Thought: To answer this question, I need to find information about Djikstra.
Action: wikipedia_search
Action Input: {'question': 'Djikstra'}
------------------------------
2025-04-23 14:59:24,922 - aiq.agent.react_agent.agent - INFO -
------------------------------
[AGENT]
Calling tools: wikipedia_search
Tool's input: {"question": "Djikstra"}
Tool's response:
<Document source="https://en.wikipedia.org/wiki/Edsger_W._Dijkstra" page=""/>
Edsger Wybe Dijkstra ( DYKE-strə; Dutch: [ˈɛtsxər ˈʋibə ˈdɛikstraː] ; 11 May 1930 – 6 August 2002) was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist.
Born in Rotterdam in the Netherlands, Dijkstra studied mathematics and physics and then theoretical physics at the University of Leiden. Adriaan van Wijngaarden offered him a job as the first computer programmer in the Netherlands at the Mathematical Centre in Amsterdam, where he worked from 1952 until 1962. He formulated and solved the shortest path problem in 1956, and in 1960 developed the first compiler for the programming language ALGOL 60 in conjunction with colleague Jaap A. Zonneveld. In 1962 he moved to Eindhoven, and later to Nuenen, where he became a professor in the Mathematics Department at the Technische Hogeschool Eindhoven. In the late 1960s he built the THE multiprogramming system, which influence...
------------------------------
2025-04-23 14:59:26,159 - aiq.agent.react_agent.agent - INFO -
------------------------------
[AGENT]
Agent input: who was Djikstra?
Agent's thoughts:
Thought: I now know the final answer
Final Answer: Edsger Wybe Dijkstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist who made significant contributions to the field of computer science, including formulating and solving the shortest path problem and developing the first compiler for the programming language ALGOL 60.
------------------------------
2025-04-23 14:59:26,164 - aiq.front_ends.console.console_front_end_plugin - INFO -
--------------------------------------------------
Workflow Result:
['Edsger Wybe Dijkstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist who made significant contributions to the field of computer science, including formulating and solving the shortest path problem and developing the first compiler for the programming language ALGOL 60.']
--------------------------------------------------You can start the AIQ toolkit server using the aiq serve command with the appropriate configuration file.
Starting the ReAct Agent Example Workflow
aiq serve --config_file=examples/intermediate/agents/react/configs/config.ymlOnce the server is running, you can make HTTP requests to interact with the workflow.
Non-Streaming Request to the ReAct Agent Example Workflow
curl --request POST \
--url http://localhost:8000/generate \
--header 'Content-Type: application/json' \
--data '{"input_message": "What are LLMs?"}'Streaming Request to the ReAct Agent Example Workflow
curl --request POST \
--url http://localhost:8000/generate/stream \
--header 'Content-Type: application/json' \
--data '{"input_message": "What are LLMs?"}'Run and evaluate the react_agent example Workflow
aiq eval --config_file=examples/intermediate/agents/react/configs/config.yml