Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of predictionguard rerank genai component. #1044

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
tests: added unit tests for ci/cd associated with reranking pg comp
Signed-off-by: Juan Maturino <juanjmaturino@gmail.com>
  • Loading branch information
jjmaturino committed Jan 29, 2025
commit 65a53ec8d555766eb924207e394f60f464a717b1
67 changes: 67 additions & 0 deletions tests/reranks/test_reranks_predictionguard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -x

WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')
function build_docker_images() {
cd $WORKPATH
docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t opea/reranking-predictionguard:comps -f comps/reranks/predictionguard/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/reranking-predictionguard built fail"
exit 1
else
echo "opea/reranking-predictionguard built successful"
fi
}

function start_service() {
predictionguard_service_port=9000
unset http_proxy

docker run -d --name="test-comps-reranking-predictionguard-server" \
-p ${predictionguard_service_port}:9000 \
--ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy \
-e PREDICTIONGUARD_API_KEY=${PREDICTIONGUARD_API_KEY} \
opea/reranking-predictionguard:comps

sleep 1m
}

function validate_microservice() {
predictionguard_service_port=9000
result=$(http_proxy="" curl http://${ip_address}:${predictionguard_service_port}/v1/reranking\
-X POST \
-d '{"initial_query":"What is Deep Learning?", "retrieved_docs": [{"text":"Deep Learning is not..."}, {"text":"Deep learning is..."}]}' \
-H 'Content-Type: application/json')
if [[ $result == *"reranked_docs"* ]]; then
echo "Result correct."
else
echo "Result wrong. Received was $result"
docker logs test-comps-reranking-predictionguard-server
exit 1
fi
}

function stop_docker() {
cid=$(docker ps -aq --filter "name=test-comps-rerank*")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
}

function main() {

stop_docker

build_docker_images
start_service

validate_microservice

stop_docker
echo y | docker system prune

}

main