Skip to content

Commit 58b47c1

Browse files
update AgentQnA (opea-project#1790)
Signed-off-by: minmin-intel <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8d421b7 commit 58b47c1

File tree

6 files changed

+58
-45
lines changed

6 files changed

+58
-45
lines changed

AgentQnA/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1. [Overview](#overview)
66
2. [Deploy with Docker](#deploy-with-docker)
7-
3. [Launch the UI](#launch-the-ui)
7+
3. [How to interact with the agent system with UI](#how-to-interact-with-the-agent-system-with-ui)
88
4. [Validate Services](#validate-services)
99
5. [Register Tools](#how-to-register-other-tools-with-the-ai-agent)
1010

@@ -144,21 +144,19 @@ source $WORKDIR/GenAIExamples/AgentQnA/docker_compose/intel/cpu/xeon/set_env.sh
144144

145145
### 2. Launch the multi-agent system. </br>
146146

147-
Two options are provided for the `llm_engine` of the agents: 1. open-source LLMs on Gaudi, 2. OpenAI models via API calls.
147+
We make it convenient to launch the whole system with docker compose, which includes microservices for LLM, agents, UI, retrieval tool, vector database, dataprep, and telemetry. There are 3 docker compose files, which make it easy for users to pick and choose. Users can choose a different retrieval tool other than the `DocIndexRetriever` example provided in our GenAIExamples repo. Users can choose not to launch the telemetry containers.
148148

149-
#### Gaudi
149+
#### Launch on Gaudi
150150

151-
On Gaudi, `meta-llama/Meta-Llama-3.1-70B-Instruct` will be served using vllm.
152-
By default, both the RAG agent and SQL agent will be launched to support the React Agent.
153-
The React Agent requires the DocIndexRetriever's [`compose.yaml`](../DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml) file, so two `compose.yaml` files need to be run with docker compose to start the multi-agent system.
154-
155-
> **Note**: To enable the web search tool, skip this step and proceed to the "[Optional] Web Search Tool Support" section.
151+
On Gaudi, `meta-llama/Meta-Llama-3.3-70B-Instruct` will be served using vllm. The command below will launch the multi-agent system with the `DocIndexRetriever` as the retrieval tool for the Worker RAG agent.
156152

157153
```bash
158154
cd $WORKDIR/GenAIExamples/AgentQnA/docker_compose/intel/hpu/gaudi/
159155
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml up -d
160156
```
161157

158+
> **Note**: To enable the web search tool, skip this step and proceed to the "[Optional] Web Search Tool Support" section.
159+
162160
To enable Open Telemetry Tracing, compose.telemetry.yaml file need to be merged along with default compose.yaml file.
163161
Gaudi example with Open Telemetry feature:
164162

@@ -183,11 +181,9 @@ docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/
183181

184182
</details>
185183

186-
#### Xeon
184+
#### Launch on Xeon
187185

188-
On Xeon, only OpenAI models are supported.
189-
By default, both the RAG Agent and SQL Agent will be launched to support the React Agent.
190-
The React Agent requires the DocIndexRetriever's [`compose.yaml`](../DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml) file, so two `compose yaml` files need to be run with docker compose to start the multi-agent system.
186+
On Xeon, only OpenAI models are supported. The command below will launch the multi-agent system with the `DocIndexRetriever` as the retrieval tool for the Worker RAG agent.
191187

192188
```bash
193189
export OPENAI_API_KEY=<your-openai-key>
@@ -206,9 +202,10 @@ bash run_ingest_data.sh
206202

207203
> **Note**: This is a one-time operation.
208204
209-
## Launch the UI
205+
## How to interact with the agent system with UI
210206

211-
Open a web browser to http://localhost:5173 to access the UI.
207+
The UI microservice is launched in the previous step with the other microservices.
208+
To see the UI, open a web browser to `http://${ip_address}:5173` to access the UI. Note the `ip_address` here is the host IP of the UI microservice.
212209

213210
1. `create Admin Account` with a random value
214211
2. add opea agent endpoint `http://$ip_address:9090/v1` which is a openai compatible api

AgentQnA/docker_compose/intel/hpu/gaudi/compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ services:
104104
- "8080:8000"
105105
ipc: host
106106
agent-ui:
107-
image: opea/agent-ui
107+
image: opea/agent-ui:latest
108108
container_name: agent-ui
109109
environment:
110110
host_ip: ${host_ip}
@@ -138,4 +138,4 @@ services:
138138
cap_add:
139139
- SYS_NICE
140140
ipc: host
141-
command: --model $LLM_MODEL_ID --tensor-parallel-size 4 --host 0.0.0.0 --port 8000 --block-size 128 --max-num-seqs 256 --max-seq_len-to-capture 16384
141+
command: --model $LLM_MODEL_ID --tensor-parallel-size 4 --host 0.0.0.0 --port 8000 --block-size 128 --max-num-seqs 256 --max-seq-len-to-capture 16384
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4+
host_ip=$(hostname -I | awk '{print $1}')
5+
port=6007
46
FILEDIR=${WORKDIR}/GenAIExamples/AgentQnA/example_data/
57
FILENAME=test_docs_music.jsonl
68

7-
python3 index_data.py --filedir ${FILEDIR} --filename ${FILENAME} --host_ip $host_ip
9+
python3 index_data.py --filedir ${FILEDIR} --filename ${FILENAME} --host_ip $host_ip --port $port

AgentQnA/tests/step4_launch_and_validate_agent_gaudi.sh

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ WORKPATH=$(dirname "$PWD")
88
export WORKDIR=$WORKPATH/../../
99
echo "WORKDIR=${WORKDIR}"
1010
export ip_address=$(hostname -I | awk '{print $1}')
11+
export host_ip=$ip_address
12+
echo "ip_address=${ip_address}"
1113
export TOOLSET_PATH=$WORKPATH/tools/
1214
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
1315
HF_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
@@ -24,12 +26,12 @@ ls $HF_CACHE_DIR
2426
vllm_port=8086
2527
vllm_volume=${HF_CACHE_DIR}
2628

27-
function start_tgi(){
28-
echo "Starting tgi-gaudi server"
29+
30+
function start_agent_service() {
31+
echo "Starting agent service"
2932
cd $WORKDIR/GenAIExamples/AgentQnA/docker_compose/intel/hpu/gaudi
3033
source set_env.sh
31-
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml tgi_gaudi.yaml -f compose.telemetry.yaml up -d
32-
34+
docker compose -f compose.yaml up -d
3335
}
3436

3537
function start_all_services() {
@@ -69,7 +71,6 @@ function download_chinook_data(){
6971
cp chinook-database/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite $WORKDIR/GenAIExamples/AgentQnA/tests/
7072
}
7173

72-
7374
function validate() {
7475
local CONTENT="$1"
7576
local EXPECTED_RESULT="$2"
@@ -138,24 +139,6 @@ function remove_chinook_data(){
138139
echo "Chinook data removed!"
139140
}
140141

141-
export host_ip=$ip_address
142-
echo "ip_address=${ip_address}"
143-
144-
145-
function validate() {
146-
local CONTENT="$1"
147-
local EXPECTED_RESULT="$2"
148-
local SERVICE_NAME="$3"
149-
150-
if echo "$CONTENT" | grep -q "$EXPECTED_RESULT"; then
151-
echo "[ $SERVICE_NAME ] Content is as expected: $CONTENT"
152-
echo 0
153-
else
154-
echo "[ $SERVICE_NAME ] Content does not match the expected result: $CONTENT"
155-
echo 1
156-
fi
157-
}
158-
159142
function ingest_data_and_validate() {
160143
echo "Ingesting data"
161144
cd $WORKDIR/GenAIExamples/AgentQnA/retrieval_tool/

AgentQnA/tests/test_compose_on_gaudi.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,39 @@ function build_agent_docker_image() {
2626
docker compose -f build.yaml build --no-cache
2727
}
2828

29+
function build_retrieval_docker_image() {
30+
cd $WORKDIR/GenAIExamples/DocIndexRetriever/docker_image_build/
31+
get_genai_comps
32+
echo "Build retrieval image with --no-cache..."
33+
docker compose -f build.yaml build --no-cache
34+
}
35+
2936
function stop_crag() {
3037
cid=$(docker ps -aq --filter "name=kdd-cup-24-crag-service")
3138
echo "Stopping container kdd-cup-24-crag-service with cid $cid"
3239
if [[ ! -z "$cid" ]]; then docker rm $cid -f && sleep 1s; fi
3340
}
3441

35-
function stop_agent_docker() {
42+
function stop_agent_containers() {
3643
cd $WORKPATH/docker_compose/intel/hpu/gaudi/
37-
docker compose -f $WORKDIR/GenAIExamples/DocIndexRetriever/docker_compose/intel/cpu/xeon/compose.yaml -f compose.yaml down
44+
container_list=$(cat compose.yaml | grep container_name | cut -d':' -f2)
45+
for container_name in $container_list; do
46+
cid=$(docker ps -aq --filter "name=$container_name")
47+
echo "Stopping container $container_name"
48+
if [[ ! -z "$cid" ]]; then docker rm $cid -f && sleep 1s; fi
49+
done
50+
}
51+
52+
function stop_telemetry_containers(){
53+
cd $WORKPATH/docker_compose/intel/hpu/gaudi/
54+
container_list=$(cat compose.telemetry.yaml | grep container_name | cut -d':' -f2)
55+
for container_name in $container_list; do
56+
cid=$(docker ps -aq --filter "name=$container_name")
57+
echo "Stopping container $container_name"
58+
if [[ ! -z "$cid" ]]; then docker rm $cid -f && sleep 1s; fi
59+
done
60+
container_list=$(cat compose.telemetry.yaml | grep container_name | cut -d':' -f2)
61+
3862
}
3963

4064
function stop_llm(){
@@ -69,12 +93,16 @@ function stop_retrieval_tool() {
6993
}
7094
echo "workpath: $WORKPATH"
7195
echo "=================== Stop containers ===================="
96+
stop_llm
7297
stop_crag
73-
stop_agent_docker
98+
stop_agent_containers
99+
stop_retrieval_tool
100+
stop_telemetry_containers
74101

75102
cd $WORKPATH/tests
76103

77104
echo "=================== #1 Building docker images===================="
105+
build_retrieval_docker_image
78106
build_agent_docker_image
79107
echo "=================== #1 Building docker images completed===================="
80108

@@ -83,8 +111,11 @@ bash $WORKPATH/tests/step4_launch_and_validate_agent_gaudi.sh
83111
echo "=================== #4 Agent, retrieval test passed ===================="
84112

85113
echo "=================== #5 Stop agent and API server===================="
114+
stop_llm
86115
stop_crag
87-
stop_agent_docker
116+
stop_agent_containers
117+
stop_retrieval_tool
118+
stop_telemetry_containers
88119
echo "=================== #5 Agent and API server stopped===================="
89120

90121
echo y | docker system prune

AgentQnA/tools/worker_agent_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def search_knowledge_base(query: str) -> str:
1212
print(url)
1313
proxies = {"http": ""}
1414
payload = {
15-
"text": query,
15+
"messages": query,
1616
}
1717
response = requests.post(url, json=payload, proxies=proxies)
1818
print(response)

0 commit comments

Comments
 (0)