diff --git a/HybridRAG/Dockerfile b/HybridRAG/Dockerfile
new file mode 100644
index 0000000000..782160dccd
--- /dev/null
+++ b/HybridRAG/Dockerfile
@@ -0,0 +1,10 @@
+# Copyright (C) 2025 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+ARG BASE_TAG=latest
+FROM opea/comps-base:$BASE_TAG
+
+COPY ./hybridrag.py $HOME/hybridrag.py
+
+ENTRYPOINT ["python", "hybridrag.py"]
+
diff --git a/HybridRAG/README.md b/HybridRAG/README.md
new file mode 100644
index 0000000000..6cdb5733f8
--- /dev/null
+++ b/HybridRAG/README.md
@@ -0,0 +1,98 @@
+# HybridRAG Application
+
+Enterprise AI systems require solutions that handle both structured data (databases, transactions, CSVs, JSON) and unstructured data (documents, images, audio). While traditional VectorRAG excels at semantic search across documents, it struggles with complex queries requiring global context or relationship-aware reasoning. HybridRAG application addresses these gaps by combining GraphRAG (knowledge graph-based retrieval) and VectorRAG (vector database retrieval) for enhanced accuracy and contextual relevance.
+
+## Table of contents
+
+1. [Architecture](#architecture)
+2. [Deployment](#deployment)
+
+## Architecture
+
+The HybridRAG application is a customizable end-to-end workflow that leverages the capabilities of LLMs and RAG efficiently. HybridRAG architecture is shown below:
+
+
+
+This application is modular as it leverages each component as a microservice(as defined in [GenAIComps](https://github.com/opea-project/GenAIComps)) that can scale independently. It comprises data preparation, embedding, retrieval, reranker(optional) and LLM microservices. All these microservices are stitched together by the HybridRAG megaservice that orchestrates the data through these microservices. The flow chart below shows the information flow between different microservices for this example.
+
+```mermaid
+---
+config:
+ flowchart:
+ nodeSpacing: 400
+ rankSpacing: 100
+ curve: linear
+ themeVariables:
+ fontSize: 50px
+---
+flowchart LR
+ %% Colors %%
+ classDef blue fill:#ADD8E6,stroke:#ADD8E6,stroke-width:2px,fill-opacity:0.5
+ classDef orange fill:#FBAA60,stroke:#ADD8E6,stroke-width:2px,fill-opacity:0.5
+ classDef orchid fill:#C26DBC,stroke:#ADD8E6,stroke-width:2px,fill-opacity:0.5
+ classDef invisible fill:transparent,stroke:transparent;
+ style HybridRAG-MegaService stroke:#000000
+
+ %% Subgraphs %%
+ subgraph HybridRAG-MegaService["HybridRAG MegaService "]
+ direction LR
+ EM([Embedding MicroService]):::blue
+ RET([Retrieval MicroService]):::blue
+ RER([Rerank MicroService]):::blue
+ LLM([LLM MicroService]):::blue
+ direction LR
+ T2C([Text2Cypher MicroService]):::blue
+ LLM([LLM MicroService]):::blue
+ end
+ subgraph UserInterface[" User Interface "]
+ direction LR
+ a([User Input Query]):::orchid
+ UI([UI server
]):::orchid
+ end
+
+
+
+ TEI_RER{{Reranking service
}}
+ TEI_EM{{Embedding service
}}
+ VDB{{Vector DB
}}
+ GDB{{Graph DB
}}
+ R_RET{{Retriever service
}}
+ DP([Data Preparation MicroService]):::blue
+ S2G([Struct2Graph MicroService]):::blue
+ LLM_gen{{LLM Service
}}
+ GW([HybridRAG GateWay
]):::orange
+
+ %% Questions interaction
+ direction LR
+ a[User Input Query] --> UI
+ UI --> GW
+ GW <==> HybridRAG-MegaService
+ EM ==> RET
+ RET ==> RER
+ RER ==> LLM
+ direction LR
+ T2C ==> LLM
+
+
+ %% Embedding service flow
+ direction LR
+ EM <-.-> TEI_EM
+ RET <-.-> R_RET
+ RER <-.-> TEI_RER
+ LLM <-.-> LLM_gen
+
+ direction TB
+ %% Vector DB interaction
+ R_RET <-.->|d|VDB
+ DP <-.->|d|VDB
+
+ direction TB
+ %% Graph DB interaction
+ T2C <-.->|d|GDB
+ S2G <-.->|d|GDB
+
+```
+
+## Deployment
+
+[HybridRAG deployment on Intel Gaudi](./docker_compose/intel/hpu/gaudi/README.md)
diff --git a/HybridRAG/README_NOTICE.md b/HybridRAG/README_NOTICE.md
new file mode 100644
index 0000000000..6874c1bf59
--- /dev/null
+++ b/HybridRAG/README_NOTICE.md
@@ -0,0 +1,3 @@
+# Notice for FFmpeg:
+
+FFmpeg is an open source project licensed under LGPL and GPL. See https://www.ffmpeg.org/legal.html. You are solely responsible for determining if your use of FFmpeg requires any additional licenses. Intel is not responsible for obtaining any such licenses, nor liable for any licensing fees due, in connection with your use of FFmpeg.
diff --git a/HybridRAG/assets/img/hybridrag_retriever_architecture.png b/HybridRAG/assets/img/hybridrag_retriever_architecture.png
new file mode 100644
index 0000000000..b4dc2466fc
Binary files /dev/null and b/HybridRAG/assets/img/hybridrag_retriever_architecture.png differ
diff --git a/HybridRAG/docker_compose/intel/hpu/gaudi/README.md b/HybridRAG/docker_compose/intel/hpu/gaudi/README.md
new file mode 100644
index 0000000000..3f9fc045ef
--- /dev/null
+++ b/HybridRAG/docker_compose/intel/hpu/gaudi/README.md
@@ -0,0 +1,161 @@
+# Example HybridRAG deployments on an Intel® Gaudi® Platform
+
+This example covers the single-node on-premises deployment of the HybridRAG example using OPEA components. There are various ways to enable HybridRAG, but this example will focus on four options available for deploying the HybridRAG pipeline to Intel® Gaudi® AI Accelerators.
+
+**Note** This example requires access to a properly installed Intel® Gaudi® platform with a functional Docker service configured to use the habanalabs-container-runtime. Please consult the [Intel® Gaudi® software Installation Guide](https://docs.habana.ai/en/v1.20.0/Installation_Guide/Driver_Installation.html) for more information.
+
+## HybridRAG Quick Start Deployment
+
+This section describes how to quickly deploy and test the HybridRAG service manually on an Intel® Gaudi® platform. The basic steps are:
+
+### Access the Code
+
+Clone the GenAIExample repository and access the HybridRAG Intel® Gaudi® platform Docker Compose files and supporting scripts:
+
+```
+git clone https://github.com/opea-project/GenAIExamples.git
+cd GenAIExamples/HybridRAG/docker_compose/intel/hpu/gaudi/
+```
+
+Checkout a released version, such as v1.4:
+
+```
+git checkout v1.4
+```
+
+### Generate a HuggingFace Access Token
+
+Some HuggingFace resources, such as some models, are only accessible if you have an access token. If you do not already have a HuggingFace access token, you can create one by first creating an account by following the steps provided at [HuggingFace](https://huggingface.co/) and then generating a [user access token](https://huggingface.co/docs/transformers.js/en/guides/private#step-1-generating-a-user-access-token).
+
+### Configure the Deployment Environment
+
+To set up environment variables for deploying HybridRAG services, source the _setup_env.sh_ script in this directory:
+
+```
+source ./set_env.sh
+```
+
+### Deploy the Services Using Docker Compose
+
+To deploy the HybridRAG services, execute the `docker compose up` command with the appropriate arguments. For a default deployment, execute:
+
+```bash
+docker compose up -d
+```
+
+The HybridRAG docker images should automatically be downloaded from the `OPEA registry` and deployed on the Intel® Gaudi® Platform:
+
+```
+[+] Running 9/9
+ ✔ Container redis-vector-db Healthy 6.4s
+ ✔ Container vllm-service Started 0.4s
+ ✔ Container tei-embedding-server Started 0.9s
+ ✔ Container neo4j-apoc Healthy 11.4s
+ ✔ Container tei-reranking-server Started 0.8s
+ ✔ Container retriever-redis-server Started 1.0s
+ ✔ Container dataprep-redis-server Started 6.5s
+ ✔ Container text2cypher-gaudi-container Started 12.2s
+ ✔ Container hybridrag-xeon-backend-server Started 12.4s
+```
+
+To rebuild the docker image for the hybridrag-xeon-backend-server container:
+
+```
+cd GenAIExamples/HybridRAG
+docker build --no-cache -t opea/hybridrag:latest -f Dockerfile .
+```
+
+### Check the Deployment Status
+
+After running docker compose, check if all the containers launched via docker compose have started:
+
+```
+docker ps -a
+```
+
+For the default deployment, the following 10 containers should have started:
+
+```
+CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
+a9286abd0015 opea/hybridrag:latest "python hybridrag.py" 15 hours ago Up 15 hours 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp hybridrag-xeon-backend-server
+8477b154dc72 opea/text2cypher-gaudi:latest "/bin/sh -c 'bash ru…" 15 hours ago Up 15 hours 0.0.0.0:11801->9097/tcp, [::]:11801->9097/tcp text2cypher-gaudi-container
+688e01a431fa opea/dataprep:latest "sh -c 'python $( [ …" 15 hours ago Up 15 hours 0.0.0.0:6007->5000/tcp, [::]:6007->5000/tcp dataprep-redis-server
+54f574fe54bb opea/retriever:latest "python opea_retriev…" 15 hours ago Up 15 hours 0.0.0.0:7000->7000/tcp, :::7000->7000/tcp retriever-redis-server
+5028eb66617c ghcr.io/huggingface/text-embeddings-inference:cpu-1.6 "text-embeddings-rou…" 15 hours ago Up 15 hours 0.0.0.0:8808->80/tcp, [::]:8808->80/tcp tei-reranking-server
+a9dbf8a13365 opea/vllm:latest "python3 -m vllm.ent…" 15 hours ago Up 15 hours (healthy) 0.0.0.0:9009->80/tcp, [::]:9009->80/tcp vllm-service
+43f44830f47b neo4j:latest "tini -g -- /startup…" 15 hours ago Up 15 hours (healthy) 0.0.0.0:7474->7474/tcp, :::7474->7474/tcp, 7473/tcp, 0.0.0.0:7687->7687/tcp, :::7687->7687/tcp neo4j-apoc
+867feabb6f11 redis/redis-stack:7.2.0-v9 "/entrypoint.sh" 15 hours ago Up 15 hours (healthy) 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp, 0.0.0.0:8001->8001/tcp, :::8001->8001/tcp redis-vector-db
+23cd7f16453b ghcr.io/huggingface/text-embeddings-inference:cpu-1.6 "text-embeddings-rou…" 15 hours ago Up 15 hours 0.0.0.0:6006->80/tcp, [::]:6006->80/tcp tei-embedding-server
+```
+
+### Test the Pipeline
+
+Once the HybridRAG services are running, run data ingestion. The following command is ingesting unstructure data:
+
+```bash
+cd GenAIExamples/HybridRAG/tests
+curl -X POST -H "Content-Type: multipart/form-data" \
+ -F "files=@./Diabetes.txt" \
+ -F "files=@./Acne_Vulgaris.txt" \
+ -F "chunk_size=300" \
+ -F "chunk_overlap=20" \
+ http://${host_ip}:6007/v1/dataprep/ingest
+```
+
+The data files (Diabetes.txt and Acne_Vulgaris.txt) are samples downloaded from Wikipedia, and they are here to facilitate the pipeline tests. Users are encouraged to download their own datasets, and the command above should be updated with the proper file names.
+
+As for the structured data, the application is pre-seeded with structured data and schema by default. To create a knowledge graph with custom data and schema, set the cypher_insert environment variable prior to application deployment.
+
+```bash
+export cypher_insert='
+ LOAD CSV WITH HEADERS FROM "https://docs.google.com/spreadsheets/d/e/2PACX-1vQCEUxVlMZwwI2sn2T1aulBrRzJYVpsM9no8AEsYOOklCDTljoUIBHItGnqmAez62wwLpbvKMr7YoHI/pub?gid=0&single=true&output=csv" AS rows
+ MERGE (d:disease {name:rows.Disease})
+ MERGE (dt:diet {name:rows.Diet})
+ MERGE (d)-[:HOME_REMEDY]->(dt)
+
+ MERGE (m:medication {name:rows.Medication})
+ MERGE (d)-[:TREATMENT]->(m)
+
+ MERGE (s:symptoms {name:rows.Symptom})
+ MERGE (d)-[:MANIFESTATION]->(s)
+
+ MERGE (p:precaution {name:rows.Precaution})
+ MERGE (d)-[:PREVENTION]->(p)
+'
+```
+
+If the graph database is already populated, you can skip the knowledge graph generation by setting the refresh_db environment variable:
+
+```bash
+export refresh_db='False'
+```
+
+Now test the pipeline using the following command:
+
+```bash
+curl -s -X POST -d '{"messages": "what are the symptoms for Diabetes?"}' \
+ -H 'Content-Type: application/json' \
+ "${host_ip}:8888/v1/hybridrag"
+```
+
+To collect per request latency for the pipeline, run the following:
+
+```bash
+curl -o /dev/null -s -w "Total Time: %{time_total}s\n" \
+ -X POST \
+ -d '{"messages": "what are the symptoms for Diabetes?"}' \
+ -H 'Content-Type: application/json' \
+ "${host_ip}:8888/v1/hybridrag"
+```
+
+**Note** The value of _host_ip_ was set using the _set_env.sh_ script and can be found in the _.env_ file.
+
+### Cleanup the Deployment
+
+To stop the containers associated with the deployment, execute the following command:
+
+```
+docker compose -f compose.yaml down
+```
+
+All the HybridRAG containers will be stopped and then removed on completion of the "down" command.
diff --git a/HybridRAG/docker_compose/intel/hpu/gaudi/compose.yaml b/HybridRAG/docker_compose/intel/hpu/gaudi/compose.yaml
new file mode 100644
index 0000000000..2ae35cf5ed
--- /dev/null
+++ b/HybridRAG/docker_compose/intel/hpu/gaudi/compose.yaml
@@ -0,0 +1,240 @@
+# Copyright (C) 2025 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+services:
+ text2cypher-gaudi:
+ image: ${REGISTRY:-opea}/text2cypher-gaudi:${TAG:-latest}
+ container_name: text2cypher-gaudi-container
+ ports:
+ - "11801:9097"
+ depends_on:
+ neo4j-apoc:
+ condition: service_healthy
+ ipc: host
+ environment:
+ no_proxy: ${no_proxy}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ INDEX_NAME: ${INDEX_NAME}
+ HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
+ HF_TOKEN: ${HF_TOKEN}
+ LOGFLAG: ${LOGFLAG:-False}
+ HABANA_VISIBLE_DEVICES: all
+ OMPI_MCA_btl_vader_single_copy_mechanism: none
+ TOKENIZERS_PARALLELISM: False
+ NEO4J_URI: ${NEO4J_URI}
+ NEO4J_URL: ${NEO4J_URI}
+ NEO4J_USERNAME: ${NEO4J_USERNAME}
+ NEO4J_PASSWORD: ${NEO4J_PASSWORD}
+ host_ip: ${host_ip}
+ runtime: habana
+ cap_add:
+ - SYS_NICE
+ restart: unless-stopped
+ neo4j-apoc:
+ image: neo4j:latest
+ container_name: neo4j-apoc
+ ports:
+ - "${NEO4J_PORT1:-7474}:7474"
+ - "${NEO4J_PORT2:-7687}:7687"
+ volumes:
+ - ./data/neo4j/logs:/logs
+ - ./data/neo4j/config:/config
+ - ./data/neo4j/data:/data
+ - ./data/neo4j/plugins:/plugins
+ ipc: host
+ environment:
+ - no_proxy=${no_proxy}
+ - http_proxy=${http_proxy}
+ - https_proxy=${https_proxy}
+ - NEO4J_AUTH=${NEO4J_USERNAME}/${NEO4J_PASSWORD}
+ - NEO4J_PLUGINS=["apoc"]
+ - NEO4J_apoc_export_file_enabled=true
+ - NEO4J_apoc_import_file_enabled=true
+ - NEO4J_apoc_import_file_use__neo4j__config=true
+ - NEO4J_dbms_security_procedures_unrestricted=apoc.\*
+ - NEO4J_server_bolt_advertised__address=localhost:${NEO4J_PORT2}
+ restart: always
+ healthcheck:
+ test: wget http://localhost:7474 || exit 1
+ interval: 5s
+ timeout: 10s
+ retries: 20
+ start_period: 3s
+ redis-vector-db:
+ image: redis/redis-stack:7.2.0-v9
+ container_name: redis-vector-db
+ ports:
+ - "6379:6379"
+ - "8001:8001"
+ healthcheck:
+ test: ["CMD", "redis-cli", "ping"]
+ interval: 5s
+ timeout: 3s
+ retries: 10
+ dataprep-redis-service:
+ image: ${REGISTRY:-opea}/dataprep:${TAG:-latest}
+ container_name: dataprep-redis-server
+ depends_on:
+ redis-vector-db:
+ condition: service_healthy
+ tei-embedding-service:
+ condition: service_started
+ ports:
+ - "6007:5000"
+ environment:
+ no_proxy: ${no_proxy}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ REDIS_URL: redis://redis-vector-db:6379
+ REDIS_HOST: redis-vector-db
+ INDEX_NAME: ${INDEX_NAME}
+ TEI_ENDPOINT: http://tei-embedding-service:80
+ HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
+ tei-embedding-service:
+ image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.6
+ container_name: tei-embedding-server
+ ports:
+ - "6006:80"
+ volumes:
+ - "${MODEL_CACHE:-./data}:/data"
+ shm_size: 1g
+ environment:
+ no_proxy: ${no_proxy}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ command: --model-id ${EMBEDDING_MODEL_ID} --auto-truncate
+ retriever:
+ image: ${REGISTRY:-opea}/retriever:${TAG:-latest}
+ container_name: retriever-redis-server
+ depends_on:
+ - redis-vector-db
+ ports:
+ - "7000:7000"
+ ipc: host
+ environment:
+ no_proxy: ${no_proxy}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ REDIS_URL: redis://redis-vector-db:6379
+ REDIS_HOST: redis-vector-db
+ INDEX_NAME: ${INDEX_NAME}
+ TEI_EMBEDDING_ENDPOINT: http://tei-embedding-service:80
+ HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
+ LOGFLAG: ${LOGFLAG}
+ RETRIEVER_COMPONENT_NAME: "OPEA_RETRIEVER_REDIS"
+ restart: unless-stopped
+ tei-reranking-service:
+ image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.6
+ container_name: tei-reranking-server
+ ports:
+ - "8808:80"
+ volumes:
+ - "${MODEL_CACHE:-./data}:/data"
+ shm_size: 1g
+ environment:
+ no_proxy: ${no_proxy}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
+ HF_HUB_DISABLE_PROGRESS_BARS: 1
+ HF_HUB_ENABLE_HF_TRANSFER: 0
+ command: --model-id ${RERANK_MODEL_ID} --auto-truncate
+ vllm-service:
+ image: ${REGISTRY:-opea}/vllm:${TAG:-latest}
+ container_name: vllm-service
+ ports:
+ - "9009:80"
+ volumes:
+ - "${MODEL_CACHE:-./data}:/root/.cache/huggingface/hub"
+ shm_size: 128g
+ environment:
+ no_proxy: ${no_proxy}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ HF_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
+ LLM_MODEL_ID: ${LLM_MODEL_ID}
+ VLLM_TORCH_PROFILER_DIR: "/mnt"
+ VLLM_CPU_KVCACHE_SPACE: 40
+ healthcheck:
+ test: ["CMD-SHELL", "curl -f http://$host_ip:9009/health || exit 1"]
+ interval: 10s
+ timeout: 10s
+ retries: 100
+ command: --model $LLM_MODEL_ID --host 0.0.0.0 --port 80
+ hybridrag-xeon-backend-server:
+ image: ${REGISTRY:-opea}/hybridrag:${TAG:-latest}
+ container_name: hybridrag-xeon-backend-server
+ depends_on:
+ - redis-vector-db
+ - retriever
+ - tei-reranking-service
+ - vllm-service
+ - neo4j-apoc
+ - text2cypher-gaudi
+ - tei-embedding-service
+ #- struct2graph
+ ports:
+ - "8888:8888"
+ environment:
+ - no_proxy=${no_proxy}
+ - https_proxy=${https_proxy}
+ - http_proxy=${http_proxy}
+ - MEGA_SERVICE_HOST_IP=${MEGA_SERVICE_HOST_IP}
+ - EMBEDDING_SERVER_HOST_IP=${EMBEDDING_SERVER_HOST_IP}
+ - EMBEDDING_SERVER_PORT=${EMBEDDING_SERVER_PORT}
+ - RETRIEVER_SERVER_HOST_IP=${RETRIEVER_SERVER_HOST_IP}
+ - RETRIEVER_SERVER_PORT=${RETRIEVER_SERVER_PORT}
+ - RERANK_SERVER_HOST_IP=${RERANK_SERVER_HOST_IP}
+ - RERANK_SERVER_PORT=${RERANK_SERVER_PORT}
+ - LLM_SERVER_HOST_IP=${LLM_SERVER_HOST_IP}
+ - LLM_SERVER_PORT=${LLM_SERVER_PORT}
+ - TEXT2CYPHER_SERVER_HOST_IP=${TEXT2CYPHER_SERVER_HOST_IP}
+ - TEXT2CYPHER_SERVER_PORT=${TEXT2CYPHER_SERVER_PORT:-9097}
+ - LLM_MODEL=${LLM_MODEL_ID}
+ - LOGFLAG=${LOGFLAG}
+ - NEO4J_URL=${NEO4J_URL}
+ - NEO4J_server_directories_import=import
+ - NEO4J_PLUGINS=["apoc"]
+ - NEO4J_dbms_security_allow__csv__import__from__file__urls=true
+ - NEO4J_dbms_security_procedures_unrestricted=apoc.*
+ ipc: host
+ restart: always
+ hybridrag-xeon-ui-server:
+ image: ${REGISTRY:-opea}/hybridrag-ui:${TAG:-latest}
+ container_name: hybridrag-xeon-ui-server
+ depends_on:
+ - hybridrag-xeon-backend-server
+ ports:
+ - "5173:5173"
+ environment:
+ - no_proxy=${no_proxy}
+ - https_proxy=${https_proxy}
+ - http_proxy=${http_proxy}
+ ipc: host
+ restart: always
+ hybridrag-xeon-nginx-server:
+ image: ${REGISTRY:-opea}/nginx:${TAG:-latest}
+ container_name: hybridrag-xeon-nginx-server
+ depends_on:
+ - hybridrag-xeon-backend-server
+ - hybridrag-xeon-ui-server
+ ports:
+ - "${NGINX_PORT:-80}:80"
+ environment:
+ - no_proxy=${no_proxy}
+ - https_proxy=${https_proxy}
+ - http_proxy=${http_proxy}
+ - FRONTEND_SERVICE_IP=hybridrag-xeon-ui-server
+ - FRONTEND_SERVICE_PORT=5173
+ - BACKEND_SERVICE_NAME=hybridrag
+ - BACKEND_SERVICE_IP=hybridrag-xeon-backend-server
+ - BACKEND_SERVICE_PORT=8888
+ - DATAPREP_SERVICE_IP=dataprep-redis-service
+ - DATAPREP_SERVICE_PORT=5000
+ ipc: host
+ restart: always
+
+networks:
+ default:
+ driver: bridge
diff --git a/HybridRAG/docker_compose/intel/hpu/gaudi/set_env.sh b/HybridRAG/docker_compose/intel/hpu/gaudi/set_env.sh
new file mode 100644
index 0000000000..a828fb565d
--- /dev/null
+++ b/HybridRAG/docker_compose/intel/hpu/gaudi/set_env.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2024 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+export host_ip=$(hostname -I | awk '{print $1}')
+export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
+export HF_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
+
+export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
+export RERANK_MODEL_ID="BAAI/bge-reranker-base"
+export LLM_MODEL_ID="meta-llama/Meta-Llama-3-8B-Instruct"
+export INDEX_NAME="rag-redis"
+# Set it as a non-null string, such as true, if you want to enable logging facility,
+# otherwise, keep it as "" to disable it.
+export LOGFLAG=""
+# Set OpenTelemetry Tracing Endpoint
+export JAEGER_IP=$(ip route get 8.8.8.8 | grep -oP 'src \K[^ ]+')
+export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=grpc://$JAEGER_IP:4317
+export TELEMETRY_ENDPOINT=http://$JAEGER_IP:4318/v1/traces
+# Set no proxy
+export no_proxy="$no_proxy,hybridrag-gaudi-ui-server,hybridrag-gaudi-backend-server,dataprep-redis-service,tei-embedding-service,retriever,tei-reranking-service,tgi-service,vllm-service,jaeger,prometheus,grafana,node-exporter,localhost,127.0.0.1,$JAEGER_IP,${host_ip}"
+
+
+export MEGA_SERVICE_HOST_IP=${host_ip}
+export EMBEDDING_SERVER_HOST_IP=${host_ip}
+export RETRIEVER_SERVER_HOST_IP=${host_ip}
+export RERANK_SERVER_HOST_IP=${host_ip}
+export LLM_SERVER_HOST_IP=${host_ip}
+export TEXT2CYPHER_SERVER_HOST_IP=${host_ip}
+export REDIS_SERVER_HOST_IP=${host_ip}
+
+export MEGA_SERVICE_PORT=8888
+export EMBEDDING_SERVER_PORT=6006
+export RETRIEVER_SERVER_PORT=7000
+export RERANK_SERVER_PORT=8808
+export LLM_SERVER_PORT=9009
+export TEXT2CYPHER_SERVER_PORT=11801
+export REDIS_SERVER_PORT=6379
+
+export LLM_ENDPOINT_PORT=8010
+export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
+export HYBRIDRAG_REDIS_VECTOR_PORT=6379
+export HYBRIDRAG_REDIS_VECTOR_INSIGHT_PORT=8001
+export HYBRIDRAG_FRONTEND_SERVICE_PORT=5173
+export HYBRIDRAG_BACKEND_SERVICE_ENDPOINT=http://${host_ip}:8888/v1/hybridrag
+export NGINX_PORT=80
+export FAQGen_COMPONENT_NAME="OpeaFaqGenvLLM"
+
+export NEO4J_PORT1=7474
+export NEO4J_PORT2=7687
+export NEO4J_URI="bolt://${host_ip}:${NEO4J_PORT2}"
+export NEO4J_URL="bolt://${host_ip}:${NEO4J_PORT2}"
+export NEO4J_USERNAME="neo4j"
+export NEO4J_PASSWORD="neo4jtest"
+export LOGFLAG=True
diff --git a/HybridRAG/docker_image_build/build.yaml b/HybridRAG/docker_image_build/build.yaml
new file mode 100644
index 0000000000..7c23807736
--- /dev/null
+++ b/HybridRAG/docker_image_build/build.yaml
@@ -0,0 +1,51 @@
+# Copyright (C) 2024 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+services:
+ hybridrag:
+ build:
+ args:
+ IMAGE_REPO: ${REGISTRY}
+ BASE_TAG: ${TAG}
+ http_proxy: ${http_proxy}
+ https_proxy: ${https_proxy}
+ no_proxy: ${no_proxy}
+ context: ../
+ dockerfile: ./Dockerfile
+ image: ${REGISTRY:-opea}/hybridrag:${TAG:-latest}
+ text2cypher:
+ build:
+ context: GenAIComps
+ dockerfile: comps/text2cypher/src/Dockerfile.intel_hpu
+ extends: hybridrag
+ image: ${REGISTRY:-opea}/text2cypher-gaudi:${TAG:-latest}
+ vllm:
+ build:
+ context: vllm
+ dockerfile: docker/Dockerfile.cpu
+ extends: hybridrag
+ image: ${REGISTRY:-opea}/vllm:${TAG:-latest}
+ dataprep:
+ build:
+ context: GenAIComps
+ dockerfile: comps/dataprep/src/Dockerfile
+ extends: hybridrag
+ image: ${REGISTRY:-opea}/dataprep:${TAG:-latest}
+ retriever:
+ build:
+ context: GenAIComps
+ dockerfile: comps/retrievers/src/Dockerfile
+ extends: hybridrag
+ image: ${REGISTRY:-opea}/retriever:${TAG:-latest}
+ nginx:
+ build:
+ context: GenAIComps
+ dockerfile: comps/third_parties/nginx/src/Dockerfile
+ extends: hybridrag
+ image: ${REGISTRY:-opea}/nginx:${TAG:-latest}
+ hybridrag-ui:
+ build:
+ context: ../ui
+ dockerfile: ./docker/Dockerfile
+ extends: hybridrag
+ image: ${REGISTRY:-opea}/hybridrag-ui:${TAG:-latest}
diff --git a/HybridRAG/hybridrag.py b/HybridRAG/hybridrag.py
new file mode 100644
index 0000000000..a7d48cd809
--- /dev/null
+++ b/HybridRAG/hybridrag.py
@@ -0,0 +1,464 @@
+# Copyright (C) 2025 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+import argparse
+import ast
+import asyncio
+import json
+import os
+import re
+import time
+
+import requests
+from comps import MegaServiceEndpoint, MicroService, ServiceOrchestrator, ServiceRoleType, ServiceType
+from comps.cores.mega.utils import handle_message
+from comps.cores.proto.api_protocol import (
+ ChatCompletionRequest,
+ ChatCompletionResponse,
+ ChatCompletionResponseChoice,
+ ChatMessage,
+ UsageInfo,
+)
+from comps.cores.proto.docarray import LLMParams, RerankerParms, RetrieverParms
+from fastapi import Request
+from fastapi.responses import StreamingResponse
+from langchain_core.prompts import PromptTemplate
+
+
+class ChatTemplate:
+ @staticmethod
+ def generate_rag_prompt(question, documents):
+ context_str = "\n".join(documents)
+ if context_str and len(re.findall("[\u4e00-\u9fff]", context_str)) / len(context_str) >= 0.3:
+ # chinese context
+ template = """
+### 你将扮演一个乐于助人、尊重他人并诚实的助手,你的目标是帮助用户解答问题。有效地利用来自本地知识库的搜索结果。确保你的回答中只包含相关信息。如果你不确定问题的答案,请避免分享不准确的信息。
+### 搜索结果:{context}
+### 问题:{question}
+### 回答:
+"""
+ else:
+ template = """
+### You are a helpful, respectful and honest assistant to help the user with questions. \
+Please refer to the search results obtained from the local knowledge base. \
+But be careful to not incorporate the information that you think is not relevant to the question. \
+If you don't know the answer to a question, please don't share false information. \n
+### Search results: {context} \n
+### Question: {question} \n
+### Answer:
+"""
+ return template.format(context=context_str, question=question)
+
+ @staticmethod
+ def generate_fuse_prompt(question, unstruct_documents, struct_str):
+ unstruct_str = "\n".join(unstruct_documents)
+ context_str = f"Structured: {struct_str} Unstructured: {unstruct_str}"
+ if context_str and len(re.findall("[\u4e00-\u9fff]", context_str)) / len(context_str) >= 0.3:
+ # chinese context
+ template = """
+您是一位知識豐富的助手,經過訓練來整合結構化和非結構化的信息,以統一的方式回答問題。在答案中不要區分結構化和非結構化的信息。
+回答問題: {question}。指示: 僅使用提供的結構化和非結構化檢索結果來回答問題。
+{context}
+"""
+ else:
+ template = """
+You are a knowledgeable assistant trained to integrate information for both structured and unstructured retrieval results to answer questions in a unified manner. Do not differentiate structured and unstructured information in the answer. Answer the question: {question}. Instructions: Use only the provided structured and unstructured results to answer the question. {context}.
+"""
+ return template.format(context=context_str, question=question)
+
+
+MEGA_SERVICE_PORT = int(os.getenv("MEGA_SERVICE_PORT", 8888))
+EMBEDDING_SERVER_HOST_IP = os.getenv("EMBEDDING_SERVER_HOST_IP", "0.0.0.0")
+EMBEDDING_SERVER_PORT = int(os.getenv("EMBEDDING_SERVER_PORT", 80))
+RETRIEVER_SERVER_HOST_IP = os.getenv("RETRIEVER_SERVER_HOST_IP", "0.0.0.0")
+RETRIEVER_SERVER_PORT = int(os.getenv("RETRIEVER_SERVER_PORT", 7000))
+RERANK_SERVER_HOST_IP = os.getenv("RERANK_SERVER_HOST_IP", "0.0.0.0")
+RERANK_SERVER_PORT = int(os.getenv("RERANK_SERVER_PORT", 80))
+LLM_SERVER_HOST_IP = os.getenv("LLM_SERVER_HOST_IP", "0.0.0.0")
+LLM_SERVER_PORT = int(os.getenv("LLM_SERVER_PORT", 80))
+TEXT2CYPHER_SERVER_HOST_IP = os.getenv("TEXT2CYPHER_SERVER_HOST_IP", "0.0.0.0")
+TEXT2CYPHER_SERVER_PORT = int(os.getenv("TEXT2CYPHER_SERVER_PORT", 11801))
+REDIS_SERVER_HOST_IP = os.getenv("REDIS_SERVER_HOST_IP", "0.0.0.0")
+REDIS_SERVER_PORT = int(os.getenv("REDIS_SERVER_PORT", 6379))
+refresh_db = os.getenv("refresh_db", "True")
+cypher_insert = os.getenv("cypher_insert", None)
+
+LLM_MODEL = os.getenv("LLM_MODEL", "meta-llama/Meta-Llama-3-8B-Instruct")
+
+
+def align_inputs(self, inputs, cur_node, runtime_graph, llm_parameters_dict, **kwargs):
+ if self.services[cur_node].service_type == ServiceType.EMBEDDING:
+ inputs["inputs"] = inputs["text"]
+ del inputs["text"]
+ elif self.services[cur_node].service_type == ServiceType.RETRIEVER:
+ # prepare the retriever params
+ retriever_parameters = kwargs.get("retriever_parameters", None)
+ if retriever_parameters:
+ inputs.update(retriever_parameters.dict())
+ elif self.services[cur_node].service_type == ServiceType.LLM:
+ # convert TGI/vLLM to unified OpenAI /v1/chat/completions format
+ next_inputs = {}
+ next_inputs["model"] = LLM_MODEL
+ next_inputs["messages"] = [{"role": "user", "content": inputs["inputs"]}]
+ next_inputs["max_tokens"] = llm_parameters_dict["max_tokens"]
+ next_inputs["top_p"] = llm_parameters_dict["top_p"]
+ next_inputs["stream"] = inputs["stream"]
+ next_inputs["frequency_penalty"] = inputs["frequency_penalty"]
+ next_inputs["temperature"] = inputs["temperature"]
+ inputs = next_inputs
+ return inputs
+
+
+def align_outputs(self, data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs):
+ next_data = {}
+ if self.services[cur_node].service_type == ServiceType.EMBEDDING:
+ assert isinstance(data, list)
+ next_data = {"text": inputs["inputs"], "embedding": data[0]}
+ elif self.services[cur_node].service_type == ServiceType.RETRIEVER:
+
+ docs = [doc["text"] for doc in data["retrieved_docs"]]
+
+ with_rerank = runtime_graph.downstream(cur_node)[0].startswith("rerank")
+ if with_rerank and docs:
+ # forward to rerank
+ # prepare inputs for rerank
+ next_data["query"] = data["initial_query"]
+ next_data["texts"] = [doc["text"] for doc in data["retrieved_docs"]]
+ else:
+ # forward to llm
+ if not docs and with_rerank:
+ # delete the rerank from retriever -> rerank -> llm
+ for ds in reversed(runtime_graph.downstream(cur_node)):
+ for nds in runtime_graph.downstream(ds):
+ runtime_graph.add_edge(cur_node, nds)
+ runtime_graph.delete_node_if_exists(ds)
+
+ # handle template
+ # if user provides template, then format the prompt with it
+ # otherwise, use the default template
+ prompt = data["initial_query"]
+ chat_template = llm_parameters_dict["chat_template"]
+ if chat_template:
+ prompt_template = PromptTemplate.from_template(chat_template)
+ input_variables = prompt_template.input_variables
+ if sorted(input_variables) == ["context", "question"]:
+ prompt = prompt_template.format(question=data["initial_query"], context="\n".join(docs))
+ elif input_variables == ["question"]:
+ prompt = prompt_template.format(question=data["initial_query"])
+ else:
+ print(f"{prompt_template} not used, we only support 2 input variables ['question', 'context']")
+ prompt = ChatTemplate.generate_rag_prompt(data["initial_query"], docs)
+ else:
+ prompt = ChatTemplate.generate_rag_prompt(data["initial_query"], docs)
+
+ next_data["inputs"] = prompt
+
+ elif self.services[cur_node].service_type == ServiceType.RERANK:
+ # rerank the inputs with the scores
+ reranker_parameters = kwargs.get("reranker_parameters", None)
+ prompt = inputs["query"]
+ hybridrag = kwargs.get("hybridrag", None)
+ # retrieve structured from cache
+ timeout = 120 # seconds
+ interval = 1 # polling interval in seconds
+ elapsed = 0
+
+ retrieved = None
+ structured_result = ""
+ while elapsed < timeout:
+ retrieved = hybridrag.cache
+ if retrieved is not None:
+ break
+ time.sleep(interval)
+ elapsed += interval
+ if retrieved:
+ structured_result = retrieved
+
+ # reset the cache
+ hybridrag.cache = None
+
+ top_n = reranker_parameters.top_n if reranker_parameters else 1
+ docs = inputs["texts"]
+ reranked_docs = []
+ for best_response in data[:top_n]:
+ reranked_docs.append(docs[best_response["index"]])
+
+ unstruct_str = "\n".join(reranked_docs)
+ fused = f"Structured: {structured_result} Unstructured: {unstruct_str}"
+
+ # handle template
+ # if user provides template, then format the prompt with it
+ # otherwise, use the default template
+ chat_template = llm_parameters_dict["chat_template"]
+ if chat_template:
+ prompt_template = PromptTemplate.from_template(chat_template)
+ input_variables = prompt_template.input_variables
+ if sorted(input_variables) == ["context", "question"]:
+ prompt = prompt_template.format(question=prompt, context=fused)
+ elif input_variables == ["question"]:
+ prompt = prompt_template.format(question=prompt)
+ else:
+ print(f"{prompt_template} not used, we only support 2 input variables ['question', 'context']")
+ prompt = ChatTemplate.generate_fuse_prompt(prompt, reranked_docs, structured_result)
+ else:
+ prompt = ChatTemplate.generate_fuse_prompt(prompt, reranked_docs, structured_result)
+
+ next_data["inputs"] = prompt
+
+ elif self.services[cur_node].service_type == ServiceType.LLM and not llm_parameters_dict["stream"]:
+ if "faqgen" in self.services[cur_node].endpoint:
+ next_data = data
+ else:
+ next_data["text"] = data["choices"][0]["message"]["content"]
+ else:
+ next_data = data
+
+ return next_data
+
+
+def align_generator(self, gen, **kwargs):
+ # OpenAI response format
+ # b'data:{"id":"","object":"text_completion","created":1725530204,"model":"meta-llama/Meta-Llama-3-8B-Instruct","system_fingerprint":"2.0.1-native","choices":[{"index":0,"delta":{"role":"assistant","content":"?"},"logprobs":null,"finish_reason":null}]}\n\n'
+ for line in gen:
+ line = line.decode("utf-8")
+ start = line.find("{")
+ end = line.rfind("}") + 1
+
+ json_str = line[start:end]
+ try:
+ # sometimes yield empty chunk, do a fallback here
+ json_data = json.loads(json_str)
+ if "ops" in json_data and "op" in json_data["ops"][0]:
+ if "value" in json_data["ops"][0] and isinstance(json_data["ops"][0]["value"], str):
+ yield f"data: {repr(json_data['ops'][0]['value'].encode('utf-8'))}\n\n"
+ else:
+ pass
+ elif (
+ json_data["choices"][0]["finish_reason"] != "eos_token"
+ and "content" in json_data["choices"][0]["delta"]
+ ):
+ yield f"data: {repr(json_data['choices'][0]['delta']['content'].encode('utf-8'))}\n\n"
+ except Exception as e:
+ yield f"data: {repr(json_str.encode('utf-8'))}\n\n"
+ yield "data: [DONE]\n\n"
+
+
+class HybridRAGService:
+ def __init__(self, host="0.0.0.0", port=8000):
+ self.host = host
+ self.port = port
+ self.cache = None
+ ServiceOrchestrator.align_inputs = align_inputs
+ ServiceOrchestrator.align_outputs = align_outputs
+ ServiceOrchestrator.align_generator = align_generator
+ self.megaservice = ServiceOrchestrator()
+ self.endpoint = str(MegaServiceEndpoint.HYBRID_RAG)
+
+ async def exec_text2cypher(self, prompt):
+ url = f"http://{TEXT2CYPHER_SERVER_HOST_IP}:{TEXT2CYPHER_SERVER_PORT}/v1/text2cypher"
+ headers = {"Content-Type": "application/json"}
+ if refresh_db == "False":
+ data = {"input_text": prompt, "seeding": {"refresh_db": "False"}}
+ elif cypher_insert is not None:
+ data = {"input_text": prompt, "seeding": {"cypher_insert": "'${cypher_insert}'", "refresh_db": "True"}}
+ else:
+ data = {"input_text": prompt}
+ response = requests.post(url, json=data)
+ data = response.json()
+ data_str = str(data)
+ start_marker = "['"
+ end_marker = "']"
+
+ # Find the start and end indices
+ start_index = data_str.find(start_marker) + len(start_marker) # Move past the start marker
+ end_index = data_str.find(end_marker, start_index) # Find the end marker
+
+ # Extract the substring
+ substring = data_str[start_index:end_index]
+
+ # Clean up the substring
+ structured = ",".join(item.strip().strip("'") for item in substring.split(","))
+
+ # save to cache
+ self.cache = structured
+ return structured
+
+ def add_remote_service(self):
+
+ embedding = MicroService(
+ name="embedding",
+ host=EMBEDDING_SERVER_HOST_IP,
+ port=EMBEDDING_SERVER_PORT,
+ endpoint="/embed",
+ use_remote_service=True,
+ service_type=ServiceType.EMBEDDING,
+ )
+
+ text2cypher = MicroService(
+ name="text2cypher",
+ host=TEXT2CYPHER_SERVER_HOST_IP,
+ port=TEXT2CYPHER_SERVER_PORT,
+ endpoint="/text2cypher",
+ use_remote_service=True,
+ service_type=ServiceType.TEXT2CYPHER,
+ )
+
+ retriever = MicroService(
+ name="retriever",
+ host=RETRIEVER_SERVER_HOST_IP,
+ port=RETRIEVER_SERVER_PORT,
+ endpoint="/v1/retrieval",
+ use_remote_service=True,
+ service_type=ServiceType.RETRIEVER,
+ )
+
+ rerank = MicroService(
+ name="rerank",
+ host=RERANK_SERVER_HOST_IP,
+ port=RERANK_SERVER_PORT,
+ endpoint="/rerank",
+ use_remote_service=True,
+ service_type=ServiceType.RERANK,
+ )
+
+ llm = MicroService(
+ name="llm",
+ host=LLM_SERVER_HOST_IP,
+ port=LLM_SERVER_PORT,
+ endpoint="/v1/chat/completions",
+ use_remote_service=True,
+ service_type=ServiceType.LLM,
+ )
+
+ # Add the microservices to the megaservice orchestrator and define the flow
+ self.megaservice.add(embedding).add(retriever).add(rerank).add(llm)
+ self.megaservice.flow_to(embedding, retriever)
+ self.megaservice.flow_to(retriever, rerank)
+ self.megaservice.flow_to(rerank, llm)
+
+ async def read_streaming_response(self, response: StreamingResponse):
+ """Reads the streaming response from a StreamingResponse object.
+
+ Parameters:
+ - self: Reference to the current instance of the class.
+ - response: The StreamingResponse object to read from.
+
+ Returns:
+ - str: The complete response body as a decoded string.
+ """
+ body = b"" # Initialize an empty byte string to accumulate the response chunks
+ async for chunk in response.body_iterator:
+ body += chunk # Append each chunk to the body
+ return body.decode("utf-8") # Decode the accumulated byte string to a regular string
+
+ async def process_prompt(self, prompt, llm_parameters, retriever_parameters, reranker_parameters):
+ # Create tasks for concurrent execution
+ exec_task = asyncio.create_task(self.exec_text2cypher(prompt))
+ schedule_task = asyncio.create_task(
+ self.megaservice.schedule(
+ initial_inputs={"text": prompt},
+ llm_parameters=llm_parameters,
+ retriever_parameters=retriever_parameters,
+ reranker_parameters=reranker_parameters,
+ hybridrag=self,
+ )
+ )
+
+ # Wait for both tasks to complete
+ structured_result = await exec_task
+ result_dict, runtime_graph = await schedule_task
+
+ return result_dict, runtime_graph
+
+ async def handle_request(self, request: Request):
+ """Handles the incoming request, processes it through the appropriate microservices,
+ and returns the response.
+
+ Parameters:
+ - self: Reference to the current instance of the class.
+ - request: The incoming request object.
+
+ Returns:
+ - ChatCompletionResponse: The response from the LLM microservice.
+ """
+ # Parse the incoming request data
+ data = await request.json()
+
+ # Get the stream option from the request data, default to True if not provided
+ stream_opt = data.get("stream", True)
+
+ # Validate and parse the chat request data
+ chat_request = ChatCompletionRequest.model_validate(data) # parse_obj(data)
+
+ # Handle the chat messages to generate the prompt
+ prompt = handle_message(chat_request.messages)
+
+ # Define the LLM parameters
+ llm_parameters = LLMParams(
+ max_tokens=chat_request.max_tokens if chat_request.max_tokens else 2048,
+ top_k=chat_request.top_k if chat_request.top_k else 10,
+ top_p=chat_request.top_p if chat_request.top_p else 0.95,
+ temperature=chat_request.temperature if chat_request.temperature else 0.01,
+ frequency_penalty=chat_request.frequency_penalty if chat_request.frequency_penalty else 0.0,
+ presence_penalty=chat_request.presence_penalty if chat_request.presence_penalty else 0.0,
+ repetition_penalty=chat_request.repetition_penalty if chat_request.repetition_penalty else 1.03,
+ stream=stream_opt,
+ chat_template=chat_request.chat_template if chat_request.chat_template else None,
+ model=chat_request.model if chat_request.model else None,
+ )
+
+ # Define the retriever parameters
+ retriever_parameters = RetrieverParms(
+ search_type=chat_request.search_type if chat_request.search_type else "similarity",
+ k=chat_request.k if chat_request.k else 4,
+ distance_threshold=chat_request.distance_threshold if chat_request.distance_threshold else None,
+ fetch_k=chat_request.fetch_k if chat_request.fetch_k else 20,
+ lambda_mult=chat_request.lambda_mult if chat_request.lambda_mult else 0.5,
+ score_threshold=chat_request.score_threshold if chat_request.score_threshold else 0.2,
+ )
+
+ # Define the reranker parameters
+ reranker_parameters = RerankerParms(
+ top_n=chat_request.top_n if chat_request.top_n else 1,
+ )
+
+ result_dict, runtime_graph = await self.process_prompt(
+ prompt, llm_parameters, retriever_parameters, reranker_parameters
+ )
+ for node, response in result_dict.items():
+ if isinstance(response, StreamingResponse):
+ return response
+ last_node = runtime_graph.all_leaves()[-1]
+ response = result_dict[last_node]["text"]
+ choices = []
+ usage = UsageInfo()
+ choices.append(
+ ChatCompletionResponseChoice(
+ index=0,
+ message=ChatMessage(role="assistant", content=response),
+ finish_reason="stop",
+ )
+ )
+ return ChatCompletionResponse(model="hybridrag", choices=choices, usage=usage)
+
+ def start(self):
+
+ self.service = MicroService(
+ self.__class__.__name__,
+ service_role=ServiceRoleType.MEGASERVICE,
+ host=self.host,
+ port=self.port,
+ endpoint=self.endpoint,
+ input_datatype=ChatCompletionRequest,
+ output_datatype=ChatCompletionResponse,
+ )
+
+ self.service.add_route(self.endpoint, self.handle_request, methods=["POST"])
+ self.service.start()
+
+
+if __name__ == "__main__":
+ hybridrag = HybridRAGService(port=MEGA_SERVICE_PORT)
+ hybridrag.add_remote_service()
+
+ hybridrag.start()
diff --git a/HybridRAG/tests/data/Acne_Vulgaris.txt b/HybridRAG/tests/data/Acne_Vulgaris.txt
new file mode 100644
index 0000000000..7c24616a3d
--- /dev/null
+++ b/HybridRAG/tests/data/Acne_Vulgaris.txt
@@ -0,0 +1 @@
+Acne (/ˈækni/ ACK-nee), also known as acne vulgaris, is a long-term skin condition that occurs when dead skin cells and oil from the skin clog hair follicles. Typical features of the condition include blackheads or whiteheads, pimples, oily skin, and possible scarring. It primarily affects skin with a relatively high number of oil glands, including the face, upper part of the chest, and back. The resulting appearance can lead to lack of confidence, anxiety, reduced self-esteem, and, in extreme cases, depression or thoughts of suicide.Susceptibility to acne is primarily genetic in 80% of cases. The roles of diet and cigarette smoking in the condition are unclear, and neither cleanliness nor exposure to sunlight are associated with acne. In both sexes, hormones called androgens appear to be part of the underlying mechanism, by causing increased production of sebum. Another common factor is the excessive growth of the bacterium Cutibacterium acnes, which is present on the skin.Treatments for acne are available, including lifestyle changes, medications, and medical procedures. Eating fewer simple carbohydrates such as sugar may minimize the condition. Treatments applied directly to the affected skin, such as azelaic acid, benzoyl peroxide, and salicylic acid, are commonly used. Antibiotics and retinoids are available in formulations that are applied to the skin and taken by mouth for the treatment of acne. However, resistance to antibiotics may develop as a result of antibiotic therapy. Several types of birth control pills help prevent acne in women. Medical professionals typically reserve isotretinoin pills for severe acne, due to greater potential side effects. Early and aggressive treatment of acne is advocated by some in the medical community to decrease the overall long-term impact on individuals.In 2015, acne affected approximately 633 million people globally, making it the eighth-most common disease worldwide. Acne commonly occurs in adolescence and affects an estimated 80–90% of teenagers in the Western world. Some rural societies report lower rates of acne than industrialized ones. Children and adults may also be affected before and after puberty. Although acne becomes less common in adulthood, it persists in nearly half of affected people into their twenties and thirties, and a smaller group continues to have difficulties in their forties. Classification The severity of acne vulgaris (Gr. ἀκμή, "point" + L. vulgaris, "common") can be classified as mild, moderate, or severe to determine an appropriate treatment regimen. There is no universally accepted scale for grading acne severity. The presence of clogged skin follicles (known as comedones) limited to the face with occasional inflammatory lesions defines mild acne. Moderate severity acne is said to occur when a higher number of inflammatory papules and pustules occur on the face, compared to mild cases of acne, and appear on the trunk of the body. Severe acne is said to occur when nodules (the painful 'bumps' lying under the skin) are the characteristic facial lesions, and involvement of the trunk is extensive.The lesions are usually, polymorphic, meaning they can take many forms, including open or closed comedones (commonly known as blackheads and whiteheads), papules, pustules, and even nodules or cysts so that these lesions often leave behind sequelae, or abnormal conditions resulting from a previous disease, such as scarring or hyperpigmentation.Large nodules were previously called cysts. The term nodulocystic has been used in the medical literature to describe severe cases of inflammatory acne. True cysts are rare in those with acne, and the term severe nodular acne is now the preferred terminology.Acne inversa (L. invertō, "upside-down") and acne rosacea (rosa, "rose-colored" + -āceus, "forming") are not forms of acne and are alternate names that respectively refer to the skin conditions hidradenitis suppurativa (HS) and rosacea. Although HS shares certain overlapping features with acne vulgaris, such as a tendency to clog skin follicles with skin cell debris, the condition otherwise lacks the hallmark features of acne and is therefore considered a distinct skin disorder. Signs and symptoms Typical features of acne include increased secretion of oily sebum by the skin, microcomedones, comedones, papules, nodules (large papules), pustules, and often results in scarring. The appearance of acne varies with skin color. It may result in psychological and social problems. Scars Acne scars are caused by inflammation within the dermis and are estimated to affect 95% of people with acne vulgaris. Abnormal healing and dermal inflammation create the scar. Scarring is most likely to take place with severe acne but may occur with any form of acne vulgaris. Acne scars are classified based on whether the abnormal healing response following dermal inflammation leads to excess collagen deposition or loss at the site of the acne lesion.Atrophic acne scars have lost collagen from the healing response and are the most common type of acne scar (accounting for approximately 75% of all acne scars). Ice-pick scars, boxcar scars, and rolling scars are subtypes of atrophic acne scars. Boxcar scars are round or ovoid indented scars with sharp borders and vary in size from 1.5–4 mm across. Ice-pick scars are narrow (less than 2 mm across), deep scars that extend into the dermis. Rolling scars are broader than ice-pick and boxcar scars (4–5 mm across) and have a wave-like pattern of depth in the skin.Hypertrophic scars are uncommon and are characterized by increased collagen content after the abnormal healing response. They are described as firm and raised from the skin. Hypertrophic scars remain within the original margins of the wound, whereas keloid scars can form scar tissue outside of these borders. Keloid scars from acne occur more often in men and people with darker skin, and usually occur on the trunk of the body. Pigmentation After an inflamed nodular acne lesion resolves, it is common for the skin to darken in that area, which is known as postinflammatory hyperpigmentation (PIH). The inflammation stimulates specialized pigment-producing skin cells (known as melanocytes) to produce more melanin pigment, which leads to the skin's darkened appearance. PIH occurs more frequently in people with darker skin color. Pigmented scar is a common term used for PIH, but is misleading as it suggests the color change is permanent. Often, PIH can be prevented by avoiding any aggravation of the nodule and can fade with time. However, untreated PIH can last for months, years, or even be permanent if deeper layers of skin are affected. Even minimal skin exposure to the sun's ultraviolet rays can sustain hyperpigmentation. Daily use of SPF 15 or higher sunscreen can minimize such a risk. Whitening agents like azelaic acid, arbutin or else may be used to improve hyperpigmentation. Causes Risk factors for the development of acne, other than genetics, have not been conclusively identified. Possible secondary contributors include hormones, infections, diet, and stress. Studies investigating the impact of smoking on the incidence and severity of acne have been inconclusive. Cleanliness (hygiene) and sunlight are not associated with acne. Genes Acne appears to be highly heritable; genetics explain 81% of the variation in the population. Studies performed in affected twins and first-degree relatives further demonstrate the strongly inherited nature of acne. Acne susceptibility is likely due to the influence of multiple genes, as the disease does not follow a classic (Mendelian) inheritance pattern. These gene candidates include certain variations in tumor necrosis factor-alpha (TNF-alpha), IL-1 alpha, and CYP1A1 genes, among others. The 308 G/A single nucleotide polymorphism variation in the gene for TNF is associated with an increased risk for acne. Acne can be a feature of rare genetic disorders such as Apert's syndrome. Severe acne may be associated with XYY syndrome. Hormones Hormonal activity, such as occurs during menstrual cycles and puberty, may contribute to the formation of acne. During puberty, an increase in sex hormones called androgens causes the skin follicle glands to grow larger and make more oily sebum. The androgen hormones testosterone, dihydrotestosterone (DHT), and dehydroepiandrosterone (DHEA) are all linked to acne. High levels of growth hormone (GH) and insulin-like growth factor 1 (IGF-1) are also associated with worsened acne. Both androgens and IGF-1 seem to be essential for acne to occur, as acne does not develop in individuals with complete androgen insensitivity syndrome (CAIS) or Laron syndrome (insensitivity to GH, resulting in very low IGF-1 levels).Medical conditions that commonly cause a high-androgen state, such as polycystic ovary syndrome, congenital adrenal hyperplasia, and androgen-secreting tumors, can cause acne in affected individuals. Conversely, people who lack androgenic hormones or are insensitive to the effects of androgens rarely have acne. Pregnancy can increase androgen levels, and consequently, oily sebum synthesis. Acne can be a side effect of testosterone replacement therapy or anabolic steroid use. Over-the-counter bodybuilding and dietary supplements often contain illegally added anabolic steroids. Infections The anaerobic bacterial species Cutibacterium acnes (formerly Propionibacterium acnes) contributes to the development of acne, but its exact role is not well understood. There are specific sub-strains of C. acnes associated with normal skin and others with moderate or severe inflammatory acne. It is unclear whether these undesirable strains evolve on-site or are acquired, or possibly both depending on the person. These strains have the capability of changing, perpetuating, or adapting to the abnormal cycle of inflammation, oil production, and inadequate sloughing of dead skin cells from acne pores. Infection with the parasitic mite Demodex is associated with the development of acne. It is unclear whether eradication of the mite improves acne. Diet High-glycemic-load diets have been found to have different degrees of effect on acne severity. Multiple randomized controlled trials and nonrandomized studies have found a lower-glycemic-load diet to be effective in reducing acne. There is weak observational evidence suggesting that dairy milk consumption is positively associated with a higher frequency and severity of acne. Milk contains whey protein and hormones such as bovine IGF-1 and precursors of dihydrotestosterone. Studies suggest these components promote the effects of insulin and IGF-1 and thereby increase the production of androgen hormones, sebum, and promote the formation of comedones. Available evidence does not support a link between eating chocolate or salt and acne severity. Few studies have examined the relationship between obesity and acne. Vitamin B12 may trigger skin outbreaks similar to acne (acneiform eruptions), or worsen existing acne when taken in doses exceeding the recommended daily intake. Stress There are few high-quality studies to demonstrate that stress causes or worsens acne. Despite being controversial, some research indicates that increased acne severity is associated with high stress levels in certain contexts, such as hormonal changes seen in premenstrual syndrome. Other Some individuals experience severe intensification of their acne when they are exposed to hot humid climates; this is due to bacteria and fungus thriving in warm, moist environments. This climate-induced acne exacerbation has been termed tropical acne.Mechanical obstruction of skin follicles with helmets or chinstraps can worsen pre-existing acne. However, acne caused by mechanical obstruction is technically not acne vulgaris, but another acneiform eruption known as acne mechanica.Several medications can also worsen pre-existing acne; this condition is the acne medicamentosaform of acne. Examples of such medications include lithium, hydantoin, isoniazid, glucocorticoids, iodides, bromides, and testosterone. When acne medicamentosa is specifically caused by anabolic–androgenic steroids it can simply be referred to as steroid acne. Genetically susceptible individuals can get acne breakouts as a result of polymorphous light eruption; a condition triggered by sunlight and artificial UV light exposure. This form of acne is called Acne aestivalis and is specifically caused by intense UVA light exposure. Affected individuals usually experience seasonal acne breakouts on their upper arms, shoulder girdle, back, and chest. The breakouts typically occur one-to-three days after exposure to intese UVA radiation. Unlike other forms of acne, the condition spares the face; this could possibly be a result of the pathogenesis of polymorphous light eruption, in which areas of the skin that are newly exposed to intense ultraviolet radiation are affected. Since faces are typically left uncovered at all stages of life, there is little-to-no likelihood for an eruption to appear there. Studies show that both polymorphous light eruption outbreaks and the acne aestivalis breakout response can be prevented by topical antioxidants combined with the application of a broad spectrum sunscreen. Pathophysiology Acne vulgaris is a chronic skin disease of the pilosebaceous unit and develops due to blockages in the skin's hair follicles.Traditionally seen as a disease of adolescence, acne vulgaris is also observed in adults, including post-menopausal women. Acne vulgaris manifested in adult female is called adult female acne (AFA), defined as a chronic inflammatory disease of the pilosebaceous unit. Particularly in AFA, during the menopausal transition, a relative increase in androgen levels occurs as estrogen levels begin to decline, so that this hormonal shift can manifest as acne; while most women with AFA exhibit few acne lesions and have normal androgen levels, baseline investigations, including an androgen testing panel, can help rule out associated comorbidities such as polycystic ovarian syndrome, congenital adrenal hyperplasia, or tumors.The blockages in the skin's hair follicles that cause acne vulgaris manifestations occur as a result of the following four abnormal processes: increased oily sebum production (influenced by androgens), excessive deposition of the protein keratin leading to comedo formation, colonization of the follicle by Cutibacterium acnes (C. acnes) bacteria, and the local release of pro-inflammatory chemicals in the skin.The earliest pathologic change is the formation of a plug (a microcomedone), which is driven primarily by excessive growth, reproduction, and accumulation of skin cells in the hair follicle. In healthy skin, the skin cells that have died come up to the surface and exit the pore of the hair follicle. In people with acne, the increased production of oily sebum causes the dead skin cells to stick together. The accumulation of dead skin cell debris and oily sebum blocks the pore of the hair follicle, thus forming the microcomedone. The C. acnes biofilm within the hair follicle worsens this process. If the microcomedone is superficial within the hair follicle, the skin pigment melanin is exposed to air, resulting in its oxidation and dark appearance (known as a blackhead or open comedo). In contrast, if the microcomedone occurs deep within the hair follicle, this causes the formation of a whitehead (known as a closed comedo).The main hormonal driver of oily sebum production in the skin is dihydrotestosterone. Another androgenic hormone responsible for increased sebaceous gland activity is DHEA-S. The adrenal glands secrete higher amounts of DHEA-S during adrenarche (a stage of puberty), and this leads to an increase in sebum production. In a sebum-rich skin environment, the naturally occurring and largely commensal skin bacterium C. acnes readily grows and can cause inflammation within and around the follicle due to activation of the innate immune system. C. acnes triggers skin inflammation in acne by increasing the production of several pro-inflammatory chemical signals (such as IL-1α, IL-8, TNF-α, and LTB4); IL-1α is essential to comedo formation.C. acnes' ability to bind and activate a class of immune system receptors known as toll-like receptors (TLRs), especially TLR2 and TLR4, is a core mechanism of acne-related skin inflammation. Activation of TLR2 and TLR4 by C. acnes leads to increased secretion of IL-1α, IL-8, and TNF-α. The release of these inflammatory signals attracts various immune cells to the hair follicle, including neutrophils, macrophages, and Th1 cells. IL-1α stimulates increased skin cell activity and reproduction, which, in turn, fuels comedo development. Furthermore, sebaceous gland cells produce more antimicrobial peptides, such as HBD1 and HBD2, in response to the binding of TLR2 and TLR4.C. acnes also provokes skin inflammation by altering the fatty composition of oily sebum. Oxidation of the lipid squalene by C. acnes is of particular importance. Squalene oxidation activates NF-κB (a protein complex) and consequently increases IL-1α levels. Additionally, squalene oxidation increases 5-lipoxygenase enzyme activity, which catalyzes the conversion of arachidonic acid to leukotriene B4 (LTB4). LTB4 promotes skin inflammation by acting on the peroxisome proliferator-activated receptor alpha (PPARα) protein. PPARα increases the activity of activator protein 1 (AP-1) and NF-κB, thereby leading to the recruitment of inflammatory T cells. C. acnes' ability to convert sebum triglycerides to pro-inflammatory free fatty acids via secretion of the enzyme lipase further explains its inflammatory properties. These free fatty acids spur increased production of cathelicidin, HBD1, and HBD2, thus leading to further inflammation.This inflammatory cascade typically leads to the formation of inflammatory acne lesions, including papules, infected pustules, or nodules. If the inflammatory reaction is severe, the follicle can break into the deeper layers of the dermis and subcutaneous tissue and cause the formation of deep nodules. The involvement of AP-1 in the aforementioned inflammatory cascade activates matrix metalloproteinases, which contribute to local tissue destruction and scar formation.Along with the bacteria C. acnes, the bacterial species Staphylococcus epidermidis (S. epidermidis) also takes a part in the physiopathology of acne vulgaris. The proliferation of S. epidermidis with C. acnes causes the formation of biofilms, which blocks the hair follicles and pores, creating an anaerobic environment under the skin. This enables for increased growth of both C. acnes and S. epidermidis under the skin. The proliferation of C. acnes causes the formation of biofilms and a biofilm matrix, making it even harder to treat the acne. Diagnosis Acne vulgaris is diagnosed based on a medical professional's clinical judgment. The evaluation of a person with suspected acne should include taking a detailed medical history about a family history of acne, a review of medications taken, signs or symptoms of excessive production of androgen hormones, cortisol, and growth hormone. Comedones (blackheads and whiteheads) must be present to diagnose acne. In their absence, an appearance similar to that of acne would suggest a different skin disorder. Microcomedones (the precursor to blackheads and whiteheads) are not visible to the naked eye when inspecting the skin and require a microscope to be seen. Many features may indicate that a person's acne vulgaris is sensitive to hormonal influences. Historical and physical clues that may suggest hormone-sensitive acne include onset between ages 20 and 30; worsening the week before a woman's period; acne lesions predominantly over the jawline and chin; and inflammatory/nodular acne lesions.Several scales exist to grade the severity of acne vulgaris, but disagreement persists about the ideal one for diagnostic use. Cook's acne grading scale uses photographs to grade severity from 0 to 8, with higher numbers representing more severe acne. This scale was the first to use a standardized photographic protocol to assess acne severity; since its creation in 1979, the scale has undergone several revisions. The Leeds acne grading technique counts acne lesions on the face, back, and chest and categorizes them as inflammatory or non-inflammatory. Leeds scores range from 0 (least severe) to 10 (most severe) though modified scales have a maximum score of 12. The Pillsbury acne grading scale classifies the severity of the acne from grade 1 (least severe) to grade 4 (most severe). Differential diagnosis Many skin conditions can mimic acne vulgaris, and these are collectively known as acneiform eruptions. Such conditions include angiofibromas, epidermal cysts, flat warts, folliculitis, keratosis pilaris, milia, perioral dermatitis, and rosacea, among others. Age is one factor that may help distinguish between these disorders. Skin disorders such as perioral dermatitis and keratosis pilaris can appear similar to acne but tend to occur more frequently in childhood. Rosacea tends to occur more frequently in older adults. Facial redness triggered by heat or the consumption of alcohol or spicy food is also more suggestive of rosacea. The presence of comedones helps health professionals differentiate acne from skin disorders that are similar in appearance. Chloracne and occupational acne due to exposure to certain chemicals & industrial compounds, may look very similar to acne vulgaris. Management Many different treatments exist for acne. These include alpha hydroxy acid, anti-androgen medications, antibiotics, antiseborrheic medications, azelaic acid, benzoyl peroxide, hormonal treatments, keratolytic soaps, nicotinamide, retinoids, and salicylic acid. Acne treatments work in at least four different ways, including the following: reducing inflammation, hormonal manipulation, killing C. acnes, and normalizing skin cell shedding and sebum production in the pore to prevent blockage. Typical treatments include topical therapies such as antibiotics, benzoyl peroxide, and retinoids, and systemic therapies, including antibiotics, hormonal agents, and oral retinoids.Recommended therapies for first-line use in acne vulgaris treatment include topical retinoids, benzoyl peroxide, and topical or oral antibiotics. Procedures such as light therapy and laser therapy are not first-line treatments and typically have only an add on role due to their high cost and limited evidence. Blue light therapy is of unclear benefit. Medications for acne target the early stages of comedo formation and are generally ineffective for visible skin lesions; acne generally improves between eight and twelve weeks after starting therapy.People often view acne as a short-term condition, some expecting it to disappear after puberty. This misconception can lead to depending on self-management or problems with long-term adherence to treatment. Communicating the long-term nature of the condition and better access to reliable information about acne can help people know what to expect from treatments. Skin care In general, it is recommended that people with acne do not wash affected skin more than twice daily. The application of a fragrance-free moisturizer to sensitive and acne-prone skin may reduce irritation. Skin irritation from acne medications typically peaks at two weeks after onset of use and tends to improve with continued use. Dermatologists recommend using cosmetic products that specifically say non-comedogenic, oil-free, and will not clog pores.Acne vulgaris patients, even those with oily skin, should moisturize in order to support the skin's moisture barrier since skin barrier dysfunction may contribute to acne. Moisturizers, especially ceramide-containing moisturizers, as an adjunct therapy are particularly helpful for the dry skin and irritation that commonly results from topical acne treatment. Studies show that ceramide-containing moisturizers are important for optimal skin care; they enhance acne therapy adherence and complement existing acne therapies. In a study where acne patients used 1.2% clindamycin phosphate / 2.5% benzoyl peroxide gel in the morning and applied a micronized 0.05% tretinoin gel in the evening the overwhelming majority of patients experienced no cutaneous adverse events throughout the study. It was concluded that using ceramide cleanser and ceramide moisturizing cream caused the favorable tolerability, did not interfere with the treatment efficacy, and improved adherence to the regimen. The importance of preserving the acidic mantle and its barrier functions is widely accepted in the scientific community. Thus, maintaining a pH in the range 4.5 – 5.5 is essential in order to keep the skin surface in its optimal, healthy conditions. Diet Causal relationship is rarely observed with diet/nutrition and dermatologic conditions. Rather, associations – some of them compelling – have been found between diet and outcomes including disease severity and the number of conditions experienced by a patient. Evidence is emerging in support of medical nutrition therapy as a way of reducing the severity and incidence of dermatologic diseases, including acne. Researchers observed a link between high glycemic index diets and acne. Dermatologists also recommend a diet low in simple sugars as a method of improving acne. As of 2014, the available evidence is insufficient to use milk restriction for this purpose. Medications Benzoyl peroxide Benzoyl peroxide (BPO) is a first-line treatment for mild and moderate acne due to its effectiveness and mild side-effects (mainly skin irritation). In the skin follicle, benzoyl peroxide kills C. acnes by oxidizing its proteins through the formation of oxygen free radicals and benzoic acid. These free radicals likely interfere with the bacterium's metabolism and ability to make proteins. Additionally, benzoyl peroxide is mildly effective at breaking down comedones and inhibiting inflammation. Combination products use benzoyl peroxide with a topical antibiotic or retinoid, such as benzoyl peroxide/clindamycin and benzoyl peroxide/adapalene, respectively. Topical benzoyl peroxide is effective at treating acne.Side effects include increased skin photosensitivity, dryness, redness, and occasional peeling. Sunscreen use is often advised during treatment, to prevent sunburn. Lower concentrations of benzoyl peroxide are just as effective as higher concentrations in treating acne but are associated with fewer side effects. Unlike antibiotics, benzoyl peroxide does not appear to generate bacterial antibiotic resistance. Retinoids Retinoids are medications that reduce inflammation, normalize the follicle cell life cycle, and reduce sebum production. They are structurally related to vitamin A. Studies show dermatologists and primary care doctors underprescribe them for acne. The retinoids appear to influence the cell life cycle in the follicle lining. This helps prevent the accumulation of skin cells within the hair follicle that can create a blockage. They are a first-line acne treatment, especially for people with dark-colored skin. Retinoids are known to lead to faster improvement of postinflammatory hyperpigmentation.Topical retinoids include adapalene, retinol, retinaldehyde, isotretinoin, tazarotene, trifarotene, and tretinoin. They often cause an initial flare-up of acne and facial flushing and can cause significant skin irritation. Generally speaking, retinoids increase the skin's sensitivity to sunlight and are therefore recommended for use at night. Tretinoin is the least expensive of the topical retinoids and is the most irritating to the skin, whereas adapalene is the least irritating but costs significantly more. Most formulations of tretinoin are incompatible for use with benzoyl peroxide. Tazarotene is the most effective and expensive topical retinoid but is usually not as well tolerated. In 2019 a tazarotene lotion formulation, marketed to be a less irritating option, was approved by the FDA. Retinol is a form of vitamin A that has similar but milder effects and is present in many over-the-counter moisturizers and other topical products.Isotretinoin is an oral retinoid that is very effective for severe nodular acne, and moderate acne that is stubborn to other treatments. One to two months of use is typically adequate to see improvement. Acne often resolves completely or is much milder after a 4–6 month course of oral isotretinoin. After a single round of treatment, about 80% of people report an improvement, with more than 50% reporting complete remission. About 20% of people require a second course, but 80% of those report improvement, resulting in a cumulative 96% efficacy rate.There are concerns that isotretinoin is linked to adverse effects, like depression, suicidality, and anemia. There is no clear evidence to support some of these claims. Isotretinoin has been found in some studies to be superior to antibiotics or placebo in reducing acne lesions. However, a 2018 review comparing inflammatory lesions after treatment with antibiotics or isotretinoin found no difference. The frequency of adverse events was about twice as high with isotretinoin use, although these were mostly dryness-related events. No increased risk of suicide or depression was conclusively found.Medical authorities strictly regulate isotretinoin use in women of childbearing age due to its known harmful effects in pregnancy. For such a woman to be considered a candidate for isotretinoin, she must have a confirmed negative pregnancy test and use an effective form of birth control. In 2008, the United States started the iPLEDGE program to prevent isotretinoin use during pregnancy. iPledge requires the woman to have two negative pregnancy tests and to use two types of birth control for at least one month before isotretinoin therapy begins and one month afterward. The effectiveness of the iPledge program is controversial due to continued instances of contraception nonadherence. Antibiotics People may apply antibiotics to the skin or take them orally to treat acne. They work by killing C. acnes and reducing inflammation. Although multiple guidelines call for healthcare providers to reduce the rates of prescribed oral antibiotics, many providers do not follow this guidance. Oral antibiotics remain the most commonly prescribed systemic therapy for acne. Widespread broad-spectrum antibiotic overuse for acne has led to higher rates of antibiotic-resistant C. acnes strains worldwide, especially to the commonly used tetracycline (e.g., doxycycline) and macrolide antibiotics (e.g., topical erythromycin). Therefore, dermatologists prefer antibiotics as part of combination therapy and not for use alone.Commonly used antibiotics, either applied to the skin or taken orally, include clindamycin, erythromycin, metronidazole, sulfacetamide, and tetracyclines (e.g., doxycycline or minocycline). Doxycycline 40 milligrams daily (low-dose) appears to have similar efficacy to 100 milligrams daily and has fewer gastrointestinal side effects. However, low-dose doxycycline is not FDA-approved for the treatment of acne. Antibiotics applied to the skin are typically used for mild to moderately severe acne. Oral antibiotics are generally more effective than topical antibiotics and produce faster resolution of inflammatory acne lesions than topical applications. The Global Alliance to Improve Outcomes in Acne recommends that topical and oral antibiotics are not used together.Oral antibiotics are recommended for no longer than three months as antibiotic courses exceeding this duration are associated with the development of antibiotic resistance and show no clear benefit over shorter durations. If long-term oral antibiotics beyond three months are used, then it is recommended that benzoyl peroxide or a retinoid be used at the same time to limit the risk of C. acnes developing antibiotic resistance.The antibiotic dapsone is effective against inflammatory acne when applied to the skin. It is generally not a first-line choice due to its higher cost and a lack of clear superiority over other antibiotics. Topical dapsone is sometimes a preferred therapy in women or for people with sensitive or darker-toned skin. It is not recommended for use with benzoyl peroxide due to the risk of causing yellow-orange skin discoloration with this combination. Minocycline is an effective acne treatment, but it is not a first-line antibiotic due to a lack of evidence that it is better than other treatments, and concerns about its safety compared to other tetracyclines.Sarecycline is the most recent oral antibiotic developed specifically for the treatment of acne, and is FDA-approved for the treatment of moderate to severe inflammatory acne in patients nine years of age and older. It is a narrow-spectrum tetracycline antibiotic that exhibits the necessary antibacterial activity against pathogens related to acne vulgaris and a low propensity for inducing antibiotic resistance. In clinical trials, sarecycline demonstrated clinical efficacy in reducing inflammatory acne lesions as early as three weeks and reduced truncal (back and chest) acne. Hormonal agents In women, the use of combined birth control pills can improve acne. These medications contain an estrogen and a progestin. They work by decreasing the production of androgen hormones by the ovaries and by decreasing the free and hence biologically active fractions of androgens, resulting in lowered skin production of sebum and consequently reduce acne severity. First-generation progestins such as norethindrone and norgestrel have androgenic properties and may worsen acne. Although oral estrogens decrease IGF-1 levels in some situations, which could theoretically improve acne symptoms, combined birth control pills do not appear to affect IGF-1 levels in fertile women. Cyproterone acetate-containing birth control pills seem to decrease total and free IGF-1 levels. Combinations containing third- or fourth-generation progestins, including desogestrel, dienogest, drospirenone, or norgestimate, as well as birth control pills containing cyproterone acetate or chlormadinone acetate, are preferred for women with acne due to their stronger antiandrogenic effects. Studies have shown a 40 to 70% reduction in acne lesions with combined birth control pills. A 2014 review found that oral antibiotics appear to be somewhat more effective than birth control pills at reducing the number of inflammatory acne lesions at three months. However, the two therapies are approximately equal in efficacy at six months for decreasing the number of inflammatory, non-inflammatory, and total acne lesions. The authors of the analysis suggested that birth control pills may be a preferred first-line acne treatment, over oral antibiotics, in certain women due to similar efficacy at six months and a lack of associated antibiotic resistance. In contrast to combined birth control pills, progestogen-only birth control forms that contain androgenic progestins have been associated with worsened acne.Antiandrogens such as cyproterone acetate and spironolactone can successfully treat acne, especially in women with signs of excessive androgen production, such as increased hairiness or skin production of sebum, or scalp hair loss. Spironolactone is an effective treatment for acne in adult women. Unlike combined birth control pills, it is not approved by the United States Food and Drug Administration for this purpose. Spironolactone is an aldosterone antagonist and is a useful acne treatment due to its ability to additionally block the androgen receptor at higher doses. Alone or in combination with a birth control pill, spironolactone has shown a 33 to 85% reduction in acne lesions in women. The effectiveness of spironolactone for acne appears to be dose-dependent. High-dose cyproterone acetate alone reportedly decreases acne symptoms in women by 75 to 90% within three months. It is usually combined with an estrogen to avoid menstrual irregularities and estrogen deficiency. The medication appears to be effective in the treatment of acne in males, with one study finding that a high dosage reduced inflammatory acne lesions by 73%. However, spironolactone and cyproterone acetate's side effects in males, such as gynecomastia, sexual dysfunction, and decreased bone mineral density, generally make their use for male acne impractical.Pregnant and lactating women should not receive antiandrogens for their acne due to a possibility of birth disorders such as hypospadias and feminization of male babies. Women who are sexually active and who can or may become pregnant should use an effective method of contraception to prevent pregnancy while taking an antiandrogen. Antiandrogens are often combined with birth control pills for this reason, which can result in additive efficacy. The FDA added a black-box warning to spironolactone about possible tumor risks based on preclinical research with very high doses (>100-fold clinical doses) and cautioned that unnecessary use of the medication should be avoided. However, several large epidemiological studies subsequently found no greater risk of tumors in association with spironolactone in humans. Conversely, strong associations of cyproterone acetate with certain brain tumors have been discovered and its use has been restricted. The brain tumor risk with cyproterone acetate is due to its strong progestogenic actions and is not related to antiandrogenic activity nor shared by other antiandrogens.Flutamide, a pure antagonist of the androgen receptor, is effective in treating acne in women. It appears to reduce acne symptoms by 80 to 90% even at low doses, with several studies showing complete acne clearance. In one study, flutamide decreased acne scores by 80% within three months, whereas spironolactone decreased symptoms by only 40% in the same period. In a large long-term study, 97% of women reported satisfaction with the control of their acne with flutamide. Although effective, flutamide has a risk of serious liver toxicity, and cases of death in women taking even low doses of the medication to treat androgen-dependent skin and hair conditions have occurred. As such, the use of flutamide for acne has become increasingly limited, and it has been argued that continued use of flutamide for such purposes is unethical. Bicalutamide, a pure androgen receptor antagonist with the same mechanism as flutamide and with comparable or superior antiandrogenic efficacy but with a far lower risk of liver toxicity, is an alternative option to flutamide in the treatment of androgen-dependent skin and hair conditions in women.Clascoterone is a topical antiandrogen that has demonstrated effectiveness in the treatment of acne in both males and females and was approved for clinical use for this indication in August 2020. It has shown no systemic absorption or associated antiandrogenic side effects. In a small direct head-to-head comparison, clascoterone showed greater effectiveness than topical isotretinoin. 5α-Reductase inhibitors such as finasteride and dutasteride may be useful for the treatment of acne in both males and females but have not been adequately evaluated for this purpose. Moreover, 5α-reductase inhibitors have a strong potential for producing birth defects in male babies and this limits their use in women. However, 5α-reductase inhibitors are frequently used to treat excessive facial/body hair in women and can be combined with birth control pills to prevent pregnancy. There is no evidence as of 2010 to support the use of cimetidine or ketoconazole in the treatment of acne.Hormonal treatments for acne such as combined birth control pills and antiandrogens may be considered first-line therapy for acne under many circumstances, including desired contraception, known or suspected hyperandrogenism, acne during adulthood, acne that flares premenstrually, and when symptoms of significant sebum production (seborrhea) are co-present. Hormone therapy is effective for acne both in women with hyperandrogenism and in women with normal androgen levels. Azelaic acid Azelaic acid is effective for mild to moderate acne when applied topically at a 15–20% concentration. Treatment twice daily for six months is necessary, and is as effective as topical benzoyl peroxide 5%, isotretinoin 0.05%, and erythromycin 2%. Azelaic acid is an effective acne treatment due to its ability to reduce skin cell accumulation in the follicle and its antibacterial and anti-inflammatory properties. It has a slight skin-lightening effect due to its ability to inhibit melanin synthesis. Therefore, it is useful in treating individuals with acne who are also affected by post-inflammatory hyperpigmentation. Azelaic acid may cause skin irritation. It is less effective and more expensive than retinoids. Azelaic acid also led to worse treatment response when compared to benzoyl peroxide. When compared to tretinoin, azelaic acid makes little or no treatment response. Salicylic acid Salicylic acid is a topically applied beta-hydroxy acid that stops bacteria from reproducing and has keratolytic properties. It is less effective than retinoid therapy. Salicylic acid opens obstructed skin pores and promotes the shedding of epithelial skin cells. Dry skin is the most commonly seen side effect with topical application, though darkening of the skin can occur in individuals with darker skin types. Other medications Topical and oral preparations of nicotinamide (the amide form of vitamin B3) are alternative medical treatments. Nicotinamide reportedly improves acne due to its anti-inflammatory properties, its ability to suppress sebum production, and its wound healing properties. Topical and oral preparations of zinc are suggested treatments for acne; evidence to support their use for this purpose is limited. Zinc's capacities to reduce inflammation and sebum production as well as inhibit C. acnes growth are its proposed mechanisms for improving acne. Antihistamines may improve symptoms among those already taking isotretinoin due to their anti-inflammatory properties and their ability to suppress sebum production.Hydroquinone lightens the skin when applied topically by inhibiting tyrosinase, the enzyme responsible for converting the amino acid tyrosine to the skin pigment melanin, and is used to treat acne-associated post-inflammatory hyperpigmentation. By interfering with the production of melanin in the epidermis, hydroquinone leads to less hyperpigmentation as darkened skin cells are naturally shed over time. Improvement in skin hyperpigmentation is typically seen within six months when used twice daily. Hydroquinone is ineffective for hyperpigmentation affecting deeper layers of skin such as the dermis. The use of a sunscreen with SPF 15 or higher in the morning with reapplication every two hours is recommended when using hydroquinone. Its application only to affected areas lowers the risk of lightening the color of normal skin but can lead to a temporary ring of lightened skin around the hyperpigmented area. Hydroquinone is generally well-tolerated; side effects are typically mild (e.g., skin irritation) and occur with the use of a higher than the recommended 4% concentration. Most preparations contain the preservative sodium metabisulfite, which has been linked to rare cases of allergic reactions, including anaphylaxis and severe asthma exacerbations in susceptible people. In extremely rare cases, the frequent and improper application of high-dose hydroquinone has been associated with a systemic condition known as exogenous ochronosis (skin discoloration and connective tissue damage from the accumulation of homogentisic acid). Combination therapy Combination therapy—using medications of different classes together, each with a different mechanism of action—has been demonstrated to be a more effective approach to acne treatment than monotherapy. The use of topical benzoyl peroxide and antibiotics together is more effective than antibiotics alone. Similarly, using a topical retinoid with an antibiotic clears acne lesions faster than the use of antibiotics alone. Frequently used combinations include the following: antibiotic and benzoyl peroxide, antibiotic and topical retinoid, or topical retinoid and benzoyl peroxide. Dermatologists generally prefer combining benzoyl peroxide with a retinoid over the combination of a topical antibiotic with a retinoid. Both regimens are effective, but benzoyl peroxide does not lead to antibiotic resistance. Pregnancy Although sebaceous gland activity in the skin increases during the late stages of pregnancy, pregnancy has not been reliably associated with worsened acne severity. In general, topically applied medications are considered the first-line approach to acne treatment during pregnancy, as they have little systemic absorption and are therefore unlikely to harm a developing fetus. Highly recommended therapies include topically applied benzoyl peroxide (pregnancy category C) and azelaic acid (category B). Salicylic acid carries a category C safety rating due to higher systemic absorption (9–25%), and an association between the use of anti-inflammatory medications in the third trimester and adverse effects to the developing fetus including too little amniotic fluid in the uterus and early closure of the babies' ductus arteriosus blood vessel. Prolonged use of salicylic acid over significant areas of the skin or under occlusive (sealed) dressings is not recommended as these methods increase systemic absorption and the potential for fetal harm. Tretinoin (category C) and adapalene (category C) are very poorly absorbed, but certain studies have suggested teratogenic effects in the first trimester. The data examining the association between maternal topical retinoid exposure in the first trimester of pregnancy and adverse pregnancy outcomes is limited. A systematic review of observational studies concluded that such exposure does not appear to increase the risk of major birth defects, miscarriages, stillbirths, premature births, or low birth weight. Similarly, in studies examining the effects of topical retinoids during pregnancy, fetal harm has not been seen in the second and third trimesters. Nevertheless, since rare harms from topical retinoids are not ruled out, they are not recommended for use during pregnancy due to persistent safety concerns. Retinoids contraindicated for use during pregnancy include the topical retinoid tazarotene, and oral retinoids isotretinoin and acitretin (all category X). Spironolactone is relatively contraindicated for use during pregnancy due to its antiandrogen effects. Finasteride is not recommended as it is highly teratogenic.Topical antibiotics deemed safe during pregnancy include clindamycin, erythromycin, and metronidazole (all category B), due to negligible systemic absorption. Nadifloxacin and dapsone (category C) are other topical antibiotics that may be used to treat acne in pregnant women but have received less study. No adverse fetal events have been reported from the topical use of dapsone. If retinoids are used there is a high risk of abnormalities occurring in the developing fetus; women of childbearing age are therefore required to use effective birth control if retinoids are used to treat acne. Oral antibiotics deemed safe for pregnancy (all category B) include azithromycin, cephalosporins, and penicillins. Tetracyclines (category D) are contraindicated during pregnancy as they are known to deposit in developing fetal teeth, resulting in yellow discoloration and thinned tooth enamel. Their use during pregnancy has been associated with the development of acute fatty liver of pregnancy and is further avoided for this reason. Procedures Limited evidence supports comedo extraction, but it is an option for comedones that do not improve with standard treatment. Another procedure for immediate relief is the injection of a corticosteroid into an inflamed acne comedo. Electrocautery and electrofulguration are effective alternative treatments for comedones.Light therapy is a treatment method that involves delivering certain specific wavelengths of light to an area of skin affected by acne. Both regular and laser light have been used. The evidence for light therapy as a treatment for acne is weak and inconclusive. Various light therapies appear to provide a short-term benefit, but data for long-term outcomes, and outcomes in those with severe acne, are sparse; it may have a role for individuals whose acne has been resistant to topical medications. A 2016 meta-analysis was unable to conclude whether light therapies were more beneficial than placebo or no treatment, nor the duration of benefit.When regular light is used immediately following the application of a sensitizing substance to the skin such as aminolevulinic acid or methyl aminolevulinate, the treatment is referred to as photodynamic therapy (PDT). PDT has the most supporting evidence of all light therapy modalities. PDT treats acne by using various forms of light (e.g., blue light or red light) that preferentially target the pilosebaceous unit. Once the light activates the sensitizing substance, this generates free radicals and reactive oxygen species in the skin, which purposefully damage the sebaceous glands and kill C. acnes bacteria. Many different types of nonablative lasers (i.e., lasers that do not vaporize the top layer of the skin but rather induce a physiologic response in the skin from the light) have been used to treat acne, including those that use infrared wavelengths of light. Ablative lasers (such as CO2 and fractional types) have also been used to treat active acne and its scars. When ablative lasers are used, the treatment is often referred to as laser resurfacing because, as mentioned previously, the entire upper layers of the skin are vaporized. Ablative lasers are associated with higher rates of adverse effects compared with non-ablative lasers, with examples being post-inflammatory hyperpigmentation, persistent facial redness, and persistent pain. Physiologically, certain wavelengths of light, used with or without accompanying topical chemicals, are thought to kill bacteria and decrease the size and activity of the glands that produce sebum. Disadvantages of light therapy can include its cost, the need for multiple visits, the time required to complete the procedure(s), and pain associated with some of the treatment modalities. Typical side effects include skin peeling, temporary reddening of the skin, swelling, and post-inflammatory hyperpigmentation.Dermabrasion is an effective therapeutic procedure for reducing the appearance of superficial atrophic scars of the boxcar and rolling varieties. Ice-pick scars do not respond well to treatment with dermabrasion due to their depth. The procedure is painful and has many potential side effects such as skin sensitivity to sunlight, redness, and decreased pigmentation of the skin. Dermabrasion has fallen out of favor with the introduction of laser resurfacing. Unlike dermabrasion, there is no evidence that microdermabrasion is an effective treatment for acne.Dermal or subcutaneous fillers are substances injected into the skin to improve the appearance of acne scars. Fillers are used to increase natural collagen production in the skin and to increase skin volume and decrease the depth of acne scars. Examples of fillers used for this purpose include hyaluronic acid; poly(methyl methacrylate) microspheres with collagen; human and bovine collagen derivatives, and fat harvested from the person's own body (autologous fat transfer).Microneedling is a procedure in which an instrument with multiple rows of tiny needles is rolled over the skin to elicit a wound healing response and stimulate collagen production to reduce the appearance of atrophic acne scars in people with darker skin color. Notable adverse effects of microneedling include post-inflammatory hyperpigmentation and tram track scarring (described as discrete slightly raised scars in a linear distribution similar to a tram track). The latter is thought to be primarily attributable to improper technique by the practitioner, including the use of excessive pressure or inappropriately large needles.Subcision is useful for the treatment of superficial atrophic acne scars and involves the use of a small needle to loosen the fibrotic adhesions that result in the depressed appearance of the scar.Chemical peels can be used to reduce the appearance of acne scars. Mild peels include those using glycolic acid, lactic acid, salicylic acid, Jessner's solution, or a lower concentration (20%) of trichloroacetic acid. These peels only affect the epidermal layer of the skin and can be useful in the treatment of superficial acne scars as well as skin pigmentation changes from inflammatory acne. Higher concentrations of trichloroacetic acid (30–40%) are considered to be medium-strength peels and affect the skin as deep as the papillary dermis. Formulations of trichloroacetic acid concentrated to 50% or more are considered to be deep chemical peels. Medium-strength and deep-strength chemical peels are more effective for deeper atrophic scars but are more likely to cause side effects such as skin pigmentation changes, infection, and small white superficial cysts known as milia. Alternative medicine Researchers are investigating complementary therapies as treatment for people with acne. Low-quality evidence suggests topical application of tea tree oil or bee venom may reduce the total number of skin lesions in those with acne. Tea tree oil appears to be approximately as effective as benzoyl peroxide or salicylic acid but is associated with allergic contact dermatitis. Proposed mechanisms for tea tree oil's anti-acne effects include antibacterial action against C. acnes and anti-inflammatory properties. Numerous other plant-derived therapies have demonstrated positive effects against acne (e.g., basil oil; oligosaccharides from seaweed; however, few well-done studies have examined their use for this purpose. There is a lack of high-quality evidence for the use of acupuncture, herbal medicine, or cupping therapy for acne. Self-care Many over-the-counter treatments in many forms are available, which are often known as cosmeceuticals. Certain types of makeup may be useful to mask acne. In those with oily skin, a water-based product is often preferred. Prognosis Acne usually improves around the age of 20 but may persist into adulthood. Permanent physical scarring may occur. Rare complications from acne or its treatment include the formation of pyogenic granulomas, osteoma cutis, and acne with facial edema. Early and aggressive treatment of acne is advocated by some in the medical community to reduce the chances of these poor outcomes. Mental health impact There is good evidence to support the idea that acne and associated scarring negatively affect a person's psychological state, worsen mood, lower self-esteem, and are associated with a higher risk of anxiety disorders, depression, and suicidal thoughts.Misperceptions about acne's causative and aggravating factors are common, and people with acne often blame themselves, and others often blame those with acne for their condition. Such blame can worsen the affected person's sense of self-esteem. Until the 20th century, even among dermatologists, the list of causes was believed to include excessive sexual thoughts and masturbation. Dermatology's association with sexually transmitted infections, especially syphilis, contributed to the stigma.Another psychological complication of acne vulgaris is acne excoriée, which occurs when a person persistently picks and scratches pimples, irrespective of the severity of their acne. This can lead to significant scarring, changes in the affected person's skin pigmentation, and a cyclic worsening of the affected person's anxiety about their appearance. Epidemiology Globally, acne affects approximately 650 million people, or about 9.4% of the population, as of 2010. It affects nearly 90% of people in Western societies during their teenage years, but can occur before adolescence and may persist into adulthood. While acne that first develops between the ages of 21 and 25 is uncommon, it affects 54% of women and 40% of men older than 25 years of age and has a lifetime prevalence of 85%. About 20% of those affected have moderate or severe cases. It is slightly more common in females than males (9.8% versus 9.0%). In those over 40 years old, 1% of males and 5% of females still have problems.Rates appear to be lower in rural societies. While some research has found it affects people of all ethnic groups, acne may not occur in the non-Westernized peoples of Papua New Guinea and Paraguay.Acne affects 40–50 million people in the United States (16%) and approximately 3–5 million in Australia (23%). Severe acne tends to be more common in people of Caucasian or Amerindian descent than in people of African descent. History Historical records indicate Pharaohs had acne, which may be the earliest known reference to the disease. Sulfur's usefulness as a topical remedy for acne dates back to at least the reign of Cleopatra (69–30 BCE). The sixth-century Greek physician Aëtius of Amida reportedly coined the term "ionthos" (ίονθωξ,) or "acnae", which seems to be a reference to facial skin lesions that occur during "the 'acme' of life" (puberty).In the 16th century, the French physician and botanist François Boissier de Sauvages de Lacroix provided one of the earlier descriptions of acne. He used the term "psydracia achne" to describe small, red, and hard tubercles that altered a person's facial appearance during adolescence and were neither itchy nor painful.The recognition and characterization of acne progressed in 1776 when Josef Plenck (an Austrian physician) published a book that proposed the novel concept of classifying skin diseases by their elementary (initial) lesions. In 1808 the English dermatologist Robert Willan refined Plenck's work by providing the first detailed descriptions of several skin disorders using morphologic terminology that remains in use today. Thomas Bateman continued and expanded on Robert Willan's work as his student and provided the first descriptions and illustrations of acne accepted as accurate by modern dermatologists. Erasmus Wilson, in 1842, was the first to make the distinction between acne vulgaris and rosacea. The first professional medical monograph dedicated entirely to acne was written by Lucius Duncan Bulkley and published in New York in 1885.Scientists initially hypothesized that acne represented a disease of the skin's hair follicle, and occurred due to blockage of the pore by sebum. During the 1880s, they observed bacteria by microscopy in skin samples from people with acne. Investigators believed the bacteria caused comedones, sebum production, and ultimately acne. During the mid-twentieth century, dermatologists realized that no single hypothesized factor (sebum, bacteria, or excess keratin) fully accounted for the disease in its entirety. This led to the current understanding that acne could be explained by a sequence of related events, beginning with blockage of the skin follicle by excessive dead skin cells, followed by bacterial invasion of the hair follicle pore, changes in sebum production, and inflammation.The approach to acne treatment underwent significant changes during the twentieth century. Retinoids became a medical treatment for acne in 1943. Benzoyl peroxide was first proposed as a treatment in 1958 and remains a staple of acne treatment. The introduction of oral tetracycline antibiotics (such as minocycline) modified acne treatment in the 1950s. These reinforced the idea amongst dermatologists that bacterial growth on the skin plays an important role in causing acne. Subsequently, in the 1970s, tretinoin (original trade name Retin A) was found to be an effective treatment. The development of oral isotretinoin (sold as Accutane and Roaccutane) followed in 1980. After its introduction in the United States, scientists identified isotretinoin as a medication highly likely to cause birth defects if taken during pregnancy. In the United States, more than 2,000 women became pregnant while taking isotretinoin between 1982 and 2003, with most pregnancies ending in abortion or miscarriage. Approximately 160 babies were born with birth defects due to maternal use of isotretinoin during pregnancy.Treatment of acne with topical crushed dry ice, known as cryoslush, was first described in 1907 but is no longer performed commonly. Before 1960, the use of X-rays was also a common treatment. Society and culture The costs and social impact of acne are substantial. In the United States, acne vulgaris is responsible for more than 5 million doctor visits and costs over US$2.5 billion each year in direct costs. Similarly, acne vulgaris is responsible for 3.5 million doctor visits each year in the United Kingdom. Sales for the top ten leading acne treatment brands in the US in 2015 amounted to $352 million.Acne vulgaris and its resultant scars are associated with significant social and academic difficulties that can last into adulthood. During the Great Depression, dermatologists discovered that young men with acne had difficulty obtaining jobs. Until the 1930s, many people viewed acne as a trivial problem among middle-class girls because, unlike smallpox and tuberculosis, no one died from it, and a feminine problem, because boys were much less likely to seek medical assistance for it. During World War II, some soldiers in tropical climates developed such severe and widespread tropical acne on their bodies that they were declared medically unfit for duty. Research Efforts to better understand the mechanisms of sebum production are underway. This research aims to develop medications that target and interfere with the hormones that are known to increase sebum production (e.g., IGF-1 and alpha-melanocyte-stimulating hormone). Other sebum-lowering medications such as topical antiandrogens, peroxisome proliferator-activated receptor modulators, and inhibitors of the stearoyl-CoA desaturase-1 enzyme are also a focus of research efforts. Particles that release nitric oxide into the skin to decrease skin inflammation caused by C. acnes and the immune system have shown promise for improving acne in early clinical trials. Another avenue of early-stage research has focused on how to best use laser and light therapy to selectively destroy sebum-producing glands in the skin's hair follicles to reduce sebum production and improve acne appearance.The use of antimicrobial peptides against C. acnes is under investigation as a treatment for acne to overcoming antibiotic resistance. In 2007, scientists reported the first genome sequencing of a C. acnes bacteriophage (PA6). The authors proposed applying this research toward the development of bacteriophage therapy as an acne treatment to overcome the problems associated with long-term antibiotic use, such as bacterial resistance. Oral and topical probiotics are under evaluation as treatments for acne. Probiotics may have therapeutic effects for those affected by acne due to their ability to decrease skin inflammation and improve skin moisture by increasing the skin's ceramide content. As of 2014, knowledge of the effects of probiotics on acne in humans was limited.Decreased levels of retinoic acid in the skin may contribute to comedo formation. Researchers are investigating methods to increase the skin's production of retinoic acid to address this deficiency. A vaccine against inflammatory acne has shown promising results in mice and humans. Some have voiced concerns about creating a vaccine designed to neutralize a stable community of normal skin bacteria that is known to protect the skin from colonization by more harmful microorganisms. Other animals Acne can occur on cats, dogs, and horses. References Further reading External links Acne Support. Expert, impartial advice on acne by the British Association of Dermatologists (BAD).
\ No newline at end of file
diff --git a/HybridRAG/tests/data/Diabetes.txt b/HybridRAG/tests/data/Diabetes.txt
new file mode 100644
index 0000000000..a4dac012bd
--- /dev/null
+++ b/HybridRAG/tests/data/Diabetes.txt
@@ -0,0 +1 @@
+Diabetes mellitus, often known simply as diabetes, is a group of common endocrine diseases characterized by sustained high blood sugar levels. Diabetes is due to either the pancreas not producing enough insulin, or the cells of the body becoming unresponsive to the hormone's effects. Classic symptoms include thirst, polyuria, weight loss, and blurred vision. If left untreated, the disease can lead to various health complications, including disorders of the cardiovascular system, eye, kidney, and nerves. Diabetes accounts for approximately 4.2 million deaths every year, with an estimated 1.5 million caused by either untreated or poorly treated diabetes.The major types of diabetes are type 1 and type 2. The most common treatment for type 1 is insulin replacement therapy (insulin injections), while anti-diabetic medications (such as metformin and semaglutide) and lifestyle modifications can be used to manage type 2. Gestational diabetes, a form that arises during pregnancy in some women, normally resolves shortly after delivery.As of 2021, an estimated 537 million people had diabetes worldwide accounting for 10.5% of the adult population, with type 2 making up about 90% of all cases. The World Health Organization has reported that diabetes was "among the top 10 causes of death in 2021, following a significant percentage increase of 95% since 2000." It is estimated that by 2045, approximately 783 million adults, or 1 in 8, will be living with diabetes, representing a 46% increase from the current figures. The prevalence of the disease continues to increase, most dramatically in low- and middle-income nations. Rates are similar in women and men, with diabetes being the seventh leading cause of death globally. The global expenditure on diabetes-related healthcare is an estimated US$760 billion a year. Signs and symptoms The classic symptoms of untreated diabetes are polyuria, thirst, and weight loss. Several other non-specific signs and symptoms may also occur, including fatigue, blurred vision, sweet smelling urine/semen and genital itchiness due to Candida infection. About half of affected individuals may also be asymptomatic. Type 1 presents abruptly following a pre-clinical phase, while type 2 has a more insidious onset; patients may remain asymptomatic for many years.Diabetic ketoacidosis is a medical emergency that occurs most commonly in type 1, but may also occur in type 2 if it has been longstanding or if the individual has significant β-cell dysfunction. Excessive production of ketone bodies leads to signs and symptoms including nausea, vomiting, abdominal pain, the smell of acetone in the breath, deep breathing known as Kussmaul breathing, and in severe cases decreased level of consciousness. Hyperosmolar hyperglycemic state is another emergency characterized by dehydration secondary to severe hyperglycemia, with resultant hypernatremia leading to an altered mental state and possibly coma.Hypoglycemia is a recognized complication of insulin treatment used in diabetes. An acute presentation can include mild symptoms such as sweating, trembling, and palpitations, to more serious effects including impaired cognition, confusion, seizures, coma, and rarely death. Recurrent hypoglycemic episodes may lower the glycemic threshold at which symptoms occur, meaning mild symptoms may not appear before cognitive deterioration begins to occur. Long-term complications The major long-term complications of diabetes relate to damage to blood vessels at both macrovascular and microvascular levels. Diabetes doubles the risk of cardiovascular disease, and about 75% of deaths in people with diabetes are due to coronary artery disease. Other macrovascular morbidities include stroke and peripheral artery disease.Microvascular disease affects the eyes, kidneys, and nerves. Damage to the retina, known as diabetic retinopathy, is the most common cause of blindness in people of working age. The eyes can also be affected in other ways, including development of cataract and glaucoma. It is recommended that people with diabetes visit an optometrist or ophthalmologist once a year.Diabetic nephropathy is a major cause of chronic kidney disease, accounting for over 50% of patients on dialysis in the United States. Diabetic neuropathy, damage to nerves, manifests in various ways, including sensory loss, neuropathic pain, and autonomic dysfunction (such as postural hypotension, diarrhoea, and erectile dysfunction). Loss of pain sensation predisposes to trauma that can lead to diabetic foot problems (such as ulceration), the most common cause of non-traumatic lower-limb amputation.Hearing loss is another long-term complication associated with diabetes.Based on extensive data and numerous cases of gallstone disease, it appears that a causal link might exist between type 2 diabetes and gallstones. People with diabetes are at a higher risk of developing gallstones compared to those without diabetes.There is a link between cognitive deficit and diabetes; studies have shown that diabetic individuals are at a greater risk of cognitive decline, and have a greater rate of decline compared to those without the disease. The condition also predisposes to falls in the elderly, especially those treated with insulin. Causes Diabetes is classified by the World Health Organization into six categories: type 1 diabetes, type 2 diabetes, hybrid forms of diabetes (including slowly evolving, immune-mediated diabetes of adults and ketosis-prone type 2 diabetes), hyperglycemia first detected during pregnancy, "other specific types", and "unclassified diabetes". Diabetes is a more variable disease than once thought, and individuals may have a combination of forms. Type 1 Type 1 accounts for 5 to 10% of diabetes cases and is the most common type diagnosed in patients under 20 years; however, the older term "juvenile-onset diabetes" is no longer used as onset in adulthood is not unusual. The disease is characterized by loss of the insulin-producing beta cells of the pancreatic islets, leading to severe insulin deficiency, and can be further classified as immune-mediated or idiopathic (without known cause). The majority of cases are immune-mediated, in which a T cell-mediated autoimmune attack causes loss of beta cells and thus insulin deficiency. Patients often have irregular and unpredictable blood sugar levels due to very low insulin and an impaired counter-response to hypoglycemia. Type 1 diabetes is partly inherited, with multiple genes, including certain HLA genotypes, known to influence the risk of diabetes. In genetically susceptible people, the onset of diabetes can be triggered by one or more environmental factors, such as a viral infection or diet. Several viruses have been implicated, but to date there is no stringent evidence to support this hypothesis in humans.Type 1 diabetes can occur at any age, and a significant proportion is diagnosed during adulthood. Latent autoimmune diabetes of adults (LADA) is the diagnostic term applied when type 1 diabetes develops in adults; it has a slower onset than the same condition in children. Given this difference, some use the unofficial term "type 1.5 diabetes" for this condition. Adults with LADA are frequently initially misdiagnosed as having type 2 diabetes, based on age rather than a cause. LADA leaves adults with higher levels of insulin production than type 1 diabetes, but not enough insulin production for healthy blood sugar levels. Type 2 Type 2 diabetes is characterized by insulin resistance, which may be combined with relatively reduced insulin secretion. The defective responsiveness of body tissues to insulin is believed to involve the insulin receptor. However, the specific defects are not known. Diabetes mellitus cases due to a known defect are classified separately. Type 2 diabetes is the most common type of diabetes mellitus accounting for 95% of diabetes. Many people with type 2 diabetes have evidence of prediabetes (impaired fasting glucose and/or impaired glucose tolerance) before meeting the criteria for type 2 diabetes. The progression of prediabetes to overt type 2 diabetes can be slowed or reversed by lifestyle changes or medications that improve insulin sensitivity or reduce the liver's glucose production.Type 2 diabetes is primarily due to lifestyle factors and genetics. A number of lifestyle factors are known to be important to the development of type 2 diabetes, including obesity (defined by a body mass index of greater than 30), lack of physical activity, poor diet, stress, and urbanization. Excess body fat is associated with 30% of cases in people of Chinese and Japanese descent, 60–80% of cases in those of European and African descent, and 100% of Pima Indians and Pacific Islanders. Even those who are not obese may have a high waist–hip ratio.Dietary factors such as sugar-sweetened drinks are associated with an increased risk. The type of fats in the diet is also important, with saturated fat and trans fats increasing the risk and polyunsaturated and monounsaturated fat decreasing the risk. Eating white rice excessively may increase the risk of diabetes, especially in Chinese and Japanese people. Lack of physical activity may increase the risk of diabetes in some people.Adverse childhood experiences, including abuse, neglect, and household difficulties, increase the likelihood of type 2 diabetes later in life by 32%, with neglect having the strongest effect.Antipsychotic medication side effects (specifically metabolic abnormalities, dyslipidemia and weight gain) are also potential risk factors. Gestational diabetes Gestational diabetes resembles type 2 diabetes in several respects, involving a combination of relatively inadequate insulin secretion and responsiveness. It occurs in about 2–10% of all pregnancies and may improve or disappear after delivery. It is recommended that all pregnant women get tested starting around 24–28 weeks gestation. It is most often diagnosed in the second or third trimester because of the increase in insulin-antagonist hormone levels that occurs at this time. However, after pregnancy approximately 5–10% of women with gestational diabetes are found to have another form of diabetes, most commonly type 2. Gestational diabetes is fully treatable, but requires careful medical supervision throughout the pregnancy. Management may include dietary changes, blood glucose monitoring, and in some cases, insulin may be required.Though it may be transient, untreated gestational diabetes can damage the health of the fetus or mother. Risks to the baby include macrosomia (high birth weight), congenital heart and central nervous system abnormalities, and skeletal muscle malformations. Increased levels of insulin in a fetus's blood may inhibit fetal surfactant production and cause infant respiratory distress syndrome. A high blood bilirubin level may result from red blood cell destruction. In severe cases, perinatal death may occur, most commonly as a result of poor placental perfusion due to vascular impairment. Labor induction may be indicated with decreased placental function. A caesarean section may be performed if there is marked fetal distress or an increased risk of injury associated with macrosomia, such as shoulder dystocia. Other types Maturity onset diabetes of the young (MODY) is a rare autosomal dominant inherited form of diabetes, due to one of several single-gene mutations causing defects in insulin production. It is significantly less common than the three main types, constituting 1–2% of all cases. The name of this disease refers to early hypotheses as to its nature. Being due to a defective gene, this disease varies in age at presentation and in severity according to the specific gene defect; thus, there are at least 13 subtypes of MODY. People with MODY often can control it without using insulin.Some cases of diabetes are caused by the body's tissue receptors not responding to insulin (even when insulin levels are normal, which is what separates it from type 2 diabetes); this form is very uncommon. Genetic mutations (autosomal or mitochondrial) can lead to defects in beta cell function. Abnormal insulin action may also have been genetically determined in some cases. Any disease that causes extensive damage to the pancreas may lead to diabetes (for example, chronic pancreatitis and cystic fibrosis). Diseases associated with excessive secretion of insulin-antagonistic hormones can cause diabetes (which is typically resolved once the hormone excess is removed). Many drugs impair insulin secretion and some toxins damage pancreatic beta cells, whereas others increase insulin resistance (especially glucocorticoids which can provoke "steroid diabetes"). The ICD-10 (1992) diagnostic entity, malnutrition-related diabetes mellitus (ICD-10 code E12), was deprecated by the World Health Organization (WHO) when the current taxonomy was introduced in 1999. Yet another form of diabetes that people may develop is double diabetes. This is when a type 1 diabetic becomes insulin resistant, the hallmark for type 2 diabetes or has a family history for type 2 diabetes. It was first discovered in 1990 or 1991.The following is a list of disorders that may increase the risk of diabetes: Pathophysiology Insulin is the principal hormone that regulates the uptake of glucose from the blood into most cells of the body, especially liver, adipose tissue and muscle, except smooth muscle, in which insulin acts via the IGF-1. Therefore, deficiency of insulin or the insensitivity of its receptors play a central role in all forms of diabetes mellitus.The body obtains glucose from three main sources: the intestinal absorption of food; the breakdown of glycogen (glycogenolysis), the storage form of glucose found in the liver; and gluconeogenesis, the generation of glucose from non-carbohydrate substrates in the body. Insulin plays a critical role in regulating glucose levels in the body. Insulin can inhibit the breakdown of glycogen or the process of gluconeogenesis, it can stimulate the transport of glucose into fat and muscle cells, and it can stimulate the storage of glucose in the form of glycogen.Insulin is released into the blood by beta cells (β-cells), found in the islets of Langerhans in the pancreas, in response to rising levels of blood glucose, typically after eating. Insulin is used by about two-thirds of the body's cells to absorb glucose from the blood for use as fuel, for conversion to other needed molecules, or for storage. Lower glucose levels result in decreased insulin release from the beta cells and in the breakdown of glycogen to glucose. This process is mainly controlled by the hormone glucagon, which acts in the opposite manner to insulin.If the amount of insulin available is insufficient, or if cells respond poorly to the effects of insulin (insulin resistance), or if the insulin itself is defective, then glucose is not absorbed properly by the body cells that require it, and is not stored appropriately in the liver and muscles. The net effect is persistently high levels of blood glucose, poor protein synthesis, and other metabolic derangements, such as metabolic acidosis in cases of complete insulin deficiency.When there is too much glucose in the blood for a long time, the kidneys cannot absorb it all (reach a threshold of reabsorption) and the extra glucose gets passed out of the body through urine (glycosuria). This increases the osmotic pressure of the urine and inhibits reabsorption of water by the kidney, resulting in increased urine production (polyuria) and increased fluid loss. Lost blood volume is replaced osmotically from water in body cells and other body compartments, causing dehydration and increased thirst (polydipsia). In addition, intracellular glucose deficiency stimulates appetite leading to excessive food intake (polyphagia). Diagnosis Diabetes mellitus is diagnosed with a test for the glucose content in the blood, and is diagnosed by demonstrating any one of the following:Fasting plasma glucose level ≥ 7.0 mmol/L (126 mg/dL). For this test, blood is taken after a period of fasting, i.e. in the morning before breakfast, after the patient had sufficient time to fast overnight or at least 8 hours before the test.Plasma glucose ≥ 11.1 mmol/L (200 mg/dL) two hours after a 75 gram oral glucose load as in a glucose tolerance test (OGTT)Symptoms of high blood sugar and plasma glucose ≥ 11.1 mmol/L (200 mg/dL) either while fasting or not fastingGlycated hemoglobin (HbA1C) ≥ 48 mmol/mol (≥ 6.5 DCCT %).A positive result, in the absence of unequivocal high blood sugar, should be confirmed by a repeat of any of the above methods on a different day. It is preferable to measure a fasting glucose level because of the ease of measurement and the considerable time commitment of formal glucose tolerance testing, which takes two hours to complete and offers no prognostic advantage over the fasting test. According to the current definition, two fasting glucose measurements at or above 7.0 mmol/L (126 mg/dL) is considered diagnostic for diabetes mellitus.Per the WHO, people with fasting glucose levels from 6.1 to 6.9 mmol/L (110 to 125 mg/dL) are considered to have impaired fasting glucose. People with plasma glucose at or above 7.8 mmol/L (140 mg/dL), but not over 11.1 mmol/L (200 mg/dL), two hours after a 75 gram oral glucose load are considered to have impaired glucose tolerance. Of these two prediabetic states, the latter in particular is a major risk factor for progression to full-blown diabetes mellitus, as well as cardiovascular disease. The American Diabetes Association (ADA) since 2003 uses a slightly different range for impaired fasting glucose of 5.6 to 6.9 mmol/L (100 to 125 mg/dL).Glycated hemoglobin is better than fasting glucose for determining risks of cardiovascular disease and death from any cause. Prevention There is no known preventive measure for type 1 diabetes. However, islet autoimmunity and multiple antibodies can be a strong predictor of the onset of type 1 diabetes. Type 2 diabetes—which accounts for 85–90% of all cases worldwide—can often be prevented or delayed by maintaining a normal body weight, engaging in physical activity, and eating a healthy diet. Higher levels of physical activity (more than 90 minutes per day) reduce the risk of diabetes by 28%. Dietary changes known to be effective in helping to prevent diabetes include maintaining a diet rich in whole grains and fiber, and choosing good fats, such as the polyunsaturated fats found in nuts, vegetable oils, and fish. Limiting sugary beverages and eating less red meat and other sources of saturated fat can also help prevent diabetes. Tobacco smoking is also associated with an increased risk of diabetes and its complications, so smoking cessation can be an important preventive measure as well.The relationship between type 2 diabetes and the main modifiable risk factors (excess weight, unhealthy diet, physical inactivity and tobacco use) is similar in all regions of the world. There is growing evidence that the underlying determinants of diabetes are a reflection of the major forces driving social, economic and cultural change: globalization, urbanization, population aging, and the general health policy environment. Comorbidity Diabetes patients' comorbidities have a significant impact on medical expenses and related costs. It has been demonstrated that patients with diabetes are more likely to experience respiratory, urinary tract, and skin infections, develop atherosclerosis, hypertension, and chronic kidney disease, putting them at increased risk of infection and complications that require medical attention. Patients with diabetes mellitus are more likely to experience certain infections, such as COVID-19, with prevalence rates ranging from 5.3 to 35.5%. Maintaining adequate glycemic control is the primary goal of diabetes management since it is critical to managing diabetes and preventing or postponing such complications.People with type 1 diabetes have higher rates of autoimmune disorders than the general population. An analysis of a type 1 diabetes registry found that 27% of the 25,000 participants had other autoimmune disorders. Between 2% and 16% of people with type 1 diabetes also have celiac disease. Management Diabetes management concentrates on keeping blood sugar levels close to normal, without causing low blood sugar. This can usually be accomplished with dietary changes, exercise, weight loss, and use of appropriate medications (insulin, oral medications).Learning about the disease and actively participating in the treatment is important, since complications are far less common and less severe in people who have well-managed blood sugar levels. The goal of treatment is an A1C level below 7%. Attention is also paid to other health problems that may accelerate the negative effects of diabetes. These include smoking, high blood pressure, metabolic syndrome obesity, and lack of regular exercise. Specialized footwear is widely used to reduce the risk of diabetic foot ulcers by relieving the pressure on the foot. Foot examination for patients living with diabetes should be done annually which includes sensation testing, foot biomechanics, vascular integrity and foot structure.Concerning those with severe mental illness, the efficacy of type 2 diabetes self-management interventions is still poorly explored, with insufficient scientific evidence to show whether these interventions have similar results to those observed in the general population. Lifestyle People with diabetes can benefit from education about the disease and treatment, dietary changes, and exercise, with the goal of keeping both short-term and long-term blood glucose levels within acceptable bounds. In addition, given the associated higher risks of cardiovascular disease, lifestyle modifications are recommended to control blood pressure.Weight loss can prevent progression from prediabetes to diabetes type 2, decrease the risk of cardiovascular disease, or result in a partial remission in people with diabetes. No single dietary pattern is best for all people with diabetes. Healthy dietary patterns, such as the Mediterranean diet, low-carbohydrate diet, or DASH diet, are often recommended, although evidence does not support one over the others. According to the ADA, "reducing overall carbohydrate intake for individuals with diabetes has demonstrated the most evidence for improving glycemia", and for individuals with type 2 diabetes who cannot meet the glycemic targets or where reducing anti-glycemic medications is a priority, low or very-low carbohydrate diets are a viable approach. For overweight people with type 2 diabetes, any diet that achieves weight loss is effective.A 2020 Cochrane systematic review compared several non-nutritive sweeteners to sugar, placebo and a nutritive low-calorie sweetener (tagatose), but the results were unclear for effects on HbA1c, body weight and adverse events. The studies included were mainly of very low-certainty and did not report on health-related quality of life, diabetes complications, all-cause mortality or socioeconomic effects.Exercise has demonstrated to impact people’s lives for a better health outcome. However, fear of hypoglycemia can negatively impact exercise view on youth that have been diagnosed with diabetes. Managing insulin, carbohydrate intake, and physical activity becomes a task that drive youth away benefitting from enjoying exercises. With different studies, an understanding of what can be done and applied to the youth population diagnosed with Type 1 Diabetes has been conducted. A study’s aim was to focus on the impact of an exercise education on physical activity. During the length of a 12-month program, youth and their parents participated in 4 education sessions learning about the benefits, safe procedures, glucose control, and physical activity. With a survey conducted in the beginning, youth and parents demonstrated their fear of hypoglycemia. At the end of the program, most of the youth and parents showed confidence on how to manage and handle situations regarding hypoglycemia. In some instances, youth provided feedback that a continuation of the sessions would be beneficial. In two other studies, exercise was the aim to investigate on how it affects adolescents with T1D. In one of those studies, the impact was assessed in the changes of glucose in exercise by how many minutes per day, intensity, duration, and heart rate. Also, glucose was monitored to see changes during exercise, post exercise, and overnight. The other study investigated how types of exercises can affect glucose levels. The exercise types were continuous moderate exercise and interval-high-intensity exercise. Both types consisted of 2 sets of 10-minute work at different pedaling paces. The continuous pedaled at a 50% and had a 5-minute passive recovery. The high-intensity pedaled at 150% for 15 seconds and was intermixed with a 30-second passive recovery. So, when studies finished collecting data and were able to analyze it, the following were the results. For the studies comparing the different intensities, it was seen that insulin and carbohydrate intake did not have a significant difference before or after exercise. In regards of glucose content, there was a greater drop of blood glucose post exercise in the high intensity (-1.47mmol/L). During recovery, the continuous exercise showed a greater decrease in blood glucose. With all these, continuous exercise resulted in being more favorable for managing blood glucose levels. In the other study, it is mentioned that exercise also contributed to a notable impact on glucose levels. Post-exercise measurements, there was a low mean glucose level that occurred 12 to 16 hours after exercising. Although, with participants exercising for longer sessions (≥90 minutes), hypoglycemia rates were higher. With all these, participants showed well-managed glucose control by intaking proper carbohydrates amount without any insulin adjustments. Lastly, the study, that educated youth and parents about exercise important and management of hypoglycemia, showed many youths feeling confident to continue to exercise regularly and being able to manage their glucose levels. Therefore, as important as exercising is, showing youth and parents that being physical active is possible. That can be done in specific intensities and with proper understanding on how to handle glucose control over time. Diabetes and youth Youth dealing with diabetes face unique challenges. These can include the emotional, psychological, and social implications as a result of managing a chronic condition at such a young age. Both forms of diabetes can have long-term risks for complications like cardiovascular disease, kidney damage, and nerve damage. This is why early intervention and impactful management important to improving long-term health. Physical activity plays a vital role in managing diabetes, improving glycemic control, and enhancing the overall quality of life for children and adolescents.Younger children and adolescents with T1D tend to be more physically active compared to older individuals. This possibly because of the more demanding schedules and sedentary lifestyles of older adolescents, who are often in high school or university. This age-related decrease in physical activity is a potential challenge to keeping up with the ideal healthy lifestyle. People who have had T1D for a longer amount of time also have a tendency to be less active. As diabetes progresses, people may face more barriers to engaging in physical activity. Examples of this could include anxiety about experiencing hypoglycemic events during exercise or the physical challenges posed by the long-term complications that diabetes cause. Increased physical activity in youth with T1D can be associated with improved health. These outcomes can include better lipid profiles (higher HDL-C and lower triglycerides), healthier body composition (reduced waist circumference and BMI), and improved overall physical health. These benefits are especially important during childhood and adolescence because this is when proper growth and development are occurring.Younger people with type 2 diabetes have a tendency to have lower levels of physical activity and CRF compared to their peers without diabetes. This contributes to their poorer overall health and increases the risk of cardiovascular and metabolic complications. Despite recommendations for physical activity as part of diabetes management, many youth and young adolesents with type 2 diabetes do not meet the guidelines, hindering their ability to effectively manage blood glucose levels and improve their health. CRF is a key health indicator. Higher levels of CRF is associated with better health outcomes. This means that increasing CRF through exercise can provide important benefits for managing type 2 diabetes. There is a need for targeted interventions that promote physical activity and improve CRF in youth with type 2 diabetes to help reduce the risk of long-term complications.When it comes to resistance training, it is found to have no significant effect on insulin sensitivity in children and adolescents, despite it having positive trends. Intervention length, training intensity, and the participants' physical maturation might explain the mixed results. Longer and higher-intensity programs showed more promising results. Future research could focus on more dire metabolic conditions like type II diabetes, investigate the role of physical maturation, and think about including longer intervention periods. While resistance training complements aerobic exercise, its standalone effects on insulin sensitivity remain unclear. Medications Glucose control Most medications used to treat diabetes act by lowering blood sugar levels through different mechanisms. There is broad consensus that when people with diabetes maintain tight glucose control – keeping the glucose levels in their blood within normal ranges – they experience fewer complications, such as kidney problems or eye problems. There is, however, debate as to whether this is appropriate and cost effective for people later in life in whom the risk of hypoglycemia may be more significant.There are a number of different classes of anti-diabetic medications. Type 1 diabetes requires treatment with insulin, ideally using a "basal bolus" regimen that most closely matches normal insulin release: long-acting insulin for the basal rate and short-acting insulin with meals. Type 2 diabetes is generally treated with medication that is taken by mouth (e.g. metformin) although some eventually require injectable treatment with insulin or GLP-1 agonists.Metformin is generally recommended as a first-line treatment for type 2 diabetes, as there is good evidence that it decreases mortality. It works by decreasing the liver's production of glucose, and increasing the amount of glucose stored in peripheral tissue. Several other groups of drugs, mainly oral medication, may also decrease blood sugar in type 2 diabetes. These include agents that increase insulin release (sulfonylureas), agents that decrease absorption of sugar from the intestines (acarbose), agents that inhibit the enzyme dipeptidyl peptidase-4 (DPP-4) that inactivates incretins such as GLP-1 and GIP (sitagliptin), agents that make the body more sensitive to insulin (thiazolidinedione) and agents that increase the excretion of glucose in the urine (SGLT2 inhibitors). When insulin is used in type 2 diabetes, a long-acting formulation is usually added initially, while continuing oral medications.Some severe cases of type 2 diabetes may also be treated with insulin, which is increased gradually until glucose targets are reached. Blood pressure lowering Cardiovascular disease is a serious complication associated with diabetes, and many international guidelines recommend blood pressure treatment targets that are lower than 140/90 mmHg for people with diabetes. However, there is only limited evidence regarding what the lower targets should be. A 2016 systematic review found potential harm to treating to targets lower than 140 mmHg, and a subsequent systematic review in 2019 found no evidence of additional benefit from blood pressure lowering to between 130 – 140mmHg, although there was an increased risk of adverse events.2015 American Diabetes Association recommendations are that people with diabetes and albuminuria should receive an inhibitor of the renin-angiotensin system to reduce the risks of progression to end-stage renal disease, cardiovascular events, and death. There is some evidence that angiotensin converting enzyme inhibitors (ACEIs) are superior to other inhibitors of the renin-angiotensin system such as angiotensin receptor blockers (ARBs), or aliskiren in preventing cardiovascular disease. Although a more recent review found similar effects of ACEIs and ARBs on major cardiovascular and renal outcomes. There is no evidence that combining ACEIs and ARBs provides additional benefits. Aspirin The use of aspirin to prevent cardiovascular disease in diabetes is controversial. Aspirin is recommended by some in people at high risk of cardiovascular disease; however, routine use of aspirin has not been found to improve outcomes in uncomplicated diabetes. 2015 American Diabetes Association recommendations for aspirin use (based on expert consensus or clinical experience) are that low-dose aspirin use is reasonable in adults with diabetes who are at intermediate risk of cardiovascular disease (10-year cardiovascular disease risk, 5–10%). National guidelines for England and Wales by the National Institute for Health and Care Excellence (NICE) recommend against the use of aspirin in people with type 1 or type 2 diabetes who do not have confirmed cardiovascular disease. Surgery Weight loss surgery in those with obesity and type 2 diabetes is often an effective measure. Many are able to maintain normal blood sugar levels with little or no medications following surgery and long-term mortality is decreased. There is, however, a short-term mortality risk of less than 1% from the surgery. The body mass index cutoffs for when surgery is appropriate are not yet clear. It is recommended that this option be considered in those who are unable to get both their weight and blood sugar under control.A pancreas transplant is occasionally considered for people with type 1 diabetes who have severe complications of their disease, including end stage kidney disease requiring kidney transplantation.Diabetic peripheral neuropathy (DPN) affects 30% of all diabetes patients. When DPN is superimposed with nerve compression, DPN may be treatable with multiple nerve decompressions. The theory is that DPN predisposes peripheral nerves to compression at anatomical sites of narrowing, and that the majority of DPN symptoms are actually attributable to nerve compression, a treatable condition, rather than DPN itself. The surgery is associated with lower pain scores, higher two-point discrimination (a measure of sensory improvement), lower rate of ulcerations, fewer falls (in the case of lower extremity decompression), and fewer amputations. Self-management and support In countries using a general practitioner system, such as the United Kingdom, care may take place mainly outside hospitals, with hospital-based specialist care used only in case of complications, difficult blood sugar control, or research projects. In other circumstances, general practitioners and specialists share care in a team approach. Evidence has shown that social prescribing led to slight improvements in blood sugar control for people with type 2 diabetes. Home telehealth support can be an effective management technique.The use of technology to deliver educational programs for adults with type 2 diabetes includes computer-based self-management interventions to collect for tailored responses to facilitate self-management. There is no adequate evidence to support effects on cholesterol, blood pressure, behavioral change (such as physical activity levels and dietary), depression, weight and health-related quality of life, nor in other biological, cognitive or emotional outcomes. Epidemiology In 2017, 425 million people had diabetes worldwide, up from an estimated 382 million people in 2013 and from 108 million in 1980. Accounting for the shifting age structure of the global population, the prevalence of diabetes is 8.8% among adults, nearly double the rate of 4.7% in 1980. Type 2 makes up about 90% of the cases. Some data indicate rates are roughly equal in women and men, but male excess in diabetes has been found in many populations with higher type 2 incidence, possibly due to sex-related differences in insulin sensitivity, consequences of obesity and regional body fat deposition, and other contributing factors such as high blood pressure, tobacco smoking, and alcohol intake.The WHO estimates that diabetes resulted in 1.5 million deaths in 2012, making it the 8th leading cause of death. However, another 2.2 million deaths worldwide were attributable to high blood glucose and the increased risks of cardiovascular disease and other associated complications (e.g. kidney failure), which often lead to premature death and are often listed as the underlying cause on death certificates rather than diabetes. For example, in 2017, the International Diabetes Federation (IDF) estimated that diabetes resulted in 4.0 million deaths worldwide, using modeling to estimate the total number of deaths that could be directly or indirectly attributed to diabetes.Diabetes occurs throughout the world but is more common (especially type 2) in more developed countries. The greatest increase in rates has, however, been seen in low- and middle-income countries, where more than 80% of diabetic deaths occur. The fastest prevalence increase is expected to occur in Asia and Africa, where most people with diabetes will probably live in 2030. The increase in rates in developing countries follows the trend of urbanization and lifestyle changes, including increasingly sedentary lifestyles, less physically demanding work and the global nutrition transition, marked by increased intake of foods that are high energy-dense but nutrient-poor (often high in sugar and saturated fats, sometimes referred to as the "Western-style" diet). The global number of diabetes cases might increase by 48% between 2017 and 2045.As of 2020, 38% of all US adults had prediabetes. Prediabetes is an early stage of diabetes. History Diabetes was one of the first diseases described, with an Egyptian manuscript from c. 1500 BCE mentioning "too great emptying of the urine." The Ebers papyrus includes a recommendation for a drink to take in such cases. The first described cases are believed to have been type 1 diabetes. Indian physicians around the same time identified the disease and classified it as madhumeha or "honey urine", noting the urine would attract ants.The term "diabetes" or "to pass through" was first used in 230 BCE by the Greek Apollonius of Memphis. The disease was considered rare during the time of the Roman empire, with Galen commenting he had only seen two cases during his career. This is possibly due to the diet and lifestyle of the ancients, or because the clinical symptoms were observed during the advanced stage of the disease. Galen named the disease "diarrhea of the urine" (diarrhea urinosa).The earliest surviving work with a detailed reference to diabetes is that of Aretaeus of Cappadocia (2nd or early 3rd century CE). He described the symptoms and the course of the disease, which he attributed to the moisture and coldness, reflecting the beliefs of the "Pneumatic School". He hypothesized a correlation between diabetes and other diseases, and he discussed differential diagnosis from the snakebite, which also provokes excessive thirst. His work remained unknown in the West until 1552, when the first Latin edition was published in Venice.Two types of diabetes were identified as separate conditions for the first time by the Indian physicians Sushruta and Charaka in 400–500 CE with one type being associated with youth and another type with being overweight. Effective treatment was not developed until the early part of the 20th century when Canadians Frederick Banting and Charles Best isolated and purified insulin in 1921 and 1922. This was followed by the development of the long-acting insulin NPH in the 1940s. Etymology The word diabetes ( or ) comes from Latin diabētēs, which in turn comes from Ancient Greek διαβήτης (diabētēs), which literally means "a passer through; a siphon". Ancient Greek physician Aretaeus of Cappadocia (fl. 1st century CE) used that word, with the intended meaning "excessive discharge of urine", as the name for the disease. Ultimately, the word comes from Greek διαβαίνειν (diabainein), meaning "to pass through", which is composed of δια- (dia-), meaning "through" and βαίνειν (bainein), meaning "to go". The word "diabetes" is first recorded in English, in the form diabete, in a medical text written around 1425.The word mellitus ( or ) comes from the classical Latin word mellītus, meaning "mellite" (i.e. sweetened with honey; honey-sweet). The Latin word comes from mell-, which comes from mel, meaning "honey"; sweetness; pleasant thing, and the suffix -ītus, whose meaning is the same as that of the English suffix "-ite". It was Thomas Willis who in 1675 added "mellitus" to the word "diabetes" as a designation for the disease, when he noticed the urine of a person with diabetes had a sweet taste (glycosuria). This sweet taste had been noticed in urine by the ancient Greeks, Chinese, Egyptians, and Indians. Society and culture The 1989 "St. Vincent Declaration" was the result of international efforts to improve the care accorded to those with diabetes. Doing so is important not only in terms of quality of life and life expectancy but also economically – expenses due to diabetes have been shown to be a major drain on health – and productivity-related resources for healthcare systems and governments.Several countries established more and less successful national diabetes programmes to improve treatment of the disease. Diabetes stigma Diabetes stigma describes the negative attitudes, judgment, discrimination, or prejudice against people with diabetes. Often, the stigma stems from the idea that diabetes (particularly Type 2 diabetes) resulted from poor lifestyle and unhealthy food choices rather than other causal factors like genetics and social determinants of health. Manifestation of stigma can be seen throughout different cultures and contexts. Scenarios include diabetes statuses affecting marriage proposals, workplace-employment, and social standing in communities.Stigma is also seen internally, as people with diabetes can also have negative beliefs about themselves. Often these cases of self-stigma are associated with higher diabetes-specific distress, lower self-efficacy, and poorer provider-patient interactions during diabetes care. Racial and economic inequalities Racial and ethnic minorities are disproportionately affected with higher prevalence of diabetes compared to non-minority individuals. While US adults overall have a 40% chance of developing type 2 diabetes, Hispanic/Latino adults chance is more than 50%. African Americans also are much more likely to be diagnosed with diabetes compared to White Americans. Asians have increased risk of diabetes as diabetes can develop at lower BMI due to differences in visceral fat compared to other races. For Asians, diabetes can develop at a younger age and lower body fat compared to other groups. Additionally, diabetes is highly underreported in Asian American people, as 1 in 3 cases are undiagnosed compared to the average 1 in 5 for the nation.People with diabetes who have neuropathic symptoms such as numbness or tingling in feet or hands are twice as likely to be unemployed as those without the symptoms.In 2010, diabetes-related emergency room (ER) visit rates in the United States were higher among people from the lowest income communities (526 per 10,000 population) than from the highest income communities (236 per 10,000 population). Approximately 9.4% of diabetes-related ER visits were for the uninsured. Naming The term "type 1 diabetes" has replaced several former terms, including childhood-onset diabetes, juvenile diabetes, and insulin-dependent diabetes mellitus. Likewise, the term "type 2 diabetes" has replaced several former terms, including adult-onset diabetes, obesity-related diabetes, and noninsulin-dependent diabetes mellitus. Beyond these two types, there is no agreed-upon standard nomenclature.Diabetes mellitus is also occasionally known as "sugar diabetes" to differentiate it from diabetes insipidus. Other animals Diabetes can occur in mammals or reptiles. Birds do not develop diabetes because of their unusually high tolerance for elevated blood glucose levels.In animals, diabetes is most commonly encountered in dogs and cats. Middle-aged animals are most commonly affected. Female dogs are twice as likely to be affected as males, while according to some sources, male cats are more prone than females. In both species, all breeds may be affected, but some small dog breeds are particularly likely to develop diabetes, such as Miniature Poodles.Feline diabetes is strikingly similar to human type 2 diabetes. The Burmese, Russian Blue, Abyssinian, and Norwegian Forest cat breeds are at higher risk than other breeds. Overweight cats are also at higher risk.The symptoms may relate to fluid loss and polyuria, but the course may also be insidious. Diabetic animals are more prone to infections. The long-term complications recognized in humans are much rarer in animals. The principles of treatment (weight loss, oral antidiabetics, subcutaneous insulin) and management of emergencies (e.g. ketoacidosis) are similar to those in humans. See also Outline of diabetesDiabetic footBlood glucose monitoring References External links American Diabetes AssociationIDF Diabetes AtlasNational Diabetes Education ProgramADA's Standards of Medical Care in Diabetes 2019Polonsky KS (October 2012). "The past 200 years in diabetes". The New England Journal of Medicine. 367 (14): 1332–1340. doi:10.1056/NEJMra1110560. PMID 23034021. S2CID 9456681."Diabetes". MedlinePlus. U.S. National Library of Medicine.
\ No newline at end of file
diff --git a/HybridRAG/tests/test_compose_on_gaudi.sh b/HybridRAG/tests/test_compose_on_gaudi.sh
new file mode 100755
index 0000000000..76ae9e876a
--- /dev/null
+++ b/HybridRAG/tests/test_compose_on_gaudi.sh
@@ -0,0 +1,257 @@
+#!/bin/bash
+# Copyright (C) 2025 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+IMAGE_REPO=${IMAGE_REPO:-"opea"}
+IMAGE_TAG=${IMAGE_TAG:-"latest"}
+echo "REGISTRY=IMAGE_REPO=${IMAGE_REPO}"
+echo "TAG=IMAGE_TAG=${IMAGE_TAG}"
+export REGISTRY=${IMAGE_REPO}
+export TAG=${IMAGE_TAG}
+export MODEL_CACHE=${model_cache:-"./data"}
+
+WORKPATH=$(dirname "$PWD")
+LOG_PATH="$WORKPATH/tests"
+ip_address=$(hostname -I | awk '{print $1}')
+
+cd $WORKPATH/docker_compose/intel/hpu/gaudi
+source set_env.sh
+
+function build_docker_images() {
+ opea_branch=${opea_branch:-"main"}
+ # If the opea_branch isn't main, replace the git clone branch in Dockerfile.
+ if [[ "${opea_branch}" != "main" ]]; then
+ cd $WORKPATH
+ OLD_STRING="RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git"
+ NEW_STRING="RUN git clone --depth 1 --branch ${opea_branch} https://github.com/opea-project/GenAIComps.git"
+ find . -type f -name "Dockerfile*" | while read -r file; do
+ echo "Processing file: $file"
+ sed -i "s|$OLD_STRING|$NEW_STRING|g" "$file"
+ done
+ fi
+
+ cd $WORKPATH/docker_image_build
+ git clone --depth 1 --branch ${opea_branch} https://github.com/opea-project/GenAIComps.git
+ REQ_FILE="GenAIComps/comps/text2cypher/src/requirements.txt"
+ sed -i \
+ -e 's/^sentence-transformers\(==.*\)\?$/sentence-transformers==3.2.1/' \
+ -e 's/^transformers\(==.*\)\?$/transformers==4.45.2/' \
+ "$REQ_FILE"
+
+ pushd GenAIComps
+ echo "GenAIComps test commit is $(git rev-parse HEAD)"
+ docker build --no-cache -t ${REGISTRY}/comps-base:${TAG} --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .
+ popd && sleep 1s
+
+ git clone https://github.com/vllm-project/vllm.git && cd vllm
+ VLLM_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" )"
+ VLLM_VER="v0.8.3"
+ echo "Check out vLLM tag ${VLLM_VER}"
+ git checkout ${VLLM_VER} &> /dev/null
+ # make sure NOT change the pwd
+ cd ../
+
+ echo "Build all the images with --no-cache, check docker_image_build.log for details..."
+ service_list="hybridrag hybridrag-ui dataprep retriever text2cypher vllm nginx"
+ docker compose -f build.yaml build ${service_list} --no-cache > ${LOG_PATH}/docker_image_build.log
+
+ docker pull ghcr.io/huggingface/text-embeddings-inference:cpu-1.5
+
+ docker images && sleep 1s
+}
+
+function start_services() {
+ cd $WORKPATH/docker_compose/intel/hpu/gaudi
+
+ # Start Docker Containers
+ docker compose -f compose.yaml up -d > ${LOG_PATH}/start_services_with_compose.log
+ n=0
+ until [[ "$n" -ge 100 ]]; do
+ docker logs vllm-service > ${LOG_PATH}/vllm_service_start.log 2>&1
+ if grep -q complete ${LOG_PATH}/vllm_service_start.log; then
+ break
+ fi
+ sleep 5s
+ n=$((n+1))
+ done
+}
+
+function dataprep() {
+ cd $WORKPATH/tests/data
+ sleep 25s
+ URL="http://${ip_address}:6007/v1/dataprep/ingest"
+ local CONTENT=$(curl -X POST -H "Content-Type: multipart/form-data" -F "files=@./Diabetes.txt" -F "files=@./Acne_Vulgaris.txt" -F "chunk_size=300" -F "chunk_overlap=20" "$URL")
+ if echo "$CONTENT" | grep -q "Data preparation succeeded"; then
+ echo "Data preparation succeeded."
+ else
+ echo "Data preparation failed."
+ exit 1
+ fi
+}
+
+function validate_service() {
+ local URL="$1"
+ local EXPECTED_RESULT="$2"
+ local SERVICE_NAME="$3"
+ local DOCKER_NAME="$4"
+ local INPUT_DATA="$5"
+
+ local HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "$INPUT_DATA" -H 'Content-Type: application/json' "$URL")
+
+ if [ "DOCKER_NAME" -eq "text2cypher-gaudi-container" ]; then
+ docker ps
+ docker logs text2cypher-gaudi-container
+ fi
+
+ if [ "$HTTP_STATUS" -eq 200 ]; then
+ echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..."
+
+ local CONTENT=$(curl -s -X POST -d "$INPUT_DATA" -H 'Content-Type: application/json' "$URL" | tee ${LOG_PATH}/${SERVICE_NAME}.log)
+
+ if echo "$CONTENT" | grep -q "$EXPECTED_RESULT"; then
+ echo "[ $SERVICE_NAME ] Content is as expected."
+ else
+ echo "[ $SERVICE_NAME ] Content does not match the expected result: $CONTENT"
+ docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log
+ if [ "DOCKER_NAME" -eq "hybridrag-xeon-backend-server" ]; then
+ docker ps
+ docker logs text2cypher-gaudi-container
+ fi
+ exit 1
+ fi
+ else
+ echo "[ $SERVICE_NAME ] HTTP status is not 200. Received status was $HTTP_STATUS"
+ docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log
+ if [ "DOCKER_NAME" -eq "hybridrag-xeon-backend-server" ]; then
+ docker ps
+ docker logs text2cypher-gaudi-container
+ fi
+ exit 1
+ fi
+ sleep 1s
+}
+
+function validate_microservices() {
+ # Check if the microservices are running correctly.
+
+ # tei for embedding service
+ validate_service \
+ "${ip_address}:6006/embed" \
+ "\[\[" \
+ "tei-embedding" \
+ "tei-embedding-server" \
+ '{"inputs":"What is Deep Learning?"}'
+
+ sleep 1m # retrieval can't curl as expected, try to wait for more time
+
+ # retrieval microservice
+ test_embedding=$(python3 -c "import random; embedding = [random.uniform(-1, 1) for _ in range(768)]; print(embedding)")
+ validate_service \
+ "${ip_address}:7000/v1/retrieval" \
+ " " \
+ "retriever" \
+ "retriever-redis-server" \
+ "{\"text\":\"What is the revenue of Nike in 2023?\",\"embedding\":${test_embedding}}"
+
+ # tei for rerank microservice
+ validate_service \
+ "${ip_address}:8808/rerank" \
+ '{"index":1,"score":' \
+ "tei-reranking-service" \
+ "tei-reranking-server" \
+ '{"query":"What is Deep Learning?", "texts": ["Deep Learning is not...", "Deep learning is..."]}'
+
+ # vllm for llm service
+ validate_service \
+ "${ip_address}:9009/v1/chat/completions" \
+ "content" \
+ "vllm-service" \
+ "vllm-service" \
+ '{"model": "meta-llama/Meta-Llama-3-8B-Instruct", "messages": [{"role": "user", "content": "What is Deep Learning?"}], "max_tokens": 17}'
+}
+
+function validate_megaservice() {
+ # Curl the Mega Service
+ validate_service \
+ "${ip_address}:8888/v1/hybridrag" \
+ "data" \
+ "hybridrag-xeon-backend-server" \
+ "hybridrag-xeon-backend-server" \
+ '{"messages": "what are the symptoms for Diabetes?"}'
+
+}
+
+function validate_text2cypher() {
+ # text2cypher service
+ validate_service \
+ "${ip_address}:11801/v1/text2cypher" \
+ "\[" \
+ "text2cypher-gaudi" \
+ "text2cypher-gaudi-container" \
+ '{"input_text": "what are the symptoms for Diabetes?"}'
+}
+
+function validate_frontend() {
+ cd $WORKPATH/ui/svelte
+ local conda_env_name="OPEA_e2e"
+ export PATH=${HOME}/miniforge3/bin/:$PATH
+ if conda info --envs | grep -q "$conda_env_name"; then
+ echo "$conda_env_name exist!"
+ else
+ conda create -n ${conda_env_name} python=3.12 -y
+ fi
+
+ source activate ${conda_env_name}
+
+ sed -i "s/localhost/$ip_address/g" playwright.config.ts
+
+ conda install -c conda-forge nodejs=22.6.0 -y
+ npm install && npm ci && npx playwright install --with-deps
+ node -v && npm -v && pip list
+
+ exit_status=0
+ npx playwright test || exit_status=$?
+
+ if [ $exit_status -ne 0 ]; then
+ echo "[TEST INFO]: ---------frontend test failed---------"
+ exit $exit_status
+ else
+ echo "[TEST INFO]: ---------frontend test passed---------"
+ fi
+}
+
+function stop_docker() {
+ cd $WORKPATH/docker_compose/intel/hpu/gaudi
+ docker compose -f compose.yaml down
+}
+
+function main() {
+
+ stop_docker
+
+ if [[ "$IMAGE_REPO" == "opea" ]]; then build_docker_images; fi
+ start_time=$(date +%s)
+ start_services
+ end_time=$(date +%s)
+ duration=$((end_time-start_time))
+ echo "Mega service start duration is $duration s" && sleep 1s
+
+ validate_microservices
+ dataprep
+
+ #validate_text2cypher
+ #export refresh_db="False"
+ validate_megaservice
+
+ validate_frontend
+
+ cd $WORKPATH/docker_image_build
+ rm -rf GenAIComps vllm
+
+ stop_docker
+ echo y | docker system prune
+
+}
+
+main
diff --git a/HybridRAG/ui/docker/Dockerfile b/HybridRAG/ui/docker/Dockerfile
new file mode 100644
index 0000000000..1d5115f4b5
--- /dev/null
+++ b/HybridRAG/ui/docker/Dockerfile
@@ -0,0 +1,26 @@
+# Copyright (C) 2024 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+# Use node 20.11.1 as the base image
+FROM node:20.11.1
+
+# Update package manager and install Git
+RUN apt-get update -y && apt-get install -y git
+
+# Copy the front-end code repository
+COPY svelte /home/user/svelte
+
+# Set the working directory
+WORKDIR /home/user/svelte
+
+# Install front-end dependencies
+RUN npm install
+
+# Build the front-end application
+RUN npm run build
+
+# Expose the port of the front-end application
+EXPOSE 5173
+
+# Run the front-end application in preview mode
+CMD ["npm", "run", "preview", "--", "--port", "5173", "--host", "0.0.0.0"]
diff --git a/HybridRAG/ui/svelte/.editorconfig b/HybridRAG/ui/svelte/.editorconfig
new file mode 100644
index 0000000000..2b7a6637f7
--- /dev/null
+++ b/HybridRAG/ui/svelte/.editorconfig
@@ -0,0 +1,10 @@
+[*]
+indent_style = tab
+
+[package.json]
+indent_style = space
+indent_size = 2
+
+[*.md]
+indent_style = space
+indent_size = 2
diff --git a/HybridRAG/ui/svelte/.env b/HybridRAG/ui/svelte/.env
new file mode 100644
index 0000000000..0ac5c8c83a
--- /dev/null
+++ b/HybridRAG/ui/svelte/.env
@@ -0,0 +1,7 @@
+CHAT_BASE_URL = '/v1/hybridrag'
+
+UPLOAD_FILE_BASE_URL = '/v1/dataprep/ingest'
+
+GET_FILE = '/v1/dataprep/get'
+
+DELETE_FILE = '/v1/dataprep/delete'
diff --git a/HybridRAG/ui/svelte/.eslintignore b/HybridRAG/ui/svelte/.eslintignore
new file mode 100644
index 0000000000..38972655fa
--- /dev/null
+++ b/HybridRAG/ui/svelte/.eslintignore
@@ -0,0 +1,13 @@
+.DS_Store
+node_modules
+/build
+/.svelte-kit
+/package
+.env
+.env.*
+!.env.example
+
+# Ignore files for PNPM, NPM and YARN
+pnpm-lock.yaml
+package-lock.json
+yarn.lock
diff --git a/HybridRAG/ui/svelte/.eslintrc.cjs b/HybridRAG/ui/svelte/.eslintrc.cjs
new file mode 100644
index 0000000000..a6592d11f7
--- /dev/null
+++ b/HybridRAG/ui/svelte/.eslintrc.cjs
@@ -0,0 +1,34 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+module.exports = {
+ root: true,
+ parser: "@typescript-eslint/parser",
+ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
+ plugins: ["svelte3", "@typescript-eslint", "neverthrow"],
+ ignorePatterns: ["*.cjs"],
+ overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
+ settings: {
+ "svelte3/typescript": () => require("typescript"),
+ },
+ parserOptions: {
+ sourceType: "module",
+ ecmaVersion: 2020,
+ },
+ env: {
+ browser: true,
+ es2017: true,
+ node: true,
+ },
+};
diff --git a/HybridRAG/ui/svelte/.prettierignore b/HybridRAG/ui/svelte/.prettierignore
new file mode 100644
index 0000000000..38972655fa
--- /dev/null
+++ b/HybridRAG/ui/svelte/.prettierignore
@@ -0,0 +1,13 @@
+.DS_Store
+node_modules
+/build
+/.svelte-kit
+/package
+.env
+.env.*
+!.env.example
+
+# Ignore files for PNPM, NPM and YARN
+pnpm-lock.yaml
+package-lock.json
+yarn.lock
diff --git a/HybridRAG/ui/svelte/.prettierrc b/HybridRAG/ui/svelte/.prettierrc
new file mode 100644
index 0000000000..c932dd178f
--- /dev/null
+++ b/HybridRAG/ui/svelte/.prettierrc
@@ -0,0 +1 @@
+{"pluginSearchDirs": ["."], "overrides": [{"files": "*.svelte", "options": {"parser": "svelte"}}]}
diff --git a/HybridRAG/ui/svelte/README.md b/HybridRAG/ui/svelte/README.md
new file mode 100644
index 0000000000..d3c26b8f0f
--- /dev/null
+++ b/HybridRAG/ui/svelte/README.md
@@ -0,0 +1,42 @@
+# ChatQnA Customized UI
+
+## 📸 Project Screenshots
+
+
+
+
+
+## 🧐 Features
+
+Here're some of the project's features:
+
+- Start a Text Chat:Initiate a text chat with the ability to input written conversations, where the dialogue content can also be customized based on uploaded files.
+- Clear: Clear the record of the current dialog box without retaining the contents of the dialog box.
+- Chat history: Historical chat records can still be retained after refreshing, making it easier for users to view the context.
+- Scroll to Bottom / Top: The chat automatically slides to the bottom. Users can also click the top icon to slide to the top of the chat record.
+- End to End Time: Shows the time spent on the current conversation.
+- Upload File: The choice between uploading locally or copying a remote link. Chat according to uploaded knowledge base.
+- Delete File: Delete a certain uploaded file.
+
+## 🛠️ Get it Running
+
+1. Clone the repo.
+
+2. cd command to the current folder.
+
+3. Modify the required .env variables.
+
+ ```
+ CHAT_BASE_URL = ''
+
+ UPLOAD_FILE_BASE_URL = ''
+
+ GET_FILE = ''
+
+ DELETE_FILE = ''
+
+ ```
+
+4. Execute `npm install` to install the corresponding dependencies.
+
+5. Execute `npm run dev` in both environments
diff --git a/HybridRAG/ui/svelte/package.json b/HybridRAG/ui/svelte/package.json
new file mode 100644
index 0000000000..0f19db6e56
--- /dev/null
+++ b/HybridRAG/ui/svelte/package.json
@@ -0,0 +1,60 @@
+{
+ "name": "chat-qna",
+ "version": "0.0.1",
+ "private": true,
+ "scripts": {
+ "dev": "vite dev",
+ "build": "vite build",
+ "preview": "vite preview",
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
+ "lint": "prettier --check . && eslint .",
+ "format": "prettier --write ."
+ },
+ "peerDependencies": {
+ "svelte": "^4.0.0"
+ },
+ "devDependencies": {
+ "@fortawesome/free-solid-svg-icons": "6.2.0",
+ "@playwright/test": "^1.45.2",
+ "@sveltejs/adapter-auto": "^3.0.0",
+ "@sveltejs/kit": "^2.0.0",
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
+ "@tailwindcss/typography": "0.5.7",
+ "@types/debug": "4.1.7",
+ "@types/node": "^20.12.13",
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
+ "@typescript-eslint/parser": "^5.27.0",
+ "autoprefixer": "^10.4.16",
+ "date-picker-svelte": "^2.6.0",
+ "debug": "4.3.4",
+ "postcss": "^8.4.31",
+ "postcss-load-config": "^4.0.1",
+ "postcss-preset-env": "^8.3.2",
+ "prettier": "^2.8.8",
+ "prettier-plugin-svelte": "^2.7.0",
+ "prettier-plugin-tailwindcss": "^0.3.0",
+ "svelte": "^4.2.7",
+ "svelte-check": "^3.6.0",
+ "svelte-fa": "3.0.3",
+ "tailwindcss": "^3.3.6",
+ "tslib": "^2.4.1",
+ "typescript": "^5.0.0",
+ "vite": "^5.0.11"
+ },
+ "type": "module",
+ "dependencies": {
+ "date-fns": "^2.30.0",
+ "driver.js": "^1.3.0",
+ "flowbite": "^2.5.2",
+ "flowbite-svelte": "^0.38.5",
+ "flowbite-svelte-icons": "^1.4.0",
+ "fuse.js": "^6.6.2",
+ "lodash": "^4.17.21",
+ "playwright": "^1.44.0",
+ "ramda": "^0.29.0",
+ "sse.js": "^0.6.1",
+ "svelte-notifications": "^0.9.98",
+ "svrollbar": "^0.12.0"
+ }
+}
diff --git a/HybridRAG/ui/svelte/playwright.config.ts b/HybridRAG/ui/svelte/playwright.config.ts
new file mode 100644
index 0000000000..e26b9f3f8c
--- /dev/null
+++ b/HybridRAG/ui/svelte/playwright.config.ts
@@ -0,0 +1,87 @@
+// Copyright (C) 2024 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+
+import { defineConfig, devices } from "@playwright/test";
+
+/**
+ * Read environment variables from file.
+ * https://github.com/motdotla/dotenv
+ */
+// require('dotenv').config();
+
+/**
+ * See https://playwright.dev/docs/test-configuration.
+ */
+export default defineConfig({
+ testDir: "./tests",
+ /* Maximum time one test can run for. */
+ timeout: 30 * 1000,
+ expect: {
+ /**
+ * Maximum time expect() should wait for the condition to be met.
+ * For example in `await expect(locator).toHaveText();`
+ */
+ timeout: 20000,
+ },
+ /* Run tests in files in parallel */
+ fullyParallel: true,
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
+ forbidOnly: !!process.env.CI,
+ /* Retry on CI only */
+ retries: process.env.CI ? 2 : 0,
+ /* Opt out of parallel tests on CI. */
+ workers: process.env.CI ? 1 : undefined,
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
+ reporter: [["html", { open: "never" }]],
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
+ use: {
+ /* 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://localhost:80",
+
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
+ trace: "on-first-retry",
+ },
+
+ /* Configure projects for major browsers */
+ projects: [
+ // {
+ // name: "chromium",
+ // use: { ...devices["Desktop Chrome"] },
+ // },
+
+ /* Test against mobile viewports. */
+ // {
+ // name: 'Mobile Chrome',
+ // use: { ...devices['Pixel 5'] },
+ // },
+ // {
+ // name: 'Mobile Safari',
+ // use: { ...devices['iPhone 12'] },
+ // },
+
+ /* Test against branded browsers. */
+ // {
+ // name: 'Microsoft Edge',
+ // use: { channel: 'msedge' },
+ // },
+ {
+ name: "webkit",
+ use: { ...devices["Desktop Safari"] },
+ },
+ // {
+ // name: 'Google Chrome',
+ // use: { channel: 'chrome' },
+ // },
+ ],
+
+ /* Folder for test artifacts such as screenshots, videos, traces, etc. */
+ // outputDir: 'test-results/',
+
+ /* Run your local dev server before starting the tests */
+ // webServer: {
+ // command: 'npm run start',
+ // port: 3000,
+ // },
+});
diff --git a/HybridRAG/ui/svelte/postcss.config.cjs b/HybridRAG/ui/svelte/postcss.config.cjs
new file mode 100644
index 0000000000..b384b43ebe
--- /dev/null
+++ b/HybridRAG/ui/svelte/postcss.config.cjs
@@ -0,0 +1,27 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const tailwindcss = require("tailwindcss");
+const autoprefixer = require("autoprefixer");
+
+const config = {
+ plugins: [
+ //Some plugins, like tailwindcss/nesting, need to run before Tailwind,
+ tailwindcss(),
+ //But others, like autoprefixer, need to run after,
+ autoprefixer,
+ ],
+};
+
+module.exports = config;
diff --git a/HybridRAG/ui/svelte/src/app.d.ts b/HybridRAG/ui/svelte/src/app.d.ts
new file mode 100644
index 0000000000..fa6a0abf77
--- /dev/null
+++ b/HybridRAG/ui/svelte/src/app.d.ts
@@ -0,0 +1,19 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// See: https://kit.svelte.dev/docs/types#app
+// import { Result} from "neverthrow";
+interface Window {
+ deviceType: string;
+}
diff --git a/HybridRAG/ui/svelte/src/app.html b/HybridRAG/ui/svelte/src/app.html
new file mode 100644
index 0000000000..db69926ea8
--- /dev/null
+++ b/HybridRAG/ui/svelte/src/app.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+ {@html msg.content} +
+{time}s
++ {file.name} +
+ {:else if file.type === "Directory" && file.id === "uploaded_links"} + + {:else} + + {/if} + + + +Folder is empty. Please upload a file.
+ {/if} +Folder is empty. Please upload a file.
+{/if} diff --git a/HybridRAG/ui/svelte/src/lib/shared/components/doc_management/treeView/tree-node.svelte b/HybridRAG/ui/svelte/src/lib/shared/components/doc_management/treeView/tree-node.svelte new file mode 100644 index 0000000000..eac311df83 --- /dev/null +++ b/HybridRAG/ui/svelte/src/lib/shared/components/doc_management/treeView/tree-node.svelte @@ -0,0 +1,111 @@ + + + + ++ Please upload your local file or paste a remote file link, and Chat will + respond based on the content of the uploaded file. +
+ +No files uploaded
+HybridRAGQnA
+