diff --git a/README.md b/README.md index 5db8f26861..85221a6bb1 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,26 @@ class ExampleService: self.megaservice.flow_to(embedding, llm) ``` +self.gateway = ChatQnAGateway(megaservice=self.megaservice, host="0.0.0.0", port=self.port) + +```` + +## Check Mega/Micro Service health status and version number + +Use below command to check Mega/Micro Service status. + +```bash +curl http://${your_ip}:${service_port}/v1/health_check\ + -X GET \ + -H 'Content-Type: application/json' +```` + +Users should get output like below example if Mega/Micro Service works correctly. + +```bash +{"Service Title":"ChatQnAGateway/MicroService","Version":"1.0","Service Description":"OPEA Microservice Infrastructure"} +``` + ## Contributing to OPEA Welcome to the OPEA open-source community! We are thrilled to have you here and excited about the potential contributions you can bring to the OPEA platform. Whether you are fixing bugs, adding new GenAI components, improving documentation, or sharing your unique use cases, your contributions are invaluable. diff --git a/comps/cores/mega/http_service.py b/comps/cores/mega/http_service.py index 2b5a472f70..80ad472960 100644 --- a/comps/cores/mega/http_service.py +++ b/comps/cores/mega/http_service.py @@ -72,7 +72,9 @@ def _create_app(self): ) async def _health_check(): """Get the health status of this GenAI microservice.""" - return {"Service Title": self.title, "Service Description": self.description} + from comps.version import __version__ + + return {"Service Title": self.title, "Version": __version__, "Service Description": self.description} @app.get("/health") async def _health() -> Response: diff --git a/tests/cores/mega/test_microservice.py b/tests/cores/mega/test_microservice.py index b621dda5ae..a92408cbb0 100644 --- a/tests/cores/mega/test_microservice.py +++ b/tests/cores/mega/test_microservice.py @@ -47,7 +47,8 @@ def test_add_route(self): response = self.client.get("/v1/health_check") self.assertEqual( - response.json(), {"Service Title": "s1", "Service Description": "OPEA Microservice Infrastructure"} + response.json(), + {"Service Title": "s1", "Version": "1.2", "Service Description": "OPEA Microservice Infrastructure"}, ) response = self.client.get("/v1/sum")