Skip to content

Commit

Permalink
Merge branch 'main' into zepan/new_check
Browse files Browse the repository at this point in the history
  • Loading branch information
ZePan110 authored Nov 21, 2024
2 parents bf2ea79 + c5177c5 commit 67d89da
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
7 changes: 3 additions & 4 deletions DocIndexRetriever/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests


def search_knowledge_base(query: str, url: str, request_type="chat_completion") -> str:
def search_knowledge_base(query: str, url: str, request_type: str) -> str:
"""Search the knowledge base for a specific query."""
print(url)
proxies = {"http": ""}
Expand All @@ -18,12 +18,13 @@ def search_knowledge_base(query: str, url: str, request_type="chat_completion")
"top_n": 2,
}
else:
print("Sending text request")
print("Sending textdoc request")
payload = {
"text": query,
}
response = requests.post(url, json=payload, proxies=proxies)
print(response)
print(response.json().keys())
if "documents" in response.json():
docs = response.json()["documents"]
context = ""
Expand All @@ -32,7 +33,6 @@ def search_knowledge_base(query: str, url: str, request_type="chat_completion")
context = str(i) + ": " + doc
else:
context += "\n" + str(i) + ": " + doc
# print(context)
return context
elif "text" in response.json():
return response.json()["text"]
Expand All @@ -44,7 +44,6 @@ def search_knowledge_base(query: str, url: str, request_type="chat_completion")
context = doc["text"]
else:
context += "\n" + doc["text"]
# print(context)
return context
else:
return "Error parsing response from the knowledge base."
Expand Down
4 changes: 4 additions & 0 deletions DocIndexRetriever/tests/test_compose_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LOG_PATH="$WORKPATH/tests"
ip_address=$(hostname -I | awk '{print $1}')

function build_docker_images() {
echo "Building Docker Images...."
cd $WORKPATH/docker_image_build
if [ ! -d "GenAIComps" ] ; then
git clone https://github.com/opea-project/GenAIComps.git && cd GenAIComps && git checkout "${opea_branch:-"main"}" && cd ../
Expand All @@ -26,9 +27,11 @@ function build_docker_images() {
docker pull redis/redis-stack:7.2.0-v9
docker pull ghcr.io/huggingface/tei-gaudi:1.5.0
docker images && sleep 1s
echo "Docker images built!"
}

function start_services() {
echo "Starting Docker Services...."
cd $WORKPATH/docker_compose/intel/hpu/gaudi
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
Expand All @@ -47,6 +50,7 @@ function start_services() {
# Start Docker Containers
docker compose up -d
sleep 20
echo "Docker services started!"
}

function validate() {
Expand Down
39 changes: 29 additions & 10 deletions DocIndexRetriever/tests/test_compose_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ LOG_PATH="$WORKPATH/tests"
ip_address=$(hostname -I | awk '{print $1}')

function build_docker_images() {
echo "Building Docker Images...."
cd $WORKPATH/docker_image_build
if [ ! -d "GenAIComps" ] ; then
echo "Cloning GenAIComps repository"
git clone https://github.com/opea-project/GenAIComps.git && cd GenAIComps && git checkout "${opea_branch:-"main"}" && cd ../
fi
service_list="dataprep-redis embedding-tei retriever-redis reranking-tei doc-index-retriever"
Expand All @@ -25,9 +27,12 @@ function build_docker_images() {
docker pull ghcr.io/huggingface/text-embeddings-inference:cpu-1.5
docker pull redis/redis-stack:7.2.0-v9
docker images && sleep 1s

echo "Docker images built!"
}

function start_services() {
echo "Starting Docker Services...."
cd $WORKPATH/docker_compose/intel/cpu/xeon
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export RERANK_MODEL_ID="BAAI/bge-reranker-base"
Expand All @@ -45,7 +50,8 @@ function start_services() {

# Start Docker Containers
docker compose up -d
sleep 20
sleep 5m
echo "Docker services started!"
}

function validate() {
Expand All @@ -66,7 +72,7 @@ function validate_megaservice() {
echo "===========Ingest data=================="
local CONTENT=$(http_proxy="" curl -X POST "http://${ip_address}:6007/v1/dataprep" \
-H "Content-Type: multipart/form-data" \
-F 'link_list=["https://opea.dev"]')
-F 'link_list=["https://opea.dev/"]')
local EXIT_CODE=$(validate "$CONTENT" "Data preparation succeeded" "dataprep-redis-service-xeon")
echo "$EXIT_CODE"
local EXIT_CODE="${EXIT_CODE:0-1}"
Expand All @@ -77,19 +83,26 @@ function validate_megaservice() {
fi

# Curl the Mega Service
echo "================Testing retriever service: Default params================"

local CONTENT=$(curl http://${ip_address}:8889/v1/retrievaltool -X POST -H "Content-Type: application/json" -d '{
"messages": "Explain the OPEA project?"
echo "================Testing retriever service: Text Request ================"
cd $WORKPATH/tests
local CONTENT=$(http_proxy="" curl http://${ip_address}:8889/v1/retrievaltool -X POST -H "Content-Type: application/json" -d '{
"text": "Explain the OPEA project?"
}')
# local CONTENT=$(python test.py --host_ip ${ip_address} --request_type text)
local EXIT_CODE=$(validate "$CONTENT" "OPEA" "doc-index-retriever-service-xeon")
echo "$EXIT_CODE"
local EXIT_CODE="${EXIT_CODE:0-1}"
echo "return value is $EXIT_CODE"
if [ "$EXIT_CODE" == "1" ]; then
docker logs tei-embedding-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Embedding container log=================="
docker logs embedding-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Retriever container log=================="
docker logs retriever-redis-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
docker logs reranking-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============TEI Reranking log=================="
docker logs tei-reranking-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Reranking container log=================="
docker logs reranking-tei-xeon-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Doc-index-retriever container log=================="
docker logs doc-index-retriever-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
exit 1
fi
Expand All @@ -102,9 +115,15 @@ function validate_megaservice() {
local EXIT_CODE="${EXIT_CODE:0-1}"
echo "return value is $EXIT_CODE"
if [ "$EXIT_CODE" == "1" ]; then
docker logs tei-embedding-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Embedding container log=================="
docker logs embedding-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Retriever container log=================="
docker logs retriever-redis-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
docker logs reranking-tei-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============TEI Reranking log=================="
docker logs tei-reranking-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Reranking container log=================="
docker logs reranking-tei-xeon-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
echo "=============Doc-index-retriever container log=================="
docker logs doc-index-retriever-server | tee -a ${LOG_PATH}/doc-index-retriever-service-xeon.log
exit 1
fi
Expand Down

0 comments on commit 67d89da

Please sign in to comment.