Skip to content

Commit

Permalink
Refactor prompt registry
Browse files Browse the repository at this point in the history
Signed-off-by: lvliang-intel <[email protected]>
  • Loading branch information
lvliang-intel committed Jan 2, 2025
1 parent 2cfd014 commit 2deac8a
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker/compose/prompt_registry-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:
promptregistry-mongo-server:
promptregistry-server:
build:
dockerfile: comps/prompt_registry/mongo/Dockerfile
image: ${REGISTRY:-opea}/promptregistry-mongo-server:${TAG:-latest}
dockerfile: comps/prompt_registry/src/Dockerfile
image: ${REGISTRY:-opea}/promptregistry-server:${TAG:-latest}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:

promptregistry-mongo:
image: opea/promptregistry-mongo:latest
container_name: promptregistry-mongo-server
container_name: promptregistry-server
ports:
- "6018:6018"
ipc: host
Expand Down
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export COLLECTION_NAME=${COLLECTION_NAME}

```bash
cd ~/GenAIComps
docker build -t opea/promptregistry-mongo-server:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/prompt_registry/mongo/Dockerfile .
docker build -t opea/promptregistry-server:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/prompt_registry/mongo/Dockerfile .
```

### Run Docker with CLI
Expand All @@ -37,7 +37,7 @@ docker build -t opea/promptregistry-mongo-server:latest --build-arg https_proxy=
- Run Prompt Registry microservice

```bash
docker run -d --name="promptregistry-mongo-server" -p 6018:6018 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e MONGO_HOST=${MONGO_HOST} -e MONGO_PORT=${MONGO_PORT} -e DB_NAME=${DB_NAME} -e COLLECTION_NAME=${COLLECTION_NAME} opea/promptregistry-mongo-server:latest
docker run -d --name="promptregistry-server" -p 6018:6018 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e MONGO_HOST=${MONGO_HOST} -e MONGO_PORT=${MONGO_PORT} -e DB_NAME=${DB_NAME} -e COLLECTION_NAME=${COLLECTION_NAME} opea/promptregistry-server:latest
```

---
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import os
from typing import Optional

from mongo_store import PromptStore
from prompt_store import PromptStore
from pydantic import BaseModel

from comps import CustomLogger
from comps.cores.mega.micro_service import opea_microservices, register_microservice

logger = CustomLogger("prompt_mongo")
logger = CustomLogger("prompt_registry")
logflag = os.getenv("LOGFLAG", False)


Expand Down Expand Up @@ -39,7 +39,7 @@ class PromptId(BaseModel):


@register_microservice(
name="opea_service@prompt_mongo",
name="opea_service@prompt",
endpoint="/v1/prompt/create",
host="0.0.0.0",
input_datatype=PromptCreate,
Expand Down Expand Up @@ -70,7 +70,7 @@ async def create_prompt(prompt: PromptCreate):


@register_microservice(
name="opea_service@prompt_mongo",
name="opea_service@prompt",
endpoint="/v1/prompt/get",
host="0.0.0.0",
input_datatype=PromptId,
Expand Down Expand Up @@ -106,7 +106,7 @@ async def get_prompt(prompt: PromptId):


@register_microservice(
name="opea_service@prompt_mongo",
name="opea_service@prompt",
endpoint="/v1/prompt/delete",
host="0.0.0.0",
input_datatype=PromptId,
Expand Down Expand Up @@ -140,4 +140,4 @@ async def delete_prompt(prompt: PromptId):


if __name__ == "__main__":
opea_microservices["opea_service@prompt_mongo"].start()
opea_microservices["opea_service@prompt"].start()
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ def __init__(
):
self.user = user

def initialize_storage(self) -> None:
self.db_client = MongoClient.get_db_client()
def initialize_storage(self, db_type="mongo") -> None:
if db_type == "mongo":
self.db_client = MongoClient.get_db_client()
self.collection = self.db_client[COLLECTION_NAME]

async def save_prompt(self, prompt) -> str:
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions tests/prompt_registry/test_prompt_registry_mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ function build_docker_images() {
echo $(pwd)
docker run -d -p 27017:27017 --name=test-comps-mongo mongo:latest

docker build --no-cache -t opea/promptregistry-mongo-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/prompt_registry/mongo/Dockerfile .
docker build --no-cache -t opea/promptregistry-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/prompt_registry/mongo/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/promptregistry-mongo-server built fail"
echo "opea/promptregistry-server built fail"
exit 1
else
echo "opea/promptregistry-mongo-server built successful"
echo "opea/promptregistry-server built successful"
fi
}

function start_service() {

docker run -d --name="test-comps-promptregistry-mongo-server" -p 6018:6018 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e MONGO_HOST=${MONGO_HOST} -e MONGO_PORT=${MONGO_PORT} -e DB_NAME=${DB_NAME} -e COLLECTION_NAME=${COLLECTION_NAME} opea/promptregistry-mongo-server:comps
docker run -d --name="test-comps-promptregistry-server" -p 6018:6018 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e MONGO_HOST=${MONGO_HOST} -e MONGO_PORT=${MONGO_PORT} -e DB_NAME=${DB_NAME} -e COLLECTION_NAME=${COLLECTION_NAME} opea/promptregistry-server:comps

sleep 10s
}
Expand All @@ -46,7 +46,7 @@ function validate_microservice() {
echo "Correct result."
else
echo "Incorrect result."
docker logs test-comps-promptregistry-mongo-server
docker logs test-comps-promptregistry-server
exit 1
fi

Expand Down

0 comments on commit 2deac8a

Please sign in to comment.