Skip to content

Commit

Permalink
Refine README for chat history, feedback management and prompt regist…
Browse files Browse the repository at this point in the history
…ry microservice (#727)

* [chat_history]: Refine README documentation

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

* [feedback_management]: Refine README documentation

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

* [prompt_registry]: Refine README documentation

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

* Fix readme typo

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
hteeyeoh and pre-commit-ci[bot] authored Sep 24, 2024
1 parent 1f57d07 commit 9d566be
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 280 deletions.
26 changes: 26 additions & 0 deletions comps/chathistory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 📝 Chat History Microservice

The Chat History Microservice is a scalable solution for storing, retrieving and managing chat conversations using various type of databases. This microservice is designed to seamlessly integrate with OPEA chat applications, enabling data persistence and efficient management of chat histories.

It can be integrated into application by making HTTP requests to the provided API endpoints as shown in the flow diagram below.

![Flow Chart](./assets/img/chathistory_flow.png)

---

## 🛠️ Features

- **Store Chat Conversations**: Save chat messages user information, and metadata associated with each conversation.
- **Retrieve Chat Histories**: Fetch chat histories for a specific user or retrieve a particular conversation by its unique identifier.
- **Update Chat Conversations**: Modify existing chat conversations by adding new messages or updating existing ones.
- **Delete Chat Conversations**: Remove chat conversations record from database.

---

## ⚙️ Implementation

The Chat History microservice able to support various database backends for storing the chat conversations.

### Chat History with MongoDB

For more detail, please refer to this [README](./mongo/README.md)
144 changes: 74 additions & 70 deletions comps/chathistory/mongo/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Chat History Microservice
# 📝 Chat History Microservice with MongoDB

The Chat History Microservice allows you to store, retrieve and manage chat conversations with a MongoDB database. This microservice can be used for data persistence in OPEA chat applications, enabling you to save and access chat histories.
This README provides setup guides and all the necessary information about the Chat History microservice with MongoDB database.

It can be integrated into any application by making HTTP requests to the provided API endpoints as shown in the flow diagram below.

![Flow Chart](./assets/img/chathistory_flow.png)
---

## Setup Environment Variables

Expand All @@ -17,6 +15,8 @@ export DB_NAME=${DB_NAME}
export COLLECTION_NAME=${COLLECTION_NAME}
```

---

## 🚀Start Microservice with Docker

### Build Docker Image
Expand All @@ -28,78 +28,82 @@ docker build -t opea/chathistory-mongo-server:latest --build-arg https_proxy=$ht

### Run Docker with CLI

- Run mongoDB image

```bash
docker run -d -p 27017:27017 --name=mongo mongo:latest
```
- Run MongoDB image container

- Run the chathistory Service
```bash
docker run -d -p 27017:27017 --name=mongo mongo:latest
```

```bash
docker run -d --name="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:latest
```

## Invoke Microservice

Once chathistory service is up and running, users can update the database by using the below API endpoint. The API returns a unique UUID for the saved conversation.

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/create \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"messages": "test Messages", "user": "test"
}
}'
```
- Run the Chat History microservice

- Get all the Conversations for a user
```bash
docker run -d --name="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:latest
```

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "test"}'
```
---

- Get specific conversation by specifying the id.
## ✅ Invoke Microservice

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "test", "id":"668620173180b591e1e0cd74"}'
```
The Chat History microservice exposes the following API endpoints:

- Update the conversation by specifying the id.
- Create new chat conversation

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/create \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"messages": "test Messages Update", "user": "test"
},
"id":"668620173180b591e1e0cd74"
}'
```
```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/create \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"messages": "test Messages", "user": "test"
}
}'
```

- Delete a stored conversation by specifying the id.
- Get all the Conversations for a user

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/delete \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "test", "id":"668620173180b591e1e0cd74"}'
```
```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "test"}'
```

- Get a specific conversation by id.

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/get \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "test", "id":"668620173180b591e1e0cd74"}'
```

- Update the conversation by id.

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/create \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"messages": "test Messages Update", "user": "test"
},
"id":"668620173180b591e1e0cd74"
}'
```

- Delete a stored conversation.

```bash
curl -X 'POST' \
http://${host_ip}:6012/v1/chathistory/delete \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"user": "test", "id":"668620173180b591e1e0cd74"}'
```
22 changes: 22 additions & 0 deletions comps/feedback_management/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 🗨 Feedback Management Microservice

The Feedback Management microservice facilitates the storage and retrieval of users'feedback data by establishing a connection with the databases. This microservice is designed to seamlessly integrate with OPEA applications, enabling data persistence and efficient management of feedback data.

---

## 🛠️ Features

- **Store Feedback**: Save feedback data from user into database.
- **Retrieve Feedback**: Fetch feedback data from database based on user or id.
- **Update Feedback**: Update feedback data info in the database based on id.
- **Delete Feedback**: Remove feedback record from database.

---

## ⚙️ Implementation

The Feedback Management microservice able to support various database backends for storing the feedback data.

### Feedback Management with MongoDB

For more detail, please refer to this [README](./mongo/README.md)
Loading

0 comments on commit 9d566be

Please sign in to comment.