pankb_llm
pankb_llm
基於 Langchain + Streamlit + Azure Cosmos DB for MongoDB (vCore) + Docker 的 GenAI 助理。
作者:
在 Linux Ubuntu 20.04 上測試(可能需要針對其他系統進行調整)。
僅用於 AI Assistant 應用部署和向量資料庫建立的最低硬體要求(不包括 PanKB DB、ETL 和 AI Assistant 應用程式):
系統需求:
DB 填充過程可能需要長達 90-150 分鐘。這取決於 DEV 伺服器和 Cosmos DB 分片叢集配置。填充集合的 MongoDB 儲存大小約為 1.0 GiB,包括。索引。
請注意以下限制和注意事項:
按以下格式建立 .env 檔案:
## 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>"
資料庫填充腳本不必在 Docker 容器中執行。可以使用以下命令來完成:
# 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
用於建置 docker 映像並重新建立包含 Streamlit 應用程式的 docker 容器的命令:
docker compose up -d --build --force-recreate
dockerized Streamlit 應用程式不必在tmux中執行。即使虛擬機器重新啟動後,它也將始終啟動並運行(透過使用 docker compose 檔案中的選項restart: always
來實現)。
可以使用以下命令檢查 docker 容器的狀態:
docker ps
該命令應該產生大約。如果部署成功,將輸出以下內容:
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