
Clone the repository:
git clone https://github.com/open-kf/smart-qa-service.git && cd smart-qa-service
Before starting the OpenKF service, you need to modify the related configurations for the program to initialize correctly.
cp env_template .env
The variables in .env
DISKCACHE_DIR="diskcache_dir"
SQLITE_DB_DIR="sqlite_dir"
SQLITE_DB_NAME="mydatabase.sqlite3"
MAX_CRAWL_PARALLEL_REQUEST=5
CHROMA_DB_DIR="chroma_dir"
CHROMA_COLLECTION_NAME="mychroma_collection"
OPENAI_API_KEY="xxxx"
GPT_MODEL_NAME="gpt-3.5-turbo"
OPENAI_EMBEDDING_MODEL_NAME="text-embedding-3-small"
MAX_QUERY_SIZE=200
RECALL_TOP_K=3
MAX_HISTORY_QUERY_SIZE=5
HISTORY_EXPIRE_TIME=10800
MAX_EMBEDDING_INPUT=2048
SITE_TITLE="your site title"
STATIC_DIR="web"
URL_PREFIX="http://your-server-ip:7000/"
MEDIA_DIR="media_dir"
- Modify
OPENAI_API_KEY
to your own key, which can be obtained by logging into the OpenAI dashboard: - Modify
SITE_TITLE
to your website's name. - Modify
URL_PREFIX
according to your website's domain.
docker-compose up --build
It is recommended to install Python-related dependencies in a Python virtual environment to avoid affecting dependencies of other projects.
If you have not yet created a virtual environment, you can create one with the following command:
python3 -m venv myenv
After creation, activate the virtual environment:
source myenv/bin/activate
Once the virtual environment is activated, you can use pip
to install the required dependencies.
pip install -r requirements.txt
The OpenKF service uses SQLite as its storage DB. Before starting the OpenKF service, you need to execute the following command to initialize the database and add the default configuration for admin console.
python3 create_sqlite_db.py
If you have completed the steps above, you can try to start the OpenKF service by executing the following command.
- Start single process:
python smart_qa_app.py
- Start multiple processes:
sh start.sh
Note
- The service port for OpenKF is
7000
. During the first test, please try not to change the port so that you can quickly experience the entire product process. - We recommend starting the OpenKF service using
start.sh
in multi-process mode for a smoother user experience.
Access the admin console through the link http://your-server-ip:7000/open-kf-admin/
to reach the login page. The default username and password are admin
and open_kf_AIGC@2024
(can be checked in create_sqlite_db.py
).
After logging in successfully, you will be able to see the configuration page of the admin console.
On the page http://your-server-ip:7000/open-kf-admin/#/
, you can set the following configurations:
- Choose the LLM base, currently only the
gpt-3.5-turbo
option is available, which will be gradually expanded. - Initial Messages
- Suggested Messages
- Message Placeholder
- Profile Picture (upload a picture)
- Display name
- Chat icon (upload a picture)
After submitting the website URL, once the server retrieves the list of all web page URLs via crawling, you can select the web page URLs you need as the knowledge base (all selected by default).
You can actively refresh the page http://your-server-ip:7000/open-kf-admin/#/source
in your browser to get the progress of web page URL processing. After the content of theweb page URL has been crawled, and the Embedding calculation and storage are completed, you can see the corresponding Size
in the admin console, and the Status
will also be updated to Stored
.
After importing website data in the admin console, you can experience the chatbot service through the link http://your-server-ip:7000/open-kf-chatbot/
.
Through the admin console link http://your-server-ip:7000/open-kf-admin/#/embed
, you can see the detailed tutorial for configuring the iframe in your website.
Through the admin console link http://your-server-ip:7000/open-kf-admin/#/dashboard
, you can view the historical request records of all users within a specified time range.
The OpenKF service integrates 2 frontend modules, and their source code information is as follows:
An intuitive web-based admin interface for Smart QA Service, offering comprehensive control over content, configuration, and user interactions. Enables effortless management of the knowledge base, real-time monitoring of queries and feedback, and continuous improvement based on user insights.
An HTML5 interface for Smart QA Service designed for easy integration into websites via iframe, providing users direct access to a tailored knowledge base without leaving the site, enhancing functionality and immediate query resolution.