diff --git a/privategpt/Dockerfile b/privategpt/Dockerfile index 9685baf..4cc36a3 100644 --- a/privategpt/Dockerfile +++ b/privategpt/Dockerfile @@ -73,7 +73,12 @@ RUN touch /VERSION && \ # Setup environment ENV KEEP_FILES="False" \ - PGPT_HF_MODEL_FILE="" \ + PROMPT_STYLE="mistral" \ + PGPT_HF_MODEL_FILE="mistral-7b-instruct-v0.2.Q4_K_M.gguf" \ + EMBEDDING_HF_MODEL_NAME="BAAI/bge-small-en-v1.5" \ + TOKENIZER="mistralai/Mistral-7B-Instruct-v0.2" \ + MAX_NEW_TOKENS="512" \ + CONTEXT_WINDOW="3900" \ LOGO_BG_COLOR="#C7BAFF" \ LOGO_HEIGHT="25%" \ LOGO_SVG_BASE64="PHN2ZyB3aWR0aD0iODYxIiBoZWlnaHQ9Ijk4IiB2aWV3Qm94PSIwIDAgODYxIDk4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNDguMTM0NSAwLjE1NzkxMUMzNi44Mjk5IDEuMDM2NTQgMjYuMTIwNSA1LjU1MzI4IDE3LjYyNTYgMTMuMDI1QzkuMTMwNDYgMjAuNDk2NyAzLjMxMTcgMzAuNTE2OSAxLjA0OTUyIDQxLjU3MDVDLTEuMjEyNzMgNTIuNjIzOCAwLjIwNDQxOSA2NC4xMDk0IDUuMDg2MiA3NC4yOTA1QzkuOTY4NjggODQuNDcxNiAxOC4wNTAzIDkyLjc5NDMgMjguMTA5OCA5OEwzMy43MDI2IDgyLjU5MDdMMzUuNDU0MiA3Ny43NjU2QzI5LjgzODcgNzQuMTY5MiAyNS41NDQ0IDY4Ljg2MDcgMjMuMjE0IDYyLjYzNDRDMjAuODgyMiA1Ni40MDg2IDIwLjYzOSA0OS41OTkxIDIyLjUyMDQgNDMuMjI0M0MyNC40MDI5IDM2Ljg0OTUgMjguMzA5NiAzMS4yNTI1IDMzLjY1NjEgMjcuMjcwNkMzOS4wMDIg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aGVpZ2h0PSI3NC44NjExIiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTUyLjQ0NCAxMi4yNSkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K" diff --git a/privategpt/README.md b/privategpt/README.md index abf9998..057bafd 100644 --- a/privategpt/README.md +++ b/privategpt/README.md @@ -75,7 +75,12 @@ services: ### 2 Environment Variables - `KEEP_FILES` - Specifies if the server should keep uploaded files after restarting the container - **True /False, Default: False** +- `PROMPT_STYLE` - Specifies which prompt style is being used - **Default: mistral** - `PGPT_HF_MODEL_FILE` - Specifies the llm model. If set, you need to mount your own llm to /home/worker/app/models - **Default: mistral-7b-instruct-v0.2.Q4_K_M.gguf** +- `EMBEDDING_HF_MODEL_NAME` - Specifies the embedding model from Huggingface.co - **Default: BAAI/bge-small-en-v1.5** +- `TOKENIZER` - Specifies the model from Huggingface.co which is used as tokenizer - **Default: mistralai/Mistral-7B-Instruct-v0.2** +- `MAX_NEW_TOKENS` - Specifies the maximum count of new tokens that are generated - **Default: 512** +- `CONTEXT_WINDOW` - Specifies the context window of the model - **Default: 3900** - `LOGO_BG_COLOR` - Specifies the logo background color - **Default: #C7BAFF** - `LOGO_HEIGHT` - Specifies the logo height - **Default: 25%** - `LOGO_SVG_BASE64` - Specifies the logo file (.svg) in base64 format. Provide your own file (.svg) in base64 format using an [image to base64 converter](https://base64.guru/converter/encode/image) - **Default: \** diff --git a/privategpt/docker-entrypoint.sh b/privategpt/docker-entrypoint.sh index 5b15ff6..776c953 100644 --- a/privategpt/docker-entrypoint.sh +++ b/privategpt/docker-entrypoint.sh @@ -5,25 +5,50 @@ set -e # setup user environment # ############################ -# HEADER_BG_COLOR -sed -i "s|background-color: #C7BAFF;|background-color: ${LOGO_BG_COLOR:-#C7BAFF};|" /home/worker/app/private_gpt/ui/ui.py - -# LOGO_SVG_BASE64 -sed -i "s|logo_svg = \"data:image/svg+xml;base64,.*\"|logo_svg = \"data:image/svg+xml;base64,${LOGO_SVG_BASE64}\"|g" /home/worker/app/private_gpt/ui/images.py +# KEEP_FILES +if [ "${KEEP_FILES:-False}" != "True" ]; then + rm -rf /home/worker/app/local_data/* +fi -# LOGO_HEIGHT -sed -i "s|\.logo img { height: 25% }|\.logo img { height: ${LOGO_HEIGHT:-25%} }|g" /home/worker/app/private_gpt/ui/ui.py +# PROMPT_STYLE +if [ "${PROMPT_STYLE}" != "" ]; then + sed -i "s|prompt_style: \"mistral\"|prompt_style: \"${PROMPT_STYLE}\"|g" /home/worker/app/settings.yaml +fi # PGPT_HF_MODEL_FILE if [ "${PGPT_HF_MODEL_FILE}" != "" ]; then sed -i "s|llm_hf_model_file: mistral-7b-instruct-v0.2.Q4_K_M.gguf|llm_hf_model_file: ${PGPT_HF_MODEL_FILE}|g" /home/worker/app/settings.yaml fi -# KEEP_FILES -if [ "${KEEP_FILES:-False}" != "True" ]; then - rm -rf /home/worker/app/local_data/* +# EMBEDDING_HF_MODEL_NAME +if [ "${EMBEDDING_HF_MODEL_NAME}" != "" ]; then + sed -i "s|embedding_hf_model_name: BAAI/bge-small-en-v1.5|embedding_hf_model_name: ${EMBEDDING_HF_MODEL_NAME}|g" /home/worker/app/settings.yaml fi +# TOKENIZER +if [ "${TOKENIZER}" != "" ]; then + sed -i "s|tokenizer: mistralai/Mistral-7B-Instruct-v0.2|tokenizer: ${TOKENIZER}|g" /home/worker/app/settings.yaml +fi + +# MAX_NEW_TOKENS +if [ "${MAX_NEW_TOKENS}" != "" ]; then + sed -i "s|max_new_tokens: 512|max_new_tokens: ${MAX_NEW_TOKENS}|g" /home/worker/app/settings.yaml +fi + +# CONTEXT_WINDOW +if [ "${CONTEXT_WINDOW}" != "" ]; then + sed -i "s|context_window: 3900|context_window: ${CONTEXT_WINDOW}|g" /home/worker/app/settings.yaml +fi + +# LOGO_BG_COLOR +sed -i "s|background-color: #C7BAFF;|background-color: ${LOGO_BG_COLOR:-#C7BAFF};|" /home/worker/app/private_gpt/ui/ui.py + +# LOGO_SVG_BASE64 +sed -i "s|logo_svg = \"data:image/svg+xml;base64,.*\"|logo_svg = \"data:image/svg+xml;base64,${LOGO_SVG_BASE64}\"|g" /home/worker/app/private_gpt/ui/images.py + +# LOGO_HEIGHT +sed -i "s|\.logo img { height: 25% }|\.logo img { height: ${LOGO_HEIGHT:-25%} }|g" /home/worker/app/private_gpt/ui/ui.py + ############################ # run app # ############################