Asisten GenAI berdasarkan Langchain + Streamlit + Azure Cosmos DB untuk MongoDB (vCore) + Docker.
Penulis:
Diuji di Linux Ubuntu 20.04 (mungkin memerlukan penyesuaian untuk sistem lain).
Persyaratan perangkat keras minimum hanya untuk penerapan Aplikasi Asisten AI dan pembuatan database Vektor (tidak termasuk aplikasi PanKB DB, ETL, dan Asisten AI):
Persyaratan sistem:
Proses populasi DB dapat memakan waktu hingga 90-150 menit. Hal ini bergantung pada server DEV dan konfigurasi klaster sharded Cosmos DB. Ukuran penyimpanan MongoDB koleksi yang diisi adalah ~ 1,0 GiB, termasuk. indeks.
Harap perhatikan batasan dan pertimbangan berikut:
Buat file .env dalam format berikut:
## Do not put this file under version control!
OPENAI_API_KEY=<insert the API key here without quotes>
COHERE_API_KEY=<insert the API key here without quotes>
TOGETHER_API_KEY=<insert the API key here without quotes>
GOOGLE_API_KEY=<insert the API key here without quotes>
ANTHROPIC_API_KEY=<insert the API key here without quotes>
REPLICATE_API_TOKEN=<insert the API key here without quotes>
VOYAGE_API_KEY=<insert the API key here without quotes>
## MongoDB-PROD (Azure Cosmos DB for MongoDB) Connection String
# Had to multiply maxIdleTimeMS by 10 to handle
# urllib3.exceptions.ProtocolError:
# ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))
MONGODB_CONN_STRING = "<insert the connection string here with quotes>"
Skrip populasi DB tidak harus dijalankan dalam kontainer buruh pelabuhan. Hal ini dapat dilakukan dengan perintah berikut:
# install all the requirements and dependencies
pip3 install -r requirements.txt
# Run the script with two command line arguments:
# the name of the folder containing the documents to feed to the LLM
# and
# the name of the MongoDB collection that will contain the vector DB
python3 make_vectordb.py ./Paper_all pankb_vector_store
Perintah untuk membuat image buruh pelabuhan dan membuat ulang kontainer buruh pelabuhan dengan aplikasi Streamlit di dalamnya:
docker compose up -d --build --force-recreate
Aplikasi streamlit yang di-docker tidak harus dijalankan di tmux . Itu akan selalu aktif dan berjalan bahkan setelah VM di-boot ulang (dicapai dengan menggunakan opsi restart: always
dalam file penulisan buruh pelabuhan).
Status container buruh pelabuhan dapat diperiksa dengan perintah berikut:
docker ps
Perintah tersebut harus menghasilkan kira-kira. output berikut antara lain jika penerapan berhasil:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54d89d7c4fad pankb_llm:latest "streamlit run strea…" 10 minutes ago Up 10 minutes 0.0.0.0:8501->8501/tcp, :::8501->8501/tcp pankb-llm