mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: move chromadb to its own service in dockerfile
This commit is contained in:
parent
79d81e4b3d
commit
71c953f00b
4 changed files with 33 additions and 1 deletions
|
|
@ -24,9 +24,15 @@ class SecurityConfig(BaseModel):
|
||||||
auth_jwt_secret_key: str
|
auth_jwt_secret_key: str
|
||||||
|
|
||||||
|
|
||||||
|
class ChromaDBConfig(BaseModel):
|
||||||
|
isSeparateDatabaseEnabled: bool | None
|
||||||
|
db_host: str | None
|
||||||
|
|
||||||
|
|
||||||
class AIConfig(BaseModel):
|
class AIConfig(BaseModel):
|
||||||
openai_api_key: str | None
|
openai_api_key: str | None
|
||||||
is_ai_enabled: bool | None
|
is_ai_enabled: bool | None
|
||||||
|
chromadb_config: ChromaDBConfig | None
|
||||||
|
|
||||||
|
|
||||||
class S3ApiConfig(BaseModel):
|
class S3ApiConfig(BaseModel):
|
||||||
|
|
@ -196,12 +202,21 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
||||||
# AI Config
|
# AI Config
|
||||||
env_openai_api_key = os.environ.get("LEARNHOUSE_OPENAI_API_KEY")
|
env_openai_api_key = os.environ.get("LEARNHOUSE_OPENAI_API_KEY")
|
||||||
env_is_ai_enabled = os.environ.get("LEARNHOUSE_IS_AI_ENABLED")
|
env_is_ai_enabled = os.environ.get("LEARNHOUSE_IS_AI_ENABLED")
|
||||||
|
env_chromadb_separate = os.environ.get("LEARNHOUSE_CHROMADB_SEPARATE")
|
||||||
|
env_chromadb_host = os.environ.get("LEARNHOUSE_CHROMADB_HOST")
|
||||||
|
|
||||||
openai_api_key = env_openai_api_key or yaml_config.get("ai_config", {}).get(
|
openai_api_key = env_openai_api_key or yaml_config.get("ai_config", {}).get(
|
||||||
"openai_api_key"
|
"openai_api_key"
|
||||||
)
|
)
|
||||||
is_ai_enabled = env_is_ai_enabled or yaml_config.get("ai_config", {}).get(
|
is_ai_enabled = env_is_ai_enabled or yaml_config.get("ai_config", {}).get(
|
||||||
"is_ai_enabled"
|
"is_ai_enabled"
|
||||||
)
|
)
|
||||||
|
chromadb_separate = env_chromadb_separate or yaml_config.get("ai_config", {}).get(
|
||||||
|
"chromadb_config", {}
|
||||||
|
).get("isSeparateDatabaseEnabled")
|
||||||
|
chromadb_host = env_chromadb_host or yaml_config.get("ai_config", {}).get(
|
||||||
|
"chromadb_config", {}
|
||||||
|
).get("db_host")
|
||||||
|
|
||||||
# Redis config
|
# Redis config
|
||||||
env_redis_connection_string = os.environ.get("LEARNHOUSE_REDIS_CONNECTION_STRING")
|
env_redis_connection_string = os.environ.get("LEARNHOUSE_REDIS_CONNECTION_STRING")
|
||||||
|
|
@ -267,6 +282,9 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
||||||
ai_config = AIConfig(
|
ai_config = AIConfig(
|
||||||
openai_api_key=openai_api_key,
|
openai_api_key=openai_api_key,
|
||||||
is_ai_enabled=bool(is_ai_enabled),
|
is_ai_enabled=bool(is_ai_enabled),
|
||||||
|
chromadb_config=ChromaDBConfig(
|
||||||
|
isSeparateDatabaseEnabled=bool(chromadb_separate), db_host=chromadb_host
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create LearnHouseConfig object
|
# Create LearnHouseConfig object
|
||||||
|
|
|
||||||
|
|
@ -36,3 +36,8 @@ database_config:
|
||||||
|
|
||||||
redis_config:
|
redis_config:
|
||||||
redis_connection_string: redis://localhost:6379/learnhouse
|
redis_connection_string: redis://localhost:6379/learnhouse
|
||||||
|
|
||||||
|
ai_config:
|
||||||
|
chromadb_config:
|
||||||
|
isSeparateDatabaseEnabled: True
|
||||||
|
db_host: "chromadb"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,12 @@ import chromadb
|
||||||
|
|
||||||
from config.config import get_learnhouse_config
|
from config.config import get_learnhouse_config
|
||||||
|
|
||||||
client = chromadb.Client()
|
LH_CONFIG = get_learnhouse_config()
|
||||||
|
client = (
|
||||||
|
chromadb.HttpClient(host=LH_CONFIG.ai_config.chromadb_config.db_host, port=8000)
|
||||||
|
if LH_CONFIG.ai_config.chromadb_config.isSeparateDatabaseEnabled == True
|
||||||
|
else chromadb.Client()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
chat_history = []
|
chat_history = []
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,7 @@ services:
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 4s
|
timeout: 4s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
chromadb:
|
||||||
|
image: chromadb/chroma:latest
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue