Skip to content

Commit

Permalink
Standardize name for LLM comps (opea-project#1162)
Browse files Browse the repository at this point in the history
Update all the names for classes and files in llm comps to follow the standard format

Related to issue opea-project#998

Signed-off-by: Xinyao Wang <[email protected]>
  • Loading branch information
XinyaoWa authored Jan 16, 2025
1 parent 3ce77ad commit a65e559
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
LLM_ENDPOINT: ${LLM_ENDPOINT}
HF_TOKEN: ${HF_TOKEN}
LLM_MODEL_ID: ${LLM_MODEL_ID}
LLM_COMPONENT_NAME: "OPEA_LLM"
LLM_COMPONENT_NAME: "OpeaTextGenService"
restart: unless-stopped

networks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
vLLM_ENDPOINT: ${vLLM_ENDPOINT}
HF_TOKEN: ${HF_TOKEN}
LLM_MODEL: ${LLM_MODEL}
LLM_COMPONENT_NAME: "OPEA_LLM"
LLM_COMPONENT_NAME: "OpeaTextGenService"
restart: unless-stopped

networks:
Expand Down
2 changes: 1 addition & 1 deletion comps/llms/src/doc-summarization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export LLM_MODEL_ID=${your_hf_llm_model}
export MAX_INPUT_TOKENS=2048
export MAX_TOTAL_TOKENS=4096
export DocSum_COMPONENT_NAME="OPEADocSum_TGI" # or "OPEADocSum_vLLM"
export DocSum_COMPONENT_NAME="OpeaDocSumTgi" # or "OpeaDocSumvLLM"
```

Please make sure MAX_TOTAL_TOKENS should be larger than (MAX_INPUT_TOKENS + max_new_tokens + 50), 50 is reserved prompt length.
Expand Down
4 changes: 2 additions & 2 deletions comps/llms/src/doc-summarization/integrations/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_llm_endpoint():
raise ConfigError(f"Input model {MODEL_NAME} not present in model_configs")


class OPEADocSum(OpeaComponent):
class OpeaDocSum(OpeaComponent):
"""A specialized OPEA DocSum component derived from OpeaComponent.
Attributes:
Expand All @@ -72,7 +72,7 @@ def __init__(self, name: str, description: str, config: dict = None):
self.tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
health_status = self.check_health()
if not health_status:
logger.error("OPEADocSum health check failed.")
logger.error("OpeaDocSum health check failed.")

async def generate(self, input: DocSumLLMParams, client):
"""Invokes the TGI/vLLM LLM service to generate summarization for the provided input.
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/src/doc-summarization/integrations/tgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
logflag = os.getenv("LOGFLAG", False)


@OpeaComponentRegistry.register("OPEADocSum_TGI")
class OPEADocSum_TGI(OPEADocSum):
"""A specialized OPEA DocSum TGI component derived from OPEADocSum for interacting with TGI services based on Lanchain HuggingFaceEndpoint API.
@OpeaComponentRegistry.register("OpeaDocSumTgi")
class OpeaDocSumTgi(OpeaDocSum):
"""A specialized OPEA DocSum TGI component derived from OpeaDocSum for interacting with TGI services based on Lanchain HuggingFaceEndpoint API.
Attributes:
client (TGI): An instance of the TGI client for text generation.
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/src/doc-summarization/integrations/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
logflag = os.getenv("LOGFLAG", False)


@OpeaComponentRegistry.register("OPEADocSum_vLLM")
class OPEADocSum_vLLM(OPEADocSum):
"""A specialized OPEA DocSum vLLM component derived from OPEADocSum for interacting with vLLM services based on Lanchain VLLMOpenAI API.
@OpeaComponentRegistry.register("OpeaDocSumvLLM")
class OpeaDocSumvLLM(OpeaDocSum):
"""A specialized OPEA DocSum vLLM component derived from OpeaDocSum for interacting with vLLM services based on Lanchain VLLMOpenAI API.
Attributes:
client (vLLM): An instance of the vLLM client for text generation.
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/src/doc-summarization/opea_docsum_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import os
import time

from integrations.tgi import OPEADocSum_TGI
from integrations.vllm import OPEADocSum_vLLM
from integrations.tgi import OpeaDocSumTgi
from integrations.vllm import OpeaDocSumvLLM

from comps import (
CustomLogger,
Expand All @@ -21,7 +21,7 @@
logger = CustomLogger("llm_docsum")
logflag = os.getenv("LOGFLAG", False)

llm_component_name = os.getenv("DocSum_COMPONENT_NAME", "OPEADocSum_TGI")
llm_component_name = os.getenv("DocSum_COMPONENT_NAME", "OpeaDocSumTgi")
# Initialize OpeaComponentLoader
loader = OpeaComponentLoader(llm_component_name, description=f"OPEA LLM DocSum Component: {llm_component_name}")

Expand Down
2 changes: 1 addition & 1 deletion comps/llms/src/faq-generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export FAQ_PORT=9000
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export LLM_MODEL_ID=${your_hf_llm_model}
export FAQGen_COMPONENT_NAME="OPEAFAQGen_TGI" # or "vllm"
export FAQGen_COMPONENT_NAME="OpeaFaqGenTgi" # or "vllm"
```

### 1.2 Build Docker Image
Expand Down
4 changes: 2 additions & 2 deletions comps/llms/src/faq-generation/integrations/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_llm_endpoint():
raise ConfigError(f"Input model {MODEL_NAME} not present in model_configs")


class OPEAFAQGen(OpeaComponent):
class OpeaFaqGen(OpeaComponent):
"""A specialized OPEA FAQGen component derived from OpeaComponent.
Attributes:
Expand All @@ -72,7 +72,7 @@ def __init__(self, name: str, description: str, config: dict = None):
self.llm_endpoint = get_llm_endpoint()
health_status = self.check_health()
if not health_status:
logger.error("OPEAFAQGen health check failed.")
logger.error("OpeaFaqGen health check failed.")

async def generate(self, input: LLMParamsDoc, client):
"""Invokes the TGI/vLLM LLM service to generate FAQ output for the provided input.
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/src/faq-generation/integrations/tgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
logflag = os.getenv("LOGFLAG", False)


@OpeaComponentRegistry.register("OPEAFAQGen_TGI")
class OPEAFAQGen_TGI(OPEAFAQGen):
"""A specialized OPEA FAQGen TGI component derived from OPEAFAQGen for interacting with TGI services based on Lanchain HuggingFaceEndpoint API.
@OpeaComponentRegistry.register("OpeaFaqGenTgi")
class OpeaFaqGenTgi(OpeaFaqGen):
"""A specialized OPEA FAQGen TGI component derived from OpeaFaqGen for interacting with TGI services based on Lanchain HuggingFaceEndpoint API.
Attributes:
client (TGI): An instance of the TGI client for text generation.
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/src/faq-generation/integrations/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
logflag = os.getenv("LOGFLAG", False)


@OpeaComponentRegistry.register("OPEAFAQGen_vLLM")
class OPEAFAQGen_vLLM(OPEAFAQGen):
"""A specialized OPEA FAQGen vLLM component derived from OPEAFAQGen for interacting with vLLM services based on Lanchain VLLMOpenAI API.
@OpeaComponentRegistry.register("OpeaFaqGenvLLM")
class OpeaFaqGenvLLM(OpeaFaqGen):
"""A specialized OPEA FAQGen vLLM component derived from OpeaFaqGen for interacting with vLLM services based on Lanchain VLLMOpenAI API.
Attributes:
client (vLLM): An instance of the vLLM client for text generation.
Expand Down
6 changes: 3 additions & 3 deletions comps/llms/src/faq-generation/opea_faqgen_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import os
import time

from integrations.tgi import OPEAFAQGen_TGI
from integrations.vllm import OPEAFAQGen_vLLM
from integrations.tgi import OpeaFaqGenTgi
from integrations.vllm import OpeaFaqGenvLLM

from comps import (
CustomLogger,
Expand All @@ -21,7 +21,7 @@
logger = CustomLogger("llm_faqgen")
logflag = os.getenv("LOGFLAG", False)

llm_component_name = os.getenv("FAQGen_COMPONENT_NAME", "OPEAFAQGen_TGI")
llm_component_name = os.getenv("FAQGen_COMPONENT_NAME", "OpeaFaqGenTgi")
# Initialize OpeaComponentLoader
loader = OpeaComponentLoader(llm_component_name, description=f"OPEA LLM FAQGen Component: {llm_component_name}")

Expand Down
8 changes: 4 additions & 4 deletions comps/llms/src/text-generation/integrations/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,18 @@ def initialize():
initialized = True


@OpeaComponentRegistry.register("OPEATextGen_Native")
class OPEATextGen_Native(OpeaComponent):
@OpeaComponentRegistry.register("OpeaTextGenNative")
class OpeaTextGenNative(OpeaComponent):
"""A specialized OPEA TextGen component derived from OpeaComponent for interacting with LLM services based on native optimum habana."""

def __init__(self, name: str, description: str, config: dict = None):
super().__init__(name, ServiceType.LLM.name.lower(), description, config)
initialize()
health_status = self.check_health()
if not health_status:
logger.error("OPEATextGen_Native health check failed.")
logger.error("OpeaTextGenNative health check failed.")
else:
logger.info("OPEATextGen_Native health check success.")
logger.info("OpeaTextGenNative health check success.")

def check_health(self) -> bool:
"""Checks the health of the LLM service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
logflag = os.getenv("LOGFLAG", False)


@OpeaComponentRegistry.register("OPEATextGen_Predictionguard")
class OPEATextGen_Predictionguard(OpeaComponent):
@OpeaComponentRegistry.register("OpeaTextGenPredictionguard")
class OpeaTextGenPredictionguard(OpeaComponent):
"""A specialized OPEA TextGen component derived from OpeaComponent for interacting with Predictionguard services.
Attributes:
Expand All @@ -28,9 +28,9 @@ def __init__(self, name: str, description: str, config: dict = None):
self.client = PredictionGuard()
health_status = self.check_health()
if not health_status:
logger.error("OPEATextGen_Predictionguard health check failed.")
logger.error("OpeaTextGenPredictionguard health check failed.")
else:
logger.info("OPEATextGen_Predictionguard health check success.")
logger.info("OpeaTextGenPredictionguard health check success.")

def check_health(self) -> bool:
"""Checks the health of the Predictionguard LLM service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def get_llm_endpoint():
raise ConfigError(f"Input model {MODEL_NAME} not present in model_configs")


@OpeaComponentRegistry.register("OPEA_LLM")
class OPEALLM(OpeaComponent):
@OpeaComponentRegistry.register("OpeaTextGenService")
class OpeaTextGenService(OpeaComponent):
"""A specialized OPEA LLM component derived from OpeaComponent for interacting with TGI/vLLM services based on OpenAI API.
Attributes:
Expand All @@ -60,7 +60,7 @@ def __init__(self, name: str, description: str, config: dict = None):
self.client = self._initialize_client()
health_status = self.check_health()
if not health_status:
logger.error("OPEALLM health check failed.")
logger.error("OpeaTextGenService health check failed.")

def _initialize_client(self) -> AsyncOpenAI:
"""Initializes the AsyncOpenAI."""
Expand Down
10 changes: 5 additions & 5 deletions comps/llms/src/text-generation/opea_llm_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
logger = CustomLogger("llm")
logflag = os.getenv("LOGFLAG", False)

llm_component_name = os.getenv("LLM_COMPONENT_NAME", "OPEA_LLM")
llm_component_name = os.getenv("LLM_COMPONENT_NAME", "OpeaTextGenService")
if logflag:
logger.info(f"Get llm_component_name {llm_component_name}")

if llm_component_name == "OPEATextGen_Native":
from integrations.native import OPEATextGen_Native
if llm_component_name == "OpeaTextGenNative":
from integrations.native import OpeaTextGenNative
else:
from integrations.opea import OPEALLM
from integrations.predictionguard import OPEATextGen_Predictionguard
from integrations.predictionguard import OpeaTextGenPredictionguard
from integrations.service import OpeaTextGenService

# Initialize OpeaComponentLoader
loader = OpeaComponentLoader(llm_component_name, description=f"OPEA LLM Component: {llm_component_name}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function start_service() {
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
export MAX_INPUT_TOKENS=2048
export MAX_TOTAL_TOKENS=4096
export DocSum_COMPONENT_NAME="OPEADocSum_TGI" # or "vllm"
export DocSum_COMPONENT_NAME="OpeaDocSumTgi" # or "vllm"
export LOGFLAG=True

cd $WORKPATH/comps/llms/deployment/docker_compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function start_service() {
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
export MAX_INPUT_TOKENS=2048
export MAX_TOTAL_TOKENS=4096
export DocSum_COMPONENT_NAME="OPEADocSum_TGI" # or "vllm"
export DocSum_COMPONENT_NAME="OpeaDocSumTgi" # or "vllm"
export LOGFLAG=True

cd $WORKPATH/comps/llms/deployment/docker_compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function start_service() {
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
export MAX_INPUT_TOKENS=2048
export MAX_TOTAL_TOKENS=4096
export DocSum_COMPONENT_NAME="OPEADocSum_vLLM" # or "vllm"
export DocSum_COMPONENT_NAME="OpeaDocSumvLLM" # or "vllm"
export VLLM_SKIP_WARMUP=true
export LOGFLAG=True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function start_service() {
export HUGGINGFACEHUB_API_TOKEN=${HF_TOKEN} # Remember to set HF_TOKEN before invoking this test!
export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
export FAQGen_COMPONENT_NAME="OPEAFAQGen_TGI"
export FAQGen_COMPONENT_NAME="OpeaFaqGenTgi"
export LOGFLAG=True

cd $WORKPATH/comps/llms/deployment/docker_compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function start_service() {
export HUGGINGFACEHUB_API_TOKEN=${HF_TOKEN} # Remember to set HF_TOKEN before invoking this test!
export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
export FAQGen_COMPONENT_NAME="OPEAFAQGen_TGI"
export FAQGen_COMPONENT_NAME="OpeaFaqGenTgi"
export LOGFLAG=True

cd $WORKPATH/comps/llms/deployment/docker_compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function start_service() {
export HUGGINGFACEHUB_API_TOKEN=${HF_TOKEN} # Remember to set HF_TOKEN before invoking this test!
export LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export LLM_MODEL_ID="Intel/neural-chat-7b-v3-3"
export FAQGen_COMPONENT_NAME="OPEAFAQGen_vLLM"
export FAQGen_COMPONENT_NAME="OpeaFaqGenvLLM"
export VLLM_SKIP_WARMUP=true
export LOGFLAG=True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function start_service() {
-e HABANA_VISIBLE_DEVICES=all \
-e OMPI_MCA_btl_vader_single_copy_mechanism=none \
-e TOKENIZERS_PARALLELISM=false \
-e LLM_COMPONENT_NAME="OPEATextGen_Native" \
-e LLM_COMPONENT_NAME="OpeaTextGenNative" \
--restart unless-stopped \
--network bridge \
opea/llm-textgen-gaudi:comps
Expand Down
2 changes: 1 addition & 1 deletion tests/llms/test_llms_text-generation_predictionguard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function start_service() {
docker run -d --name=test-comps-llm-textgen-pg-server \
-e http_proxy= -e https_proxy= \
-e PREDICTIONGUARD_API_KEY=${PREDICTIONGUARD_API_KEY} \
-e LLM_COMPONENT_NAME="OPEATextGen_Predictionguard" \
-e LLM_COMPONENT_NAME="OpeaTextGenPredictionguard" \
-e LOGFLAG=True \
-p 9000:9000 --ipc=host opea/llm-textgen:comps
sleep 60 # Sleep for 1 minute to allow the service to start
Expand Down

0 comments on commit a65e559

Please sign in to comment.