Skip to content

Commit

Permalink
Merge pull request #6 from IDinsight/update-docs
Browse files Browse the repository at this point in the history
Customize docs
  • Loading branch information
lickem22 authored Aug 15, 2024
2 parents cd78218 + 91e3720 commit a85a524
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 111 deletions.
25 changes: 16 additions & 9 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,20 @@
}
],
"deployment/docker-compose/template.core_backend.env": [
{
"type": "Secret Keyword",
"filename": "deployment/docker-compose/template.core_backend.env",
"hashed_secret": "4402394e878f7a467f57e5e02d450190b511f7a8",
"is_verified": false,
"line_number": 13
},
{
"type": "Secret Keyword",
"filename": "deployment/docker-compose/template.core_backend.env",
"hashed_secret": "b83efb89100a5f11b5cb4418471326f6c5b669c7",
"is_verified": false,
"line_number": 20
},
{
"type": "Secret Keyword",
"filename": "deployment/docker-compose/template.core_backend.env",
Expand All @@ -500,13 +514,6 @@
"is_verified": false,
"line_number": 18
},
{
"type": "Secret Keyword",
"filename": "deployment/docker-compose/template.litellm_proxy.env",
"hashed_secret": "8586c76a0032202d1a68b119f9d0ffe9cae81220",
"is_verified": false,
"line_number": 22
},
{
"type": "Secret Keyword",
"filename": "deployment/docker-compose/template.litellm_proxy.env",
Expand Down Expand Up @@ -539,9 +546,9 @@
"filename": "docs/develop/setup.md",
"hashed_secret": "1c8d549f8ff68a7790ba6825cedf89735c115972",
"is_verified": false,
"line_number": 278
"line_number": 277
}
]
},
"generated_at": "2024-08-14T14:37:37Z"
"generated_at": "2024-08-14T18:24:15Z"
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ setup-embeddings-arm:
@sleep 2
@docker run \
--name huggingface-embeddings \
-p 8080:80 \
-p 8081:80 \
-v "$(PWD)/data:/data" \
-d text-embeddings-inference-arm \
--model-id $(HUGGINGFACE_MODEL) \
Expand All @@ -126,7 +126,7 @@ setup-embeddings:
@sleep 2
@docker run \
--name huggingface-embeddings \
-p 8080:80 \
-p 8081:80 \
-v "$(PWD)/data:/data" \
--pull always ghcr.io/huggingface/text-embeddings-inference:cpu-1.5 \
--model-id $(HUGGINGFACE_MODEL) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ const PersistentSearchBar = ({
<MenuItem value="embeddings-search" autoFocus={true}>
<Typography variant="body2">Content Search</Typography>
</MenuItem>
<MenuItem value="llm-response">
{/* <MenuItem value="llm-response">
<Typography variant="body2">AI Response</Typography>
</MenuItem>
</MenuItem>*/}
<MenuItem value="urgency-detection">
<Typography variant="body2">Urgency Detection</Typography>
</MenuItem>
Expand Down
2 changes: 1 addition & 1 deletion core_backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
POSTGRES_DB = os.environ.get("POSTGRES_DB", "postgres")

# PGVector variables
PGVECTOR_VECTOR_SIZE = os.environ.get("PGVECTOR_VECTOR_SIZE", "1536")
PGVECTOR_VECTOR_SIZE = os.environ.get("PGVECTOR_VECTOR_SIZE", "1024")
PGVECTOR_M = os.environ.get("PGVECTOR_M", "16")
PGVECTOR_EF_CONSTRUCTION = os.environ.get("PGVECTOR_EF_CONSTRUCTION", "64")
PGVECTOR_DISTANCE = os.environ.get("PGVECTOR_DISTANCE", "vector_cosine_ops")
Expand Down
4 changes: 2 additions & 2 deletions deployment/docker-compose/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
- .core_backend.env
volumes:
- db_volume:/var/lib/postgresql/data
ports: # Expose the port to port 5434 on the host machine for debugging
- 5434:5432
ports:
- 5432:5432

volumes:
db_volume:
5 changes: 3 additions & 2 deletions deployment/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ services:
["--model-id", "${HUGGINGFACE_MODEL}", "--api-key", "${LITELLM_API_KEY}"]
restart: always
env_file:
- .litellm_proxy.env
- .core_backend.env
develop:
watch:
- action: rebuild
path: ../../optional_components/embeddings

redis:
image: "redis:6.0-alpine"
ports: # Expose the port to port 6380 on the host machine for debugging
ports:
# Expose the port to port 6380 on the host machine for debugging
- "6380:6379"
restart: always

Expand Down
5 changes: 0 additions & 5 deletions deployment/docker-compose/template.base.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ BACKEND_ROOT_PATH="/api"
# This is the path that core_backend will be hosted on.
# Only change if you want to use a different backend root path.

#### Google OAuth Client ID ###################################################
# NEXT_PUBLIC_GOOGLE_LOGIN_CLIENT_ID="update-me"
# If you want to use Google OAuth, set the correct value for your production. This value
# is used by core_backend and admin_app.

#### Backend URL ##############################################################
NEXT_PUBLIC_BACKEND_URL="https://${DOMAIN}${BACKEND_ROOT_PATH}"
# Do not change this value. This value is used by admin_app.
Expand Down
23 changes: 8 additions & 15 deletions deployment/docker-compose/template.core_backend.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,51 @@

#### 🔒 Postgres variables -- change for production ############################
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres #pragma: allowlist secret
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=postgres

#### 🔒 Admin user -- change for production ####################################
ADMIN_USERNAME="admin"
ADMIN_PASSWORD="fullaccess" #pragma: allowlist secret
ADMIN_API_KEY="admin-key" #pragma: allowlist secret
ADMIN_API_KEY="admin-key"

#### Admin user rate limits ###################################################
# ADMIN_CONTENT_QUOTA=1000
# ADMIN_API_DAILY_QUOTA=100

#### 🔒 JWT -- change for production ###########################################
JWT_SECRET="jwt-secret" #pragma: allowlist secret
JWT_SECRET="jwt-secret"

#### Redis -- change for production ##########################################
REDIS_HOST="redis://localhost:6379"
# For docker compose, use "redis://redis:6379"

#### 🔒 LiteLLM Proxy Server -- change for production ##########################
LITELLM_ENDPOINT="http://local-embeddings"
LITELLM_ENDPOINT="http://localhost:8081"
LITELLM_API_KEY="update-embeddings-api-key"
HUGGINGFACE_MODEL="Alibaba-NLP/gte-large-en-v1.5"
# For docker compose, use "http://local-embeddings"
# For docker compose, use "http://huggingface-embeddings"

#### Variables for Huggingface embeddings container ###########################
# If on ARM, you need to build the embeddings image manually using
# `make build-embeddings-arm` from repository root and set the following variables
#EMBEDDINGS_IMAGE_NAME=text-embeddings-inference-arm
#PGVECTOR_VECTOR_SIZE=1024
PGVECTOR_VECTOR_SIZE=1024

#### Temporary folder for prometheus gunicorn multiprocess ####################
PROMETHEUS_MULTIPROC_DIR="/tmp"

#### Application-wide content limits ##########################################
# CHECK_CONTENT_LIMIT=True
# CHECK_CONTENT_LIMIT=False
# DEFAULT_CONTENT_QUOTA=50

#### Number of top content to return for /search. #############################
# N_TOP_CONTENT=5

#### Urgency detection variables ##############################################
# URGENCY_CLASSIFIER="cosine_distance_classifier"
# Choose between `cosine_distance_classifier` and `llm_entailment_classifier`

# URGENCY_DETECTION_MAX_DISTANCE=0.5
# Only used if URGENCY_CLASSIFIER=cosine_distance_classifier

# URGENCY_DETECTION_MIN_PROBABILITY=0.5
# Only used if URGENCY_CLASSIFIER=llm_entailment_classifier
URGENCY_CLASSIFIER="cosine_distance_classifier"

#### LiteLLM tracing ##########################################################
LANGFUSE=False
2 changes: 1 addition & 1 deletion docs/components/huggingface-embeddings/how-to-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ make setup-embeddings-arm

!!! warning "Before running the commands above, you must export environment variables `HUGGINGFACE_MODEL` and `HUGGINGFACE_EMBEDDINGS_API_KEY`."

The embeddings API endpoint by default is at: [http://localhost:5000](http://localhost:5000).
The embeddings API endpoint by default is at: [http://localhost:8081](http://localhost:8081).


## Also see
Expand Down
6 changes: 4 additions & 2 deletions docs/components/huggingface-embeddings/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Get more control of your data with Custom Embeddings
# Hugging Face Embeddings

_Get more control of your data by using open-source embeddings from Hugging Face_

By default, AAQ uses
[OpenAI text embeddings](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings)
Expand All @@ -23,4 +25,4 @@ some heavy. Please carefully choose the model that will fit your use case best.
Deploying the custom Hugging Face embeddings model and
configuring AAQ to use Hugging Face embeddings.

[:octicons-arrow-right-24: More info](./huggingface-embeddings/index.md)
[:octicons-arrow-right-24: More info](./how-to-use.md)
2 changes: 1 addition & 1 deletion docs/deployment/architecture.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Architecture

!!! note "Customized for MomConnect"
!!! info "This page has been customized for MomConnect."

We use docker-compose to orchestrate containers with a reverse proxy that manages all
incoming traffic to the service. The database and embedding model server are only accessed by the core
Expand Down
66 changes: 11 additions & 55 deletions docs/deployment/config-options.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,24 @@
# Configuring AAQ

There are several aspects of AAQ you can configure:
!!! info "This page has been customized for MomConnect."

1. **Application configs through environment variables**
All required and optional environment variables are defined in
`deployment/docker-compose/template.*.env` files.

All required and optional environment variables are defined in
`deployment/docker-compose/template.*.env` files. **You will need to copy the
templates into `.*.env` files.**
You will need to copy the
templates into `.*.env` files.

```shell
cp template.base.env .base.env
cp template.core_backend.env .core_backend.env
cp template.litellm_proxy.env .litellm_proxy.env
```

To get a [local setup running with docker
compose](./quick-setup.md), you won't need to change any values except for
[LLM credentials in
`.litellm_proxy.env`](#authenticating-litellm-proxy-server-to-llms).
See the rest of
this page for more information on the environment variables.
2. **LLM models in
[`litellm_proxy_config.yaml`](https://github.com/IDinsight/ask-a-question/blob/main/deployment/docker-compose/litellm_proxy_config.yaml)**
This defines which LLM to use for which task. You may want to change the LLMs and
specific calling parameters based on your needs.
3. **LLM prompts in
[`llm_prompts.py`](https://github.com/IDinsight/ask-a-question/blob/main/core_backend/app/llm_call/llm_prompts.py)**
```shell
cp template.base.env .base.env
cp template.core_backend.env .core_backend.env
```

While all prompts have been carefully selected to perform each task well, you can
customize them to your need here.
See the rest of
this page for more information on the environment variables.

<a name="template-env-guide"></a>
!!! note "Understanding the template environment files `template.*.env`"

For local testing and development, the values shoud work as is, except for LLM API credentials in `.litellm_proxy.env`
For production, make sure you confirm or update the ones marked "change for production" at the least.

1. Secrets have been marked with 🔒.
Expand Down Expand Up @@ -91,29 +70,6 @@ files -- for example, [`core_backend/app/config.py`](https://github.com/IDinsigh
not found, we fall back on defaults provided. So any environment variables set
will override any defaults you have set in the config file.

## Configuring LiteLLM Proxy Server (`litellm_proxy`)

### LiteLLM Proxy Server configurations

You can edit the default [LiteLLM Proxy Server](../components/litellm-proxy/index.md)
settings by updating
[`litellm_proxy_config.yaml`](https://github.com/IDinsight/ask-a-question/blob/main/deployment/docker-compose/litellm_proxy_config.yaml).
Learn more about the server configuration in [LiteLLM Proxy Server](../components/litellm-proxy/index.md).

### Authenticating LiteLLM Proxy Server to LLMs

The `litellm_proxy` server uses the following required and optional (commented out) environment
variables for authenticating to external LLM APIs ([guide](#template-env-guide) on updating the template).

You will need to set up
the correct credentials (API keys, etc.) for all LLM APIs declared in
[`litellm_proxy_config.yaml`](https://github.com/IDinsight/ask-a-question/blob/main/deployment/docker-compose/litellm_proxy_config.yaml). See [LiteLLM's documentation](https://docs.litellm.ai/docs/) for more information about
authentication for different LLMs.
```shell title="<code>deployment/docker-compose/template.litellm_proxy.env</code>"
--8<-- "deployment/docker-compose/template.litellm_proxy.env"
```
## Configuring optional components

See instructions for setting these in the documentation for the specific optional
Expand Down
18 changes: 7 additions & 11 deletions docs/deployment/quick-setup.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Quick Setup with Docker Compose

!!! info "This page has been customized for MomConnect."

## Quick setup

!!! warning "You need to have installed [Docker](https://docs.docker.com/get-docker/)"

**Step 1:** Clone the [AAQ repository](https://github.com/IDinsight/ask-a-question).

```shell
git clone git@github.com:IDinsight/ask-a-question.git
git clone git@github.com:IDinsight/momconnect-aaq.git
```

**Step 2:** Navigate to the `deployment/docker-compose/` subfolder.
Expand All @@ -21,22 +23,15 @@ cd deployment/docker-compose/
```shell
cp template.base.env .base.env
cp template.core_backend.env .core_backend.env
cp template.litellm_proxy.env .litellm_proxy.env
```

**Step 4:** Configure LiteLLM Proxy server

1. (optional) Edit `litellm_proxy_config.yaml` with LLM services you want to use. See
[LiteLLM Proxy Server](../components/litellm-proxy/index.md) for more details.
2. Update the API key(s) and authentication information in
`.litellm_proxy.env`. Make sure you set up the correct authentication for the LLM
services defined in `litellm_proxy_config.yaml`.
**Step 4:** <s>Configure LiteLLM Proxy server</s> (Not applicable for MomConnect)

**Step 5:** Run docker-compose

```shell
docker compose -f docker-compose.yml -f docker-compose.dev.yml \
-p aaq-stack up -d --build
--profile huggingface-embeddings -p mc-aaq-stack up -d --build
```

You can now view the AAQ admin app at `https://$DOMAIN/` (by default, this should be [https://localhost/](https://localhost/)) and the API documentation at
Expand All @@ -45,7 +40,8 @@ You can now view the AAQ admin app at `https://$DOMAIN/` (by default, this shoul
**Step 6:** Shutdown containers

```shell
docker compose -f docker-compose.yml -f docker-compose.dev.yml -p aaq-stack down
docker compose -f docker-compose.yml -f docker-compose.dev.yml \
--profile huggingface-embeddings -p mc-aaq-stack down
```

## Ready to deploy?
Expand Down
3 changes: 1 addition & 2 deletions docs/develop/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Please fork the
[project repository](https://github.com/IDinsight/ask-a-question) by clicking on the
"Fork" button. Then, clone the repo using your own GitHub handle:

git clone git@github.com:<your GitHub handle>/ask-a-question.git
git clone git@github.com:<your GitHub handle>/momconnect-aaq.git

For questions related to setup, please contact
[AAQ Support](mailto:aaq@idinsight.org?Subject=AAQ%20Setup%20Help)
Expand All @@ -24,7 +24,6 @@ For questions related to setup, please contact
```shell
cp template.base.env .base.env
cp template.core_backend.env .core_backend.env
cp template.litellm_proxy.env .litellm_proxy.env
```

3. Update `.litellm_proxy.env` with LLM service credentials. This will be used by
Expand Down
2 changes: 1 addition & 1 deletion optional_components/embeddings/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

COPY ./app /app

CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8081"]

0 comments on commit a85a524

Please sign in to comment.