Skip to content

Commit

Permalink
Added unified ports for Chat History Microservice. (#449)
Browse files Browse the repository at this point in the history
* Added unified ports

Signed-off-by: Yogesh <[email protected]>

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

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

* Added unified ports for compose

Signed-off-by: Yogesh <[email protected]>

---------

Signed-off-by: Yogesh <[email protected]>
Co-authored-by: Yogesh <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 10, 2024
1 parent 0614fc2 commit 2098b91
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions comps/chathistory/mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ curl -X 'POST' \

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

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

```bash
curl -X 'POST' \
http://${host_ip}:6014/v1/chathistory/delete \
http://${host_ip}:6012/v1/chathistory/delete \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
Expand Down
14 changes: 6 additions & 8 deletions comps/chathistory/mongo/chathistory_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_first_string(value):


@register_microservice(
name="opea_service@chathistory_mongo_create",
name="opea_service@chathistory_mongo",
endpoint="/v1/chathistory/create",
host="0.0.0.0",
input_datatype=ChatMessage,
Expand Down Expand Up @@ -70,11 +70,11 @@ async def create_documents(document: ChatMessage):


@register_microservice(
name="opea_service@chathistory_mongo_get",
name="opea_service@chathistory_mongo",
endpoint="/v1/chathistory/get",
host="0.0.0.0",
input_datatype=ChatId,
port=6013,
port=6012,
)
async def get_documents(document: ChatId):
"""Retrieves documents from the document store based on the provided ChatId.
Expand All @@ -100,11 +100,11 @@ async def get_documents(document: ChatId):


@register_microservice(
name="opea_service@chathistory_mongo_delete",
name="opea_service@chathistory_mongo",
endpoint="/v1/chathistory/delete",
host="0.0.0.0",
input_datatype=ChatId,
port=6014,
port=6012,
)
async def delete_documents(document: ChatId):
"""Deletes a document from the document store based on the provided ChatId.
Expand All @@ -130,6 +130,4 @@ async def delete_documents(document: ChatId):


if __name__ == "__main__":
opea_microservices["opea_service@chathistory_mongo_get"].start()
opea_microservices["opea_service@chathistory_mongo_create"].start()
opea_microservices["opea_service@chathistory_mongo_delete"].start()
opea_microservices["opea_service@chathistory_mongo"].start()
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ services:
container_name: chathistory-mongo-server
ports:
- "6012:6012"
- "6013:6013"
- "6014:6014"
ipc: host
environment:
http_proxy: ${http_proxy}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_chathistory_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-chathistory-mongo-server" -p 6013:6013 -p 6012:6012 -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/chathistory-mongo-server:comps
docker run -d --name="test-comps-chathistory-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/chathistory-mongo-server:comps

sleep 10s
}
Expand Down

0 comments on commit 2098b91

Please sign in to comment.