Skip to content

Commit

Permalink
prompt_registry: Unifying API endpoint port (#443)
Browse files Browse the repository at this point in the history
* prompt_registry: Unifying API endpoint port

Unifying all port for API endpoints for prompt registry services with
recent register_microservice wrapper function update.

Signed-off-by: Yeoh, Hoong Tee <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Yeoh, Hoong Tee <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and xiguiw committed Aug 12, 2024
1 parent 9482a75 commit 4cf982c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
10 changes: 5 additions & 5 deletions comps/prompt_registry/mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ docker run -d -p 27017:27017 --name=mongo mongo:latest
2. Run prompt_registry service

```bash
docker run -d --name="promptregistry-mongo-server" -p 6012:6012 -p 6013:6013 -p 6014:6014 -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-mongo-server" -p 6012:6012 -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
```

## Invoke Microservice
Expand All @@ -64,7 +64,7 @@ curl -X 'POST' \

```bash
curl -X 'POST' \
http://{host_ip}:6013/v1/prompt/get \
http://{host_ip}:6012/v1/prompt/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
Expand All @@ -73,7 +73,7 @@ curl -X 'POST' \

```bash
curl -X 'POST' \
http://{host_ip}:6013/v1/prompt/get \
http://{host_ip}:6012/v1/prompt/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
Expand All @@ -84,7 +84,7 @@ curl -X 'POST' \

```bash
curl -X 'POST' \
http://{host_ip}:6013/v1/prompt/get \
http://{host_ip}:6012/v1/prompt/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
Expand All @@ -95,7 +95,7 @@ curl -X 'POST' \

```bash
curl -X 'POST' \
http://{host_ip}:6014/v1/prompt/delete \
http://{host_ip}:6012/v1/prompt/delete \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ services:
container_name: promptregistry-mongo-server
ports:
- "6012:6012"
- "6013:6013"
- "6014:6014"
ipc: host
environment:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
no_proxy: ${no_proxy}
MONGO_HOST: ${MONGO_HOST}
MONGO_PORT: ${MONGO_PORT}
DB_NAME: ${DB_NAME}
COLLECTION_NAME: ${COLLECTION_NAME}
restart: unless-stopped

Expand Down
14 changes: 6 additions & 8 deletions comps/prompt_registry/mongo/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PromptId(BaseModel):


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


@register_microservice(
name="opea_service@prompt_mongo_get",
name="opea_service@prompt_mongo",
endpoint="/v1/prompt/get",
host="0.0.0.0",
input_datatype=PromptId,
port=6013,
port=6012,
)
async def get_prompt(prompt: PromptId):
"""Retrieves prompt from prompt store based on provided PromptId or user.
Expand Down Expand Up @@ -95,11 +95,11 @@ async def get_prompt(prompt: PromptId):


@register_microservice(
name="opea_service@prompt_mongo_delete",
name="opea_service@prompt_mongo",
endpoint="/v1/prompt/delete",
host="0.0.0.0",
input_datatype=PromptId,
port=6014,
port=6012,
)
async def delete_prompt(prompt: PromptId):
"""Delete a prompt from prompt store by given PromptId.
Expand All @@ -125,6 +125,4 @@ async def delete_prompt(prompt: PromptId):


if __name__ == "__main__":
opea_microservices["opea_service@prompt_mongo_get"].start()
opea_microservices["opea_service@prompt_mongo_create"].start()
opea_microservices["opea_service@prompt_mongo_delete"].start()
opea_microservices["opea_service@prompt_mongo"].start()
2 changes: 1 addition & 1 deletion tests/test_prompt_registry_mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function build_docker_images() {

function start_service() {

docker run -d --name="test-comps-promptregistry-mongo-server" -p 6012:6012 -p 6013:6013 -p 6014:6014 -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="test-comps-promptregistry-mongo-server" -p 6012:6012 -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

sleep 10s
}
Expand Down

0 comments on commit 4cf982c

Please sign in to comment.