Skip to content

ableneo/samo

Repository files navigation

ableneo-ChatBot: A RAG-based ChatBot

Python Version Apache 2 License Account X

Installing

Clone the repository:

git clone https://github.com/ableneo/samo

Install Ableneo ChatBot Samo via:

pip install  .

Launching the ChatBot Samo

For demonstration purposes, we have already prepared all the prerequisites. The ChatBot is configured to serve as a helpful Biology assistant. It utilizes information from biological pages on Wikipedia as its knowledge base (data were downloaded from https://commoncrawl.org/). All responses will be in Slovak, so no additional translation is necessary.

Running server

To run chatbot Samo server run::

  1. Duplicate the config.example.yaml file
  2. Fill in all placeholders in the config file
  3. Run the following command::
    ableneo-chatbot server run --config-file <config.yaml>
  4. Run the server

For more information, run:

ableneo-chatbot server --help

Initialize Knowledge-Base

If you would like to use your data in your ChatBot system, follow these steps:

  1. Remove the ./db folder
  2. Copy your *.txt data to the ./data folder
  3. Run the following command:
    ableneo-chatbot knowledge-base init --data-root './data' --data-type '.txt' --config-file './config.yaml' --encoding 'utf-8'

For more information, run::

ableneo-chatbot knowledge-base --help

Endpoints

GET /health

Request

curl -i --request GET 'http://127.0.0.1:6628/health'
Response
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.11.9
Date: Thu, 06 Jun 2024 15:41:15 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2
Access-Control-Allow-Origin: *
Connection: close

OK

GET /version

Request

curl -i --request GET 'http://127.0.0.1:6628/version'
Response
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.11.9
Date: Thu, 06 Jun 2024 15:41:48 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 5
Access-Control-Allow-Origin: *
Connection: close

0.1.1

POST /v1/chatbot/prompt

Request

GET /version

curl -i --request POST 'http://127.0.0.1:6628/v1/chatbot/prompt' \
--header 'Content-Type: application/json' \
--data '{
    "chat_id": "abb99ff0-22ad-4992-ac54-997b95ebbc11",
    "chat_history": [],
    "question": "Koľko mláďat ročne má Myšiarka ušatá?"
}'
Response
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.11.9
Date: Thu, 06 Jun 2024 16:12:54 GMT
Content-Type: text/plain; charset=utf-8
Access-Control-Allow-Origin: *
Transfer-Encoding: chunked
Connection: close

Myšiarka ušatá (Asio otus) kladie 3 až 7 svetlých vajec ročne.

Zdroj: <a href='data\\mysiarka_usata.txt'>data\\mysiarka_usata.txt</a>

POST /v1/chatbot/history

Request

curl -i --request POST 'http://127.0.0.1:6628/v1/chatbot/history' \
--header 'Content-Type: application/json' \
--data '{"chat_id": "abb99ff0-22ad-4992-ac54-997b95ebbc11"}'
Response
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.11.9
Date: Thu, 06 Jun 2024 16:14:26 GMT
Content-Type: application/json
Content-Length: 259
Access-Control-Allow-Origin: *
Connection: close

[{"role": "user", "content": "Koľko mláďat ročne má Myšiarka ušatá?"}, {"role": "assistant", "content": "Myšiarka ušatá (Asio otus) kladie 3 až 7 svetlých vajec ročne. <a href='data\\mysiarka_usata.txt'>data\\mysiarka_usata.txt</a>"}]

POST /v1/chatbot/feedback

Request

curl -i --request POST 'http://127.0.0.1:6628/v1/chatbot/feedback' \
--header 'Content-Type: application/json' \
--data '{
    "chat_id": "abb99ff0-22ad-4992-ac54-997b95ebbc11",
    "chat_history": [],
    "question": "Koľko mláďat ročne má Myšiarka ušatá?",
    "feedback": "Správne",
    "answer": "Myšiarka ušatá (Asio otus) kladie 3 až 7 svetlých vajec ročne. <a href='\''data\\mysiarka_usata.txt'\''>data\\mysiarka_usata.txt</a>",
    "reporter": "učiteľ"
}'
Response
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.11.9
Date: Thu, 06 Jun 2024 16:21:00 GMT
Content-Type: application/json
Content-Length: 22
Access-Control-Allow-Origin: *
Connection: close

{"message": "success"}

Development

If you would like to customize the source code, you can install all development dependencies via:

pip install -e .[dev]

About Ableneo

Read our blog

Our website

https://www.ableneo.com

Contact

For more information, contact:

About

Ableneo Chat built on top of a RAG concept.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published