llama-stack/llama_stack/distribution
Andy Xie f5dae0517c
feat: Support ReAct Agent on Tools Playground (#2012)
# What does this PR do?
ReAct prompting attempts to use the Thinking, Action, Observation loop
to improve the model's reasoning ability via prompt engineering.

With this PR, it now supports the various features in Streamlit's
playground:
1. Adding the selection box for choosing between Agent Type: normal,
ReAct.
2. Adding the Thinking, Action, Observation loop streamlit logic for
ReAct agent, as seen in many LLM clients.
3. Improving tool calling accuracies via ReAct prompting, e.g. using
web_search.


**Folded**
![react_output_folded
png](https://github.com/user-attachments/assets/bf1bdce7-e6ef-455d-b6b0-c22a64e9d5c1)

**Collapsed**

![react_output_collapsed](https://github.com/user-attachments/assets/cda2fc17-df0b-400d-971c-988de821f2a4)

[//]: # (If resolving an issue, uncomment and update the line below)
[//]: # (Closes #[issue-number])

## Test Plan

[Describe the tests you ran to verify your changes with result
summaries. *Provide clear instructions so the plan can be easily
re-executed.*]
Run the playground and uses reasoning prompts to see for yourself. Steps
to test the ReAct agent mode:
1. Setup a llama-stack server as
[getting_started](https://llama-stack.readthedocs.io/en/latest/getting_started/index.html)
describes.
2. Setup your Web Search API keys under
`llama_stack/distribution/ui/modules/api.py`.
3. Run the streamlit playground and try ReAct agent, possibly with
`websearch`, with the command: `streamlit run
llama_stack/distribution/ui/app.py`.

## Test Process
Current results are demonstrated with `llama-3.2-3b-instruct`. Results
will vary with different models.

You should be seeing clear distinction with normal agent and ReAct
agent. Example prompts listed below:
1. Aside from the Apple Remote, what other devices can control the
program Apple Remote was originally designed to interact with?
2. What is the elevation range for the area that the eastern sector of
the Colorado orogeny extends into?

## Example Test Results

**Web search on AppleTV**
<img width="1440" alt="normal_output_appletv"
src="https://github.com/user-attachments/assets/bf6b3273-1c94-4976-8b4a-b2d82fe41330"
/>

<img width="1440" alt="react_output_appletv"
src="https://github.com/user-attachments/assets/687f1feb-88f4-4d32-93d5-5013d0d5fe25"
/>

**Web search on Colorado**
<img width="1440" alt="normal_output_colorado"
src="https://github.com/user-attachments/assets/10bd3ad4-f2ad-466d-9ce0-c66fccee40c1"
/>

<img width="1440" alt="react_output_colorado"
src="https://github.com/user-attachments/assets/39cfd82d-2be9-4e2f-9f90-a2c4840185f7"
/>

**Web search tool + MCP Slack server**
<img width="1250" alt="normal_output_search_slack png"
src="https://github.com/user-attachments/assets/72e88125-cdbf-4a90-bcb9-ab412c51d62d"
/>

<img width="1217" alt="react_output_search_slack"
src="https://github.com/user-attachments/assets/8ae04efb-a4fd-49f6-9465-37dbecb6b73e"
/>


![slack_screenshot](https://github.com/user-attachments/assets/bb70e669-6067-462a-bdf6-7aaac6ccbcef)
2025-04-25 17:01:51 +02:00
..
routers fix: Return HTTP 400 for OpenAI API validation errors (#2002) 2025-04-23 17:48:32 +02:00
server fix: Additional streaming error handling (#2007) 2025-04-24 17:01:45 -07:00
store fix: handle registry errors gracefully (#1732) 2025-03-20 15:24:07 -07:00
ui feat: Support ReAct Agent on Tools Playground (#2012) 2025-04-25 17:01:51 +02:00
utils feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
__init__.py API Updates (#73) 2024-09-17 19:51:35 -07:00
access_control.py feat: make sure agent sessions are under access control (#1737) 2025-03-21 07:31:16 -07:00
build.py feat: include run.yaml in the container image (#2005) 2025-04-24 11:29:53 +02:00
build_conda_env.sh chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
build_container.sh feat: include run.yaml in the container image (#2005) 2025-04-24 11:29:53 +02:00
build_venv.sh chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
client.py chore: move all Llama Stack types from llama-models to llama-stack (#1098) 2025-02-14 09:10:59 -08:00
common.sh fix: Fixing some small issues with the build scripts (#1132) 2025-02-19 22:20:49 -08:00
configure.py feat: add provider API for listing and inspecting provider info (#1429) 2025-03-13 15:07:21 -07:00
datatypes.py feat: allow building distro with external providers (#1967) 2025-04-18 17:18:28 +02:00
distribution.py feat: allow building distro with external providers (#1967) 2025-04-18 17:18:28 +02:00
inspect.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
library_client.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
providers.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
request_headers.py feat(server): add attribute based access control for resources (#1703) 2025-03-19 21:28:52 -07:00
resolver.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
stack.py feat: add health to all providers through providers endpoint (#1418) 2025-04-14 11:59:36 +02:00
start_stack.sh docs: Update docs and fix warning in start-stack.sh (#1937) 2025-04-11 16:26:17 -07:00