mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Update default docker compose configuration with Khoj local mode
This commit is contained in:
parent
8c36079f74
commit
20ce3d0c78
2 changed files with 51 additions and 27 deletions
|
@ -10,7 +10,15 @@ services:
|
||||||
POSTGRES_DB: postgres
|
POSTGRES_DB: postgres
|
||||||
volumes:
|
volumes:
|
||||||
- khoj_db:/var/lib/postgresql/data/
|
- khoj_db:/var/lib/postgresql/data/
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
server:
|
server:
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
# Use the following line to use the latest version of khoj. Otherwise, it will build from source.
|
# Use the following line to use the latest version of khoj. Otherwise, it will build from source.
|
||||||
image: ghcr.io/khoj-ai/khoj:latest
|
image: ghcr.io/khoj-ai/khoj:latest
|
||||||
# Uncomment the following line to build from source. This will take a few minutes. Comment the next two lines out if you want to use the offiicial image.
|
# Uncomment the following line to build from source. This will take a few minutes. Comment the next two lines out if you want to use the offiicial image.
|
||||||
|
@ -47,9 +55,11 @@ services:
|
||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD=postgres
|
||||||
- POSTGRES_HOST=database
|
- POSTGRES_HOST=database
|
||||||
- POSTGRES_PORT=5432
|
- POSTGRES_PORT=5432
|
||||||
- GOOGLE_CLIENT_SECRET=bar
|
- KHOJ_DJANGO_SECRET_KEY=secret
|
||||||
- GOOGLE_CLIENT_ID=foo
|
- KHOJ_DEBUG=True
|
||||||
command: --host="0.0.0.0" --port=42110 -vv
|
- ADMIN_EMAIL=username@example.com
|
||||||
|
- ADMIN_PASSWORD=password
|
||||||
|
command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from database.models import (
|
from database.models import (
|
||||||
KhojUser,
|
KhojUser,
|
||||||
|
@ -17,37 +18,50 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def initialization():
|
def initialization():
|
||||||
def _create_admin_user():
|
def _create_admin_user():
|
||||||
logger.info("👩✈️ Setting up admin user")
|
logger.info(
|
||||||
email_addr = input("Email Address: ")
|
"👩✈️ Setting up admin user. These credentials will allow you to configure your server at /django/admin."
|
||||||
password = input("Password: ")
|
)
|
||||||
|
email_addr = os.getenv("ADMIN_EMAIL") or input("Email: ")
|
||||||
|
password = os.getenv("ADMIN_PASSWORD") or input("Password: ")
|
||||||
admin_user = KhojUser.objects.create_superuser(email=email_addr, username=email_addr, password=password)
|
admin_user = KhojUser.objects.create_superuser(email=email_addr, username=email_addr, password=password)
|
||||||
logger.info(f"👩✈️ Created admin user: {admin_user.email}")
|
logger.info(f"👩✈️ Created admin user: {admin_user.email}")
|
||||||
|
|
||||||
def _create_chat_configuration():
|
def _create_chat_configuration():
|
||||||
logger.info(
|
logger.info(
|
||||||
"🗣️ Configure chat models available to your server. You can always update these at /django/admin using the credentials of your admin account"
|
"🗣️ Configure chat models available to your server. You can always update these at /django/admin using the credentials of your admin account"
|
||||||
)
|
)
|
||||||
use_offline_model = input("Use offline chat model? (y/n): ")
|
try:
|
||||||
if use_offline_model == "y":
|
# Some environments don't support interactive input. We catch the exception and return if that's the case. The admin can still configure their settings from the admin page.
|
||||||
logger.info("🗣️ Setting up offline chat model")
|
input()
|
||||||
OfflineChatProcessorConversationConfig.objects.create(enabled=True)
|
except EOFError:
|
||||||
|
return
|
||||||
|
|
||||||
offline_chat_model = input(
|
try:
|
||||||
f"Enter the name of the offline chat model you want to use, based on the models in HuggingFace (press enter to use the default: {default_offline_chat_model}): "
|
import gpt4all
|
||||||
)
|
|
||||||
if offline_chat_model == "":
|
use_offline_model = input("Use offline chat model? (y/n): ")
|
||||||
ChatModelOptions.objects.create(
|
if use_offline_model == "y":
|
||||||
chat_model=default_offline_chat_model, model_type=ChatModelOptions.ModelType.OFFLINE
|
logger.info("🗣️ Setting up offline chat model")
|
||||||
)
|
OfflineChatProcessorConversationConfig.objects.create(enabled=True)
|
||||||
else:
|
|
||||||
max_tokens = input("Enter the maximum number of tokens to use for the offline chat model:")
|
offline_chat_model = input(
|
||||||
tokenizer = input("Enter the tokenizer to use for the offline chat model:")
|
f"Enter the name of the offline chat model you want to use, based on the models in HuggingFace (press enter to use the default: {default_offline_chat_model}): "
|
||||||
ChatModelOptions.objects.create(
|
|
||||||
chat_model=offline_chat_model,
|
|
||||||
model_type=ChatModelOptions.ModelType.OFFLINE,
|
|
||||||
max_prompt_size=max_tokens,
|
|
||||||
tokenizer=tokenizer,
|
|
||||||
)
|
)
|
||||||
|
if offline_chat_model == "":
|
||||||
|
ChatModelOptions.objects.create(
|
||||||
|
chat_model=default_offline_chat_model, model_type=ChatModelOptions.ModelType.OFFLINE
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
max_tokens = input("Enter the maximum number of tokens to use for the offline chat model:")
|
||||||
|
tokenizer = input("Enter the tokenizer to use for the offline chat model:")
|
||||||
|
ChatModelOptions.objects.create(
|
||||||
|
chat_model=offline_chat_model,
|
||||||
|
model_type=ChatModelOptions.ModelType.OFFLINE,
|
||||||
|
max_prompt_size=max_tokens,
|
||||||
|
tokenizer=tokenizer,
|
||||||
|
)
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
logger.warning("Offline models are not supported on this device.")
|
||||||
|
|
||||||
use_openai_model = input("Use OpenAI chat model? (y/n): ")
|
use_openai_model = input("Use OpenAI chat model? (y/n): ")
|
||||||
|
|
||||||
|
@ -61,7 +75,7 @@ def initialization():
|
||||||
chat_model=openai_chat_model, model_type=ChatModelOptions.ModelType.OPENAI, max_tokens=max_tokens
|
chat_model=openai_chat_model, model_type=ChatModelOptions.ModelType.OPENAI, max_tokens=max_tokens
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("🗣️ Chat model configuration complete")
|
logger.info("🗣️ Chat model configuration complete")
|
||||||
|
|
||||||
admin_user = KhojUser.objects.filter(is_staff=True).first()
|
admin_user = KhojUser.objects.filter(is_staff=True).first()
|
||||||
if admin_user is None:
|
if admin_user is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue