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