Skip to content

Commit

Permalink
Refactor chathistory based on E-RAG code structure. (#1154)
Browse files Browse the repository at this point in the history
Previously, the code for implementing microservice and functionalities was placed in one folder. Now the microservice and functionalities code have been separated.

Fix [Issue 989](opea-project/GenAIComps#989)

Signed-off-by: Yao, Qing <[email protected]>
  • Loading branch information
yao531441 authored Jan 16, 2025
1 parent c49db2b commit 3802cd8
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker/compose/chathistory-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
services:
chathistory-mongo-server:
build:
dockerfile: comps/chathistory/mongo/Dockerfile
dockerfile: comps/chathistory/src/Dockerfile
image: ${REGISTRY:-opea}/chathistory-mongo-server:${TAG:-latest}
2 changes: 1 addition & 1 deletion comps/chathistory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ The Chat History microservice able to support various database backends for stor

### Chat History with MongoDB

For more detail, please refer to this [README](./mongo/README.md)
For more detail, please refer to this [README](src/README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ COPY comps /home/user/comps
COPY requirements.txt /home/user/

RUN pip install --no-cache-dir --upgrade pip setuptools && \
pip install --no-cache-dir -r /home/user/comps/chathistory/mongo/requirements.txt && \
pip install --no-cache-dir -r /home/user/comps/chathistory/src/requirements.txt && \
pip install --no-cache-dir -r /home/user/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/user/comps/chathistory/mongo
WORKDIR /home/user/comps/chathistory/src

ENTRYPOINT ["python", "chathistory_mongo.py"]
ENTRYPOINT ["python", "opea_chathistory_microservice.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export COLLECTION_NAME=${COLLECTION_NAME}

```bash
cd ../../../../
docker build -t opea/chathistory-mongo-server:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/mongo/Dockerfile .
docker build -t opea/chathistory-mongo-server:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/src/Dockerfile .
```

### Run Docker with CLI
Expand Down
2 changes: 2 additions & 0 deletions comps/chathistory/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import bson.errors as BsonError
from bson.objectid import ObjectId
from config import COLLECTION_NAME
from mongo_conn import MongoClient

from comps.chathistory.src.integrations.mongo.config import COLLECTION_NAME
from comps.chathistory.src.integrations.mongo.mongo_conn import MongoClient


class DocumentStore:
Expand Down
2 changes: 2 additions & 0 deletions comps/chathistory/src/integrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions comps/chathistory/src/integrations/mongo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import Any

import motor.motor_asyncio as motor
from config import DB_NAME, MONGO_HOST, MONGO_PORT

from comps.chathistory.src.integrations.mongo.config import DB_NAME, MONGO_HOST, MONGO_PORT


class MongoClient:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright (C) 2024 Intel Corporation
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
from typing import Optional

from fastapi import HTTPException
from mongo_store import DocumentStore
from pydantic import BaseModel

from comps import CustomLogger
from comps.chathistory.src.document_store import DocumentStore
from comps.cores.mega.micro_service import opea_microservices, register_microservice
from comps.cores.proto.api_protocol import ChatCompletionRequest

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/chathistory/test_chathistory_mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function build_docker_images() {
echo $(pwd)
docker run -d -p 27017:27017 --name=test-comps-mongo mongo:latest

docker build --no-cache -t opea/chathistory-mongo-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/mongo/Dockerfile .
docker build --no-cache -t opea/chathistory-mongo-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/src/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/chathistory-mongo-server built fail"
exit 1
Expand Down

0 comments on commit 3802cd8

Please sign in to comment.