Skip to content

Commit

Permalink
Grag ex1.1 (#1123)
Browse files Browse the repository at this point in the history
Signed-off-by: Rita Brugarolas <[email protected]>
Signed-off-by: theresa <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: theresa <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2024
1 parent 39f68d5 commit 6f8fa6a
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions GraphRAG/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To set up environment variables for deploying GraphRAG services, follow these st

### Quick Start: 2.Run Docker Compose

If the microservice images are available in Docker Hub they will be pulled, otherwise you will need to build the container images manually. Please refer to the 'Build Docker Images' in [Guide](../ChatQnA/docker_compose/intel/cpu/xeon/README.md). [test_compose.sh](tests/test_compose.sh) can be a good resource as it shows how to do image build, starting services, validated each microservices and megaservices. This is what is used in CI/CD.
If the microservice images are available in Docker Hub they will be pulled, otherwise you will need to build the container images manually. Please refer to the 'Build Docker Images' in [Guide](../ChatQnA/docker_compose/intel/cpu/xeon/README.md). [test_compose_on_gaudi.sh](tests/test_compose_on_gaudi.sh) can be a good resource as it shows how to do image build, starting services, validated each microservices and megaservices. This is what is used in CI/CD.

Docker compose will start 8 services: ![8 servicesi in GraphRAG](assets/8microservices.png)

Expand Down Expand Up @@ -191,7 +191,7 @@ Working on a table comparison of various model sizes vs. naive RAG with a datase

### Check Service Status

Before consuming GraphRAG Service, make sure each microservice is ready by checking the docker logs of each microservice. [test_compose.sh](tests/test_compose.sh) can be a good resource as it shows how CI/CD validated each microservices based on returned HTTP status and response body.
Before consuming GraphRAG Service, make sure each microservice is ready by checking the docker logs of each microservice. [test_compose_on_gaudi.sh](tests/test_compose_on_gaudi.sh) can be a good resource as it shows how CI/CD validated each microservices based on returned HTTP status and response body.

```bash
docker logs container_name
Expand Down
13 changes: 8 additions & 5 deletions GraphRAG/docker_compose/intel/hpu/gaudi/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

version: "3.8"
services:
neo4j-apoc:
image: neo4j:latest
Expand Down Expand Up @@ -52,6 +51,7 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
HUGGING_FACE_HUB_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
HF_TOKEN: ${HF_TOKEN}
HF_HUB_DISABLE_PROGRESS_BARS: 1
HF_HUB_ENABLE_HF_TRANSFER: 0
HABANA_VISIBLE_DEVICES: all
Expand All @@ -64,9 +64,9 @@ services:
cap_add:
- SYS_NICE
ipc: host
command: --model-id ${LLM_MODEL_ID} --max-input-length 2048 --max-total-tokens 4096
command: --model-id ${LLM_MODEL_ID} --max-input-length 6000 --max-total-tokens 8192
dataprep-neo4j-llamaindex:
image: opea/dataprep-neo4j-llamaindex:latest
image: ${REGISTRY:-opea}/dataprep-neo4j-llamaindex:${TAG:-latest}
container_name: dataprep-neo4j-server
depends_on:
- neo4j-apoc
Expand All @@ -80,6 +80,8 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
host_ip: ${host_ip}
HUGGING_FACE_HUB_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
HF_TOKEN: ${HF_TOKEN}
NEO4J_URL: ${NEO4J_URL}
NEO4J_USERNAME: ${NEO4J_USERNAME}
NEO4J_PASSWORD: ${NEO4J_PASSWORD}
Expand All @@ -93,7 +95,7 @@ services:
LOGFLAG: ${LOGFLAG}
restart: unless-stopped
retriever-neo4j-llamaindex:
image: opea/retriever-neo4j-llamaindex:latest
image: ${REGISTRY:-opea}/retriever-neo4j-llamaindex:${TAG:-latest}
container_name: retriever-neo4j-server
depends_on:
- neo4j-apoc
Expand All @@ -107,6 +109,8 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
host_ip: ${host_ip}
HUGGING_FACE_HUB_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
HF_TOKEN: ${HF_TOKEN}
NEO4J_URL: ${NEO4J_URL}
NEO4J_USERNAME: ${NEO4J_USERNAME}
NEO4J_PASSWORD: ${NEO4J_PASSWORD}
Expand Down Expand Up @@ -136,7 +140,6 @@ services:
- MEGA_SERVICE_HOST_IP=graphrag-gaudi-backend-server
- RETRIEVER_SERVICE_HOST_IP=retriever-neo4j-llamaindex
- RETRIEVER_SERVICE_PORT=6009
- RETRIEVER_SERVICE_PORT=${RETRIEVER_SERVICE_PORT:-80}
- LLM_SERVER_HOST_IP=tgi-gaudi-service
- LLM_SERVER_PORT=${LLM_SERVER_PORT:-80}
- LOGFLAG=${LOGFLAG}
Expand Down
2 changes: 1 addition & 1 deletion GraphRAG/docker_compose/intel/hpu/gaudi/set_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export NEO4J_URL="bolt://${host_ip}:7687"
export NEO4J_USERNAME=neo4j
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6004/v1/dataprep"
export LOGFLAG=True
export RETRIEVER_SERVICE_PORT=6009
export RETRIEVER_SERVICE_PORT=80
6 changes: 5 additions & 1 deletion GraphRAG/graphrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def align_outputs(self, data, cur_node, inputs, runtime_graph, llm_parameters_di
# handle template
# if user provides template, then format the prompt with it
# otherwise, use the default template
prompt = inputs.messages[0]["content"]
print("outputs before align:\n", inputs)
if isinstance(inputs.messages, str):
prompt = inputs.messages
else:
prompt = inputs.messages[0]["content"]
chat_template = llm_parameters_dict["chat_template"]
if chat_template:
prompt_template = PromptTemplate.from_template(chat_template)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -e
set -xe
IMAGE_REPO=${IMAGE_REPO:-"opea"}
IMAGE_TAG=${IMAGE_TAG:-"latest"}
echo "REGISTRY=IMAGE_REPO=${IMAGE_REPO}"
Expand All @@ -11,7 +11,6 @@ export REGISTRY=${IMAGE_REPO}
export TAG=${IMAGE_TAG}

WORKPATH=$(dirname "$PWD")
WORKPATH=/home/rbrugaro/GenAIExamples/GraphRAG
LOG_PATH="$WORKPATH/tests"
ip_address=$(hostname -I | awk '{print $1}')

Expand All @@ -34,6 +33,13 @@ function start_services() {
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export LLM_MODEL_ID="meta-llama/Meta-Llama-3-8B-Instruct"
export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
export HF_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="neo4jtest"
export NEO4J_URL="bolt://${ip_address}:7687"
export TEI_EMBEDDING_ENDPOINT="http://${ip_address}:6006"
export TGI_LLM_ENDPOINT="http://${ip_address}:6005"
export host_ip=${ip_address}

# Start Docker Containers
docker compose -f compose.yaml up -d > ${LOG_PATH}/start_services_with_compose.log
Expand Down
2 changes: 1 addition & 1 deletion GraphRAG/ui/svelte/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHAT_BASE_URL = '/v1/chatqna'
CHAT_BASE_URL = '/v1/graphrag'

UPLOAD_FILE_BASE_URL = '/v1/dataprep'

Expand Down
6 changes: 3 additions & 3 deletions GraphRAG/ui/svelte/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
/* Maximum time one test can run for. */
timeout: 30 * 1000,
timeout: 300 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
timeout: 30000,
},
/* Run tests in files in parallel */
fullyParallel: true,
Expand All @@ -38,7 +38,7 @@ export default defineConfig({
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://10.7.4.57:80",
baseURL: "http://localhost:80",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
Expand Down
2 changes: 1 addition & 1 deletion GraphRAG/ui/svelte/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
>
<div class="mx-auto flex h-full w-full flex-col sm:mt-0 sm:w-[72%]">
<div class="flex justify-between p-2">
<p class="text-[1.7rem] font-bold tracking-tight">ChatQnA</p>
<p class="text-[1.7rem] font-bold tracking-tight">GraphRAG</p>
<UploadFile />
</div>
<div
Expand Down

0 comments on commit 6f8fa6a

Please sign in to comment.