Skip to content

Commit

Permalink
Merge branch 'main' into multi-turn-v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
minmin-intel authored Feb 13, 2025
2 parents 6462f06 + d1dfd0e commit 5b5a72e
Show file tree
Hide file tree
Showing 64 changed files with 467 additions and 225 deletions.
1 change: 0 additions & 1 deletion .github/workflows/_comps-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ jobs:
fi
if [[ $(grep -c "vllm-gaudi:" ${docker_compose_yml}) != 0 ]]; then
git clone --depth 1 --branch v0.6.4.post2+Gaudi-1.19.0 https://github.com/HabanaAI/vllm-fork.git
sed -i 's/triton/triton==3.1.0/g' vllm-fork/requirements-hpu.txt
fi
- name: Get build list
id: get-build-list
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/_run-helm-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ jobs:
if [[ "${service,,}" == *"third_parties"* ]]; then
CHART_NAME="$(echo "${service,,}"|cut -d'/' -f2)" # bridgetower
else
CHART_NAME="${service_name}" # agent
CHART_NAME="${service_name}" # web_retrievers
fi
CHART_NAME=$(echo "$CHART_NAME" | tr -cd 'a-z0-9')
echo "service_name=$service_name" >> $GITHUB_ENV
echo "CHART_NAME=$CHART_NAME" >> $GITHUB_ENV
echo "RELEASE_NAME=${CHART_NAME}$(date +%d%H%M%S)" >> $GITHUB_ENV
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker/compose/chathistory-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# this file should be run in the root of the repo
services:
chathistory-mongo-server:
chathistory-mongo:
build:
dockerfile: comps/chathistory/src/Dockerfile
image: ${REGISTRY:-opea}/chathistory-mongo-server:${TAG:-latest}
image: ${REGISTRY:-opea}/chathistory-mongo:${TAG:-latest}
2 changes: 1 addition & 1 deletion .github/workflows/manual-comps-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
inputs:
services:
default: "asr"
description: "List of services to test [agent,asr,chathistory,dataprep,embeddings,feedback_management,finetuning,guardrails,knowledgegraphs,llms,lvms,nginx,prompt_registry,ragas,rerankings,retrievers,tts,web_retrievers]"
description: "List of services to test [agent,asr,chathistory,animation,dataprep,embeddings,feedback_management,finetuning,guardrails,image2image,image2video,intent_detection,llms,lvms,prompt_registry,ragas,rerankings,retrievers,text2image,text2sql,third_parties,tts,vectorstores,web_retrievers]"
required: true
type: string
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
inputs:
services:
default: ""
description: "List of services to test [agent,asr,chathistory,dataprep,embeddings,feedback_management,finetuning,guardrails,knowledgegraphs,llms,lvms,nginx,prompt_registry,ragas,rerankings,retrievers,tts,web_retrievers]"
description: "List of services to test [agent,asr,chathistory,animation,dataprep,embeddings,feedback_management,finetuning,guardrails,image2image,image2video,intent_detection,llms,lvms,prompt_registry,ragas,rerankings,retrievers,text2image,text2sql,third_parties,tts,vectorstores,web_retrievers]"
required: false
type: string
images:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/push-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:

image-build:
needs: get-build-matrix
if: ${{ fromJSON(needs.get-build-matrix.outputs.services).length != 0 }}
if: needs.get-build-matrix.outputs.services != '[]'
strategy:
matrix:
service: ${{ fromJSON(needs.get-build-matrix.outputs.services) }}
Expand Down Expand Up @@ -96,7 +96,6 @@ jobs:
fi
if [[ $(grep -c "vllm-gaudi:" ${docker_compose_path}) != 0 ]]; then
git clone --depth 1 --branch v0.6.4.post2+Gaudi-1.19.0 https://github.com/HabanaAI/vllm-fork.git
sed -i 's/triton/triton==3.1.0/g' vllm-fork/requirements-hpu.txt
fi
- name: Build Image
Expand Down
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# Base image for GenAIComps based OPEA Python applications
# Build: docker build -t opea/comps-base -f Dockerfile .

ARG IMAGE_NAME=python
ARG IMAGE_TAG=3.11-slim

FROM ${IMAGE_NAME}:${IMAGE_TAG} AS base

ENV HOME=/home/user

RUN useradd -m -s /bin/bash user && \
mkdir -p $HOME && \
chown -R user $HOME

# get security updates
RUN apt-get update && apt-get upgrade -y && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

WORKDIR $HOME

COPY *.toml *.py *.txt *.md LICENSE ./

RUN pip install --no-cache-dir --upgrade pip setuptools && \
pip install --no-cache-dir -r requirements.txt

COPY comps/ comps/

ENV PYTHONPATH=$PYTHONPATH:$HOME

USER user

ENTRYPOINT ["sh", "-c", "set && ls -la"]
3 changes: 3 additions & 0 deletions LEGAL_INFORMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Your use of the source code for these components is subject to the terms and con

See the accompanying [license](LICENSE) file for full license text and copyright notices.

Please note: component(s) depend on software subject to non-open source licenses.  If you use or redistribute this software, it is your sole responsibility to ensure compliance with such licenses.
e.g langserve

## Citation

If you use Generative AI Components in your research, use the following BibTeX entry.
Expand Down
2 changes: 1 addition & 1 deletion comps/chathistory/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
command: mongod --quiet --logpath /dev/null

chathistory-mongo:
image: ${REGISTRY:-opea}/chathistory-mongo-server:${TAG:-latest}
image: ${REGISTRY:-opea}/chathistory-mongo:${TAG:-latest}
container_name: chathistory-mongo-server
ports:
- "${CHATHISTORY_PORT:-6012}:6012"
Expand Down
2 changes: 1 addition & 1 deletion comps/chathistory/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export COLLECTION_NAME=${COLLECTION_NAME}

```bash
cd ../../../../
docker build -t opea/chathistory-mongo-server:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/src/Dockerfile .
docker build -t opea/chathistory-mongo:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/src/Dockerfile .
```

### Run Docker with CLI
Expand Down
61 changes: 49 additions & 12 deletions comps/cores/mega/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import re
import threading
import time
from typing import Dict, List

Expand All @@ -27,28 +28,64 @@


class OrchestratorMetrics:
# Because:
# - CI creates several orchestrator instances
# - Prometheus requires metrics to be singletons
# - Oorchestror instances are not provided their own names
# Metrics are class members with "megaservice" name prefix
first_token_latency = Histogram("megaservice_first_token_latency", "First token latency (histogram)")
inter_token_latency = Histogram("megaservice_inter_token_latency", "Inter-token latency (histogram)")
request_latency = Histogram("megaservice_request_latency", "Whole request/reply latency (histogram)")
request_pending = Gauge("megaservice_request_pending", "Count of currently pending requests (gauge)")
# Need an static class-level ID for metric prefix because:
# - Prometheus requires metrics (their names) to be unique
_instance_id = 0

def __init__(self) -> None:
pass
OrchestratorMetrics._instance_id += 1
if OrchestratorMetrics._instance_id > 1:
self._prefix = f"megaservice{self._instance_id}"
else:
self._prefix = "megaservice"

self.request_pending = Gauge(f"{self._prefix}_request_pending", "Count of currently pending requests (gauge)")

# locking for latency metric creation / method change
self._lock = threading.Lock()

# Metrics related to token processing are created on demand,
# to avoid bogus ones for services that never handle tokens
self.first_token_latency = None
self.inter_token_latency = None
self.request_latency = None

# initial methods to create the metrics
self.token_update = self._token_update_create
self.request_update = self._request_update_create

def _token_update_create(self, token_start: float, is_first: bool) -> float:
with self._lock:
# in case another thread already got here
if self.token_update == self._token_update_create:
self.first_token_latency = Histogram(
f"{self._prefix}_first_token_latency", "First token latency (histogram)"
)
self.inter_token_latency = Histogram(
f"{self._prefix}_inter_token_latency", "Inter-token latency (histogram)"
)
self.token_update = self._token_update_real
return self.token_update(token_start, is_first)

def _request_update_create(self, req_start: float) -> None:
with self._lock:
# in case another thread already got here
if self.request_update == self._request_update_create:
self.request_latency = Histogram(
f"{self._prefix}_request_latency", "Whole LLM request/reply latency (histogram)"
)
self.request_update = self._request_update_real
self.request_update(req_start)

def token_update(self, token_start: float, is_first: bool) -> float:
def _token_update_real(self, token_start: float, is_first: bool) -> float:
now = time.time()
if is_first:
self.first_token_latency.observe(now - token_start)
else:
self.inter_token_latency.observe(now - token_start)
return now

def request_update(self, req_start: float) -> None:
def _request_update_real(self, req_start: float) -> None:
self.request_latency.observe(time.time() - req_start)

def pending_update(self, increase: bool) -> None:
Expand Down
5 changes: 3 additions & 2 deletions comps/dataprep/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
DATAPREP_COMPONENT_NAME: "OPEA_DATAPREP_ELASTICSEARCH"
ES_CONNECTION_STRING: ${ES_CONNECTION_STRING}
INDEX_NAME: ${INDEX_NAME}
TEI_ENDPOINT: ${TEI_ENDPOINT}
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
restart: unless-stopped
depends_on:
Expand All @@ -49,6 +49,7 @@ services:
MILVUS_HOST: ${MILVUS_HOST}
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
LOGFLAG: ${LOGFLAG}
restart: unless-stopped
depends_on:
tei-embedding-serving:
Expand Down Expand Up @@ -161,7 +162,7 @@ services:
QDRANT_HOST: ${QDRANT_HOST}
QDRANT_PORT: ${QDRANT_PORT}
COLLECTION_NAME: ${COLLECTION_NAME}
TEI_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
TEI_EMBEDDING_ENDPOINT: ${TEI_EMBEDDING_ENDPOINT}
HUGGINGFACEHUB_API_TOKEN: ${HF_TOKEN}
restart: unless-stopped

Expand Down
2 changes: 1 addition & 1 deletion comps/dataprep/src/README_elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ docker build -t opea/dataprep:latest --build-arg https_proxy=$https_proxy --buil
### 2.4 Run Docker with CLI (Option A)

```bash
docker run --name="dataprep-elasticsearch" -p 6011:6011 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e ES_CONNECTION_STRING=$ES_CONNECTION_STRING -e INDEX_NAME=$INDEX_NAME -e TEI_ENDPOINT=$TEI_ENDPOINT -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_ELASTICSEARCH" opea/dataprep:latest
docker run --name="dataprep-elasticsearch" -p 6011:6011 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e ES_CONNECTION_STRING=$ES_CONNECTION_STRING -e INDEX_NAME=$INDEX_NAME -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_ELASTICSEARCH" opea/dataprep:latest
```

### 2.5 Run with Docker Compose (Option B)
Expand Down
5 changes: 4 additions & 1 deletion comps/dataprep/src/README_milvus.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export MILVUS_HOST=${your_milvus_host_ip}
export MILVUS_PORT=19530
export COLLECTION_NAME=${your_collection_name}
export TEI_EMBEDDING_ENDPOINT=${your_embedding_endpoint}
export HUGGINGFACEHUB_API_TOKEN=${your_huggingface_api_token}
```

### 1.4 Start TEI Embedding Service
Expand Down Expand Up @@ -70,13 +71,15 @@ docker build -t opea/dataprep:latest --build-arg https_proxy=$https_proxy --buil

```bash
export TEI_EMBEDDING_ENDPOINT="http://localhost:$your_port"
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export EMBEDDING_MODEL_ID=${your_embedding_model_id}
export MILVUS_HOST=${your_host_ip}
```

### 2.3 Run Docker with CLI (Option A)

```bash
docker run -d --name="dataprep-milvus-server" -p 6010:6010 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT} -e MILVUS_HOST=${MILVUS_HOST} -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_MILVUS" opea/dataprep:latest
docker run -d --name="dataprep-milvus-server" -p 6010:6010 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e TEI_EMBEDDING_ENDPOINT=${TEI_EMBEDDING_ENDPOINT} -e MILVUS_HOST=${MILVUS_HOST} -e HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN} -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_MILVUS" opea/dataprep:latest
```

### 2.4 Run with Docker Compose (Option B)
Expand Down
6 changes: 3 additions & 3 deletions comps/dataprep/src/README_opensearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ curl localhost:$your_port/embed \
After checking that it works, set up environment variables.

```bash
export TEI_ENDPOINT="http://localhost:$your_port"
export TEI_EMBEDDING_ENDPOINT="http://localhost:$your_port"
```

### 1.4 Start Document Preparation Microservice for OpenSearch with Python Script
Expand All @@ -75,7 +75,7 @@ Please refer to this [readme](../../third_parties/opensearch/src/README.md).

```bash
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export TEI_ENDPOINT="http://${your_ip}:6006"
export TEI_EMBEDDING_ENDPOINT="http://${your_ip}:6006"
export OPENSEARCH_URL="http://${your_ip}:9200"
export INDEX_NAME=${your_index_name}
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
Expand All @@ -97,7 +97,7 @@ docker build -t opea/dataprep:latest --build-arg https_proxy=$https_proxy --buil
- option 1: Start single-process version (for processing up to 10 files)

```bash
docker run -d --name="dataprep-opensearch-server" -p 6007:6007 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e OPENSEARCH_URL=$OPENSEARCH_URL -e INDEX_NAME=$INDEX_NAME -e TEI_ENDPOINT=$TEI_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_OPENSEARCH" opea/dataprep:latest
docker run -d --name="dataprep-opensearch-server" -p 6007:6007 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e OPENSEARCH_URL=$OPENSEARCH_URL -e INDEX_NAME=$INDEX_NAME -e EMBED_MODEL=${EMBED_MODEL} -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_OPENSEARCH" opea/dataprep:latest
```

### 2.5 Run with Docker Compose (Option B - deprecated, will move to genAIExample in future)
Expand Down
4 changes: 3 additions & 1 deletion comps/dataprep/src/README_pgvector.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Please refer to this [readme](../../third_parties/pgvector/src/README.md).
```bash
export PG_CONNECTION_STRING=postgresql+psycopg2://testuser:testpwd@${your_ip}:5432/vectordb
export INDEX_NAME=${your_index_name}
export TEI_EMBEDDING_ENDPOINT=${your_tei_embedding_endpoint}
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
```

### 2.3 Build Docker Image
Expand All @@ -50,7 +52,7 @@ docker build -t opea/dataprep:latest --build-arg https_proxy=$https_proxy --buil
### 2.4 Run Docker with CLI (Option A)

```bash
docker run --name="dataprep-pgvector" -p 6007:6007 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e PG_CONNECTION_STRING=$PG_CONNECTION_STRING -e INDEX_NAME=$INDEX_NAME -e TEI_ENDPOINT=$TEI_ENDPOINT -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_PGVECTOR" opea/dataprep:latest
docker run --name="dataprep-pgvector" -p 6007:6007 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e PG_CONNECTION_STRING=$PG_CONNECTION_STRING -e INDEX_NAME=$INDEX_NAME -e EMBED_MODEL=${EMBED_MODEL} -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN} -e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_PGVECTOR" opea/dataprep:latest
```

### 2.5 Run with Docker Compose (Option B)
Expand Down
5 changes: 2 additions & 3 deletions comps/dataprep/src/README_redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ Please refer to this [readme](../../third_parties/redis/src/README.md).
### 2.2 Setup Environment Variables

```bash
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export TEI_ENDPOINT="http://${your_ip}:6006"
export TEI_EMBEDDING_ENDPOINT="http://${your_ip}:6006"
export REDIS_URL="redis://${your_ip}:6379"
export INDEX_NAME=${your_index_name}
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
Expand All @@ -112,7 +111,7 @@ docker build -t opea/dataprep:latest --build-arg https_proxy=$https_proxy --buil
### 2.4 Run Docker with CLI (Option A)

```bash
docker run -d --name="dataprep-redis-server" -p 6007:6007 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e TEI_ENDPOINT=$TEI_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN opea/dataprep:latest
docker run -d --name="dataprep-redis-server" -p 6007:5000 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=$HUGGINGFACEHUB_API_TOKEN opea/dataprep:latest
```

### 2.5 Run with Docker Compose (Option B - deprecated, will move to genAIExample in future)
Expand Down
6 changes: 4 additions & 2 deletions comps/dataprep/src/README_vdms.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export http_proxy=${your_http_proxy}
export https_proxy=${your_http_proxy}
export VDMS_HOST=${host_ip}
export VDMS_PORT=55555
export TEI_ENDPOINT=${your_tei_endpoint}
export TEI_EMBEDDING_ENDPOINT=${your_tei_endpoint}
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export COLLECTION_NAME=${your_collection_name}
export SEARCH_ENGINE="FaissFlat"
export DISTANCE_STRATEGY="L2"
Expand All @@ -89,7 +90,8 @@ Start single-process version (for 1-10 files processing)

```bash
docker run -d --name="dataprep-vdms-server" -p 6007:6007 --runtime=runc --ipc=host \
-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e TEI_ENDPOINT=$TEI_ENDPOINT \
-e http_proxy=$http_proxy -e https_proxy=$https_proxy \
-e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN} \
-e COLLECTION_NAME=$COLLECTION_NAME -e VDMS_HOST=$VDMS_HOST -e VDMS_PORT=$VDMS_PORT \
-e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_VDMS" opea/dataprep:latest
```
Expand Down
Loading

0 comments on commit 5b5a72e

Please sign in to comment.