pankb_llm
pankb_llm
Langchain + Streamlit + Azure Cosmos DB for MongoDB (vCore) + Docker に基づく GenAI アシスタント。
著者:
Linux Ubuntu 20.04 でテスト済み (他のシステムでは調整が必要な場合があります)。
AI アシスタント アプリの展開と Vector データベースの作成のみの最小ハードウェア要件 (PanKB DB、ETL、および AI アシスタント アプリを除く):
システム要件:
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>"
DB 作成スクリプトは、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
Docker 化された streamlit アプリはtmuxで実行する必要はありません。 VM が再起動された後でも、常に稼働し続けます (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