Skip to content

Commit

Permalink
prompt_registry: Unifying API endpoint port
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hteeyeoh committed Aug 9, 2024
1 parent 8f0f2b0 commit c812750
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 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
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 c812750

Please sign in to comment.