|
| 1 | +# 📝 Chat History Microservice with ArangoDB |
| 2 | + |
| 3 | +This README provides setup guides and all the necessary information about the Chat History microservice with ArangoDB database. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Setup Environment Variables |
| 8 | + |
| 9 | +```bash |
| 10 | +export http_proxy=${your_http_proxy} |
| 11 | +export https_proxy=${your_http_proxy} |
| 12 | +export OPEA_STORE_NAME="arangodb" |
| 13 | +export ARANGODB_HOST="http://localhost:8529" |
| 14 | +export ARANGODB_USERNAME="root" |
| 15 | +export ARANGODB_PASSWORD="${YOUR_ARANGO_PASSWORD}" |
| 16 | +export ARANGODB_ROOT_PASSWORD="${YOUR_ARANGO_ROOT_PASSWORD}" |
| 17 | +export ARANGODB_DB_NAME="${YOUR_ARANGODB_DB_NAME-_system}" |
| 18 | +export ARANGODB_COLLECTION_NAME="${YOUR_ARANGODB_COLLECTION_NAME-default}" |
| 19 | +export ENABLE_MCP=false # Set to true to enable MCP support |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 🚀 Start Microservice with Docker (Option 1) |
| 25 | + |
| 26 | +### Build Docker Image |
| 27 | + |
| 28 | +```bash |
| 29 | +cd ../../../../ |
| 30 | +docker build -t opea/chathistory:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/chathistory/src/Dockerfile . |
| 31 | +``` |
| 32 | + |
| 33 | +### Run Docker with CLI |
| 34 | + |
| 35 | +- Run ArangoDB image container |
| 36 | + |
| 37 | + ```bash |
| 38 | + docker run -d -p 8529:8529 --name=arango-vector-db -e ARANGO_ROOT_PASSWORD=${ARANGO_ROOT_PASSWORD} arangodb/arangodb:latest |
| 39 | + ``` |
| 40 | + |
| 41 | +- Run the Chat History microservice |
| 42 | + |
| 43 | + ```bash |
| 44 | + docker run -d --name="chathistory-arango-server" -p 6012:6012 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e ARANGODB_HOST=${ARANGODB_HOST} -e ARANGODB_USERNAME=${ARANGODB_USERNAME} -e ARANGODB_PASSWORD=${ARANGODB_PASSWORD} -e ARANGODB_DB_NAME=${ARANGODB_DB_NAME} -e ARANGODB_COLLECTION_NAME=${ARANGODB_COLLECTION_NAME} -e ENABLE_MCP=${ENABLE_MCP} opea/chathistory:latest |
| 45 | + ``` |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## 🚀 Start Microservice with Docker Compose (Option 2) |
| 50 | + |
| 51 | +```bash |
| 52 | +docker compose -f ../deployment/docker_compose/compose.yaml up -d chathistory-arango |
| 53 | +``` |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## ✅ Invoke Microservice |
| 58 | + |
| 59 | +The Chat History microservice exposes the following API endpoints: |
| 60 | + |
| 61 | +- Create new chat conversation |
| 62 | + |
| 63 | + ```bash |
| 64 | + curl -X 'POST' \ |
| 65 | + http://${host_ip}:6012/v1/chathistory/create \ |
| 66 | + -H 'accept: application/json' \ |
| 67 | + -H 'Content-Type: application/json' \ |
| 68 | + -d '{ |
| 69 | + "data": { |
| 70 | + "messages": "test Messages", "user": "test" |
| 71 | + } |
| 72 | + }' |
| 73 | + ``` |
| 74 | + |
| 75 | +- Get all the Conversations for a user |
| 76 | + |
| 77 | + ```bash |
| 78 | + curl -X 'POST' \ |
| 79 | + http://${host_ip}:6012/v1/chathistory/get \ |
| 80 | + -H 'accept: application/json' \ |
| 81 | + -H 'Content-Type: application/json' \ |
| 82 | + -d '{ |
| 83 | + "user": "test"}' |
| 84 | + ``` |
| 85 | + |
| 86 | +- Get a specific conversation by id. |
| 87 | + |
| 88 | + ```bash |
| 89 | + curl -X 'POST' \ |
| 90 | + http://${host_ip}:6012/v1/chathistory/get \ |
| 91 | + -H 'accept: application/json' \ |
| 92 | + -H 'Content-Type: application/json' \ |
| 93 | + -d '{ |
| 94 | + "user": "test", "id":"YOU_COLLECTION_NAME/YOU_DOC_KEY"}' |
| 95 | + ``` |
| 96 | + |
| 97 | +- Update the conversation by id. |
| 98 | + |
| 99 | + ```bash |
| 100 | + curl -X 'POST' \ |
| 101 | + http://${host_ip}:6012/v1/chathistory/create \ |
| 102 | + -H 'accept: application/json' \ |
| 103 | + -H 'Content-Type: application/json' \ |
| 104 | + -d '{ |
| 105 | + "data": { |
| 106 | + "messages": "test Messages Update", "user": "test" |
| 107 | + }, |
| 108 | + "id":"YOU_COLLECTION_NAME/YOU_DOC_KEY" |
| 109 | + }' |
| 110 | + ``` |
| 111 | + |
| 112 | +- Delete a stored conversation. |
| 113 | + |
| 114 | + ```bash |
| 115 | + curl -X 'POST' \ |
| 116 | + http://${host_ip}:6012/v1/chathistory/delete \ |
| 117 | + -H 'accept: application/json' \ |
| 118 | + -H 'Content-Type: application/json' \ |
| 119 | + -d '{ |
| 120 | + "user": "test", "id":"YOU_COLLECTION_NAME/YOU_DOC_KEY"}' |
| 121 | + ``` |
0 commit comments