Skip to content

Commit

Permalink
feature: Allow specifying a specific redis db to use. Fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Mar 27, 2024
1 parent 6770172 commit e22a3dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
29 changes: 15 additions & 14 deletions docs/docs/03-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

The app is mainly configured by environment variables. All the used environment variables are listed in [packages/shared/config.ts](https://github.com/MohamedBassem/hoarder-app/blob/main/packages/shared/config.ts). The most important ones are:

| Name | Required | Default | Description |
| ---------------- | ------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- |
| DATA_DIR | Yes | Not set | The path for the persistent data directory. This is where the db and the uploaded assets live. |
| NEXTAUTH_SECRET | Yes | Not set | Random string used to sign the JWT tokens. Generate one with `openssl rand -base64 36`. |
| REDIS_HOST | Yes | localhost | The address of redis used by background jobs |
| REDIS_POST | Yes | 6379 | The port of redis used by background jobs |
| MEILI_ADDR | No | Not set | The address of meilisearch. If not set, Search will be disabled. E.g. (`http://meilisearch:7700`) |
| MEILI_MASTER_KEY | Only in Prod and if search is enabled | Not set | The master key configured for meilisearch. Not needed in development environment. Generate one with `openssl rand -base64 36` |
| Name | Required | Default | Description |
| ---------------- | ------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| DATA_DIR | Yes | Not set | The path for the persistent data directory. This is where the db and the uploaded assets live. |
| NEXTAUTH_SECRET | Yes | Not set | Random string used to sign the JWT tokens. Generate one with `openssl rand -base64 36`. |
| REDIS_HOST | Yes | localhost | The address of redis used by background jobs |
| REDIS_POST | Yes | 6379 | The port of redis used by background jobs |
| REDIS_DB_IDX | No | Not set | The db idx to use with redis. It defaults to 0 (in the client) so you don't usually need to set it unless you explicitly want another db. |
| MEILI_ADDR | No | Not set | The address of meilisearch. If not set, Search will be disabled. E.g. (`http://meilisearch:7700`) |
| MEILI_MASTER_KEY | Only in Prod and if search is enabled | Not set | The master key configured for meilisearch. Not needed in development environment. Generate one with `openssl rand -base64 36` |

## Inference Configs (For automatic tagging)

Either `OPENAI_API_KEY` or `OLLAMA_BASE_URL` need to be set for automatic tagging to be enabled. Otherwise, automatic tagging will be skipped.

| Name | Required | Default | Description |
| --------------------- | -------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OPENAI_API_KEY | No | Not set | The OpenAI key used for automatic tagging. More on that in [here](/openai). |
| Name | Required | Default | Description |
| --------------------- | -------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| OPENAI_API_KEY | No | Not set | The OpenAI key used for automatic tagging. More on that in [here](/openai). |
| OPENAI_BASE_URL | No | Not set | If you just want to use OpenAI you don't need to pass this variable. If, however, you want to use some other openai compatible API (e.g. azure openai service), set this to the url of the API. |
| OLLAMA_BASE_URL | No | Not set | If you want to use ollama for local inference, set the address of ollama API here. |
| INFERENCE_TEXT_MODEL | No | gpt-3.5-turbo-0125 | The model to use for text inference. You'll need to change this to some other model if you're using ollama. |
| INFERENCE_IMAGE_MODEL | No | gpt-4-vision-preview | The model to use for image inference. You'll need to change this to some other model if you're using ollama and that model needs to support vision APIs (e.g. llava). |
| OLLAMA_BASE_URL | No | Not set | If you want to use ollama for local inference, set the address of ollama API here. |
| INFERENCE_TEXT_MODEL | No | gpt-3.5-turbo-0125 | The model to use for text inference. You'll need to change this to some other model if you're using ollama. |
| INFERENCE_IMAGE_MODEL | No | gpt-4-vision-preview | The model to use for image inference. You'll need to change this to some other model if you're using ollama and that model needs to support vision APIs (e.g. llava). |
2 changes: 2 additions & 0 deletions packages/shared/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const allEnv = z.object({
INFERENCE_IMAGE_MODEL: z.string().default("gpt-4-vision-preview"),
REDIS_HOST: z.string().default("localhost"),
REDIS_PORT: z.coerce.number().default(6379),
REDIS_DB_IDX: z.coerce.number().optional(),
CRAWLER_HEADLESS_BROWSER: stringBool("true"),
BROWSER_EXECUTABLE_PATH: z.string().optional(), // If not set, the system's browser will be used
BROWSER_USER_DATA_DIR: z.string().optional(),
Expand Down Expand Up @@ -46,6 +47,7 @@ const serverConfigSchema = allEnv.transform((val) => {
bullMQ: {
redisHost: val.REDIS_HOST,
redisPort: val.REDIS_PORT,
redisDBIdx: val.REDIS_DB_IDX,
},
crawler: {
headlessBrowser: val.CRAWLER_HEADLESS_BROWSER,
Expand Down
1 change: 1 addition & 0 deletions packages/shared/queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import serverConfig from "./config";
export const queueConnectionDetails = {
host: serverConfig.bullMQ.redisHost,
port: serverConfig.bullMQ.redisPort,
db: serverConfig.bullMQ.redisDBIdx,
};

// Link Crawler
Expand Down

0 comments on commit e22a3dc

Please sign in to comment.