Merge pull request #255 from learnhouse/feat/separate-chromadb-from-api

Separate chromadb from api
This commit is contained in:
Badr B 2024-05-26 11:30:52 +02:00 committed by GitHub
commit 558e85e018
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 4182 additions and 3338 deletions

View file

@ -24,9 +24,15 @@ class SecurityConfig(BaseModel):
auth_jwt_secret_key: str
class ChromaDBConfig(BaseModel):
isSeparateDatabaseEnabled: bool | None
db_host: str | None
class AIConfig(BaseModel):
openai_api_key: str | None
is_ai_enabled: bool | None
chromadb_config: ChromaDBConfig | None
class S3ApiConfig(BaseModel):
@ -196,12 +202,21 @@ def get_learnhouse_config() -> LearnHouseConfig:
# AI Config
env_openai_api_key = os.environ.get("LEARNHOUSE_OPENAI_API_KEY")
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"
)
is_ai_enabled = env_is_ai_enabled or yaml_config.get("ai_config", {}).get(
"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
env_redis_connection_string = os.environ.get("LEARNHOUSE_REDIS_CONNECTION_STRING")
@ -267,6 +282,9 @@ def get_learnhouse_config() -> LearnHouseConfig:
ai_config = AIConfig(
openai_api_key=openai_api_key,
is_ai_enabled=bool(is_ai_enabled),
chromadb_config=ChromaDBConfig(
isSeparateDatabaseEnabled=bool(chromadb_separate), db_host=chromadb_host
),
)
# Create LearnHouseConfig object

View file

@ -36,3 +36,8 @@ database_config:
redis_config:
redis_connection_string: redis://localhost:6379/learnhouse
ai_config:
chromadb_config:
isSeparateDatabaseEnabled: True
db_host: "chromadb"

View file

@ -20,7 +20,12 @@ import chromadb
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 = []

View file

@ -1,39 +1,139 @@
lockfileVersion: '6.0'
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
'@hocuspocus/server':
specifier: ^2.11.3
version: 2.11.3(y-protocols@1.0.6)(yjs@13.6.14)
bun:
specifier: ^1.0.36
version: 1.1.1
typescript:
specifier: 5.4.4
version: 5.4.4
y-protocols:
specifier: ^1.0.6
version: 1.0.6(yjs@13.6.14)
yjs:
specifier: ^13.6.14
version: 13.6.14
importers:
.:
dependencies:
'@hocuspocus/server':
specifier: ^2.11.3
version: 2.11.3(y-protocols@1.0.6)(yjs@13.6.14)
bun:
specifier: ^1.0.36
version: 1.1.1
typescript:
specifier: 5.4.4
version: 5.4.4
y-protocols:
specifier: ^1.0.6
version: 1.0.6(yjs@13.6.14)
yjs:
specifier: ^13.6.14
version: 13.6.14
packages:
/@hocuspocus/common@2.11.3:
'@hocuspocus/common@2.11.3':
resolution: {integrity: sha512-w3UZpW6ZVYIHPEFzZJV3yn1d3EZaXf2m2zU53pwj0AyTBmVD7kB9ZiD6twc9A7NNB1dkqD8c58PbD42+pnNiKQ==}
dependencies:
lib0: 0.2.93
dev: false
/@hocuspocus/server@2.11.3(y-protocols@1.0.6)(yjs@13.6.14):
'@hocuspocus/server@2.11.3':
resolution: {integrity: sha512-1Vdy4RtJcpffs5I4Ey3M8ulu2f6AbpSDmK4YFG8k3O4EJT7HDSO3Ib5STiRBxlr2LncJeVa2ikwlvwQotsWqew==}
peerDependencies:
y-protocols: ^1.0.6
yjs: ^13.6.8
'@oven/bun-darwin-aarch64@1.1.1':
resolution: {integrity: sha512-RDs5ZMSkcurj4YqPtkcKGYUA46/LDcw7tQ0a4hBI/mtjpYySYmIIYkSeeotl9IJMNcG+ZsHpRc4b7ROFRYhxEw==}
cpu: [arm64]
os: [darwin]
'@oven/bun-darwin-x64-baseline@1.1.1':
resolution: {integrity: sha512-sJKZqgT9JSbxTPLULHdcYiKy+F4x2gq114FxDwEqn3YVZnBqSO0X9GCqWOa1CNqUaxGvJnNgn+HDkIQlnXVLiA==}
cpu: [x64]
os: [darwin]
'@oven/bun-darwin-x64@1.1.1':
resolution: {integrity: sha512-RiRbhu9htOML4+81AfHIvjgdVU3jsn+EiyvwuUv5j91vgGrZLkNXebGZXt2eGDDutGzHqvQJqW6sxQ+UNJQi7w==}
cpu: [x64]
os: [darwin]
'@oven/bun-linux-aarch64@1.1.1':
resolution: {integrity: sha512-9twn92P90pAwyvC6PzcWv/3a2B2/01TzdCwslWNaI0LdQ3b+sJR4IvdXG1yQI3N2Ne/ticM7eww2eWma4I0LRQ==}
cpu: [arm64]
os: [linux]
'@oven/bun-linux-x64-baseline@1.1.1':
resolution: {integrity: sha512-2nXg32DLs0xaZH5GafJ16UqrDr4XGRXTeyZW3PNhplaFY0m3fRDXCqDsXmTvsQoGO/FEtMrEmJSWXbLa7u0B4A==}
cpu: [x64]
os: [linux]
'@oven/bun-linux-x64@1.1.1':
resolution: {integrity: sha512-2JPkRTCSXe5w9JvMucx7fgN77yQK+XZ+fY7WlEsZnAR4PjEGImZA12nGNbnxEHM3TmOEivy2PP00nAXeu9LViA==}
cpu: [x64]
os: [linux]
'@oven/bun-windows-x64-baseline@1.1.1':
resolution: {integrity: sha512-3q/THmrP1yA8/YTJoS29Et5a+AxP2jGX96cYHlOZEjoTj/FBNFSuuPVvvFEpjrRkQ8Oz9iNE/C6ltna8WKSUxQ==}
cpu: [x64]
os: [win32]
'@oven/bun-windows-x64@1.1.1':
resolution: {integrity: sha512-oolhIph8Kah6K/7kPUjcqgc2N5lS6RD4yruwrG2QYhxcYWTh7m36Ngp709l8+trhLLaUyTnvr4MvuiKPl1cRjQ==}
cpu: [x64]
os: [win32]
async-lock@1.4.1:
resolution: {integrity: sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==}
bun@1.1.1:
resolution: {integrity: sha512-gV90TkJgHvI50X9BoKQ3zVpPEY6YP0vqOww2uZmsOyckZSRlcFYWhXZwFj6PV8KCFINYs8VZ65m59U2RuFYfWw==}
cpu: [arm64, x64]
os: [darwin, linux, win32]
hasBin: true
isomorphic.js@0.2.5:
resolution: {integrity: sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==}
kleur@4.1.5:
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
engines: {node: '>=6'}
lib0@0.2.93:
resolution: {integrity: sha512-M5IKsiFJYulS+8Eal8f+zAqf5ckm1vffW0fFDxfgxJ+uiVopvDdd3PxJmz0GsVi3YNO7QCFSq0nAsiDmNhLj9Q==}
engines: {node: '>=16'}
hasBin: true
typescript@5.4.4:
resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==}
engines: {node: '>=14.17'}
hasBin: true
uuid@9.0.1:
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
hasBin: true
ws@8.16.0:
resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
y-protocols@1.0.6:
resolution: {integrity: sha512-vHRF2L6iT3rwj1jub/K5tYcTT/mEYDUppgNPXwp8fmLpui9f7Yeq3OEtTLVF012j39QnV+KEQpNqoN7CWU7Y9Q==}
engines: {node: '>=16.0.0', npm: '>=8.0.0'}
peerDependencies:
yjs: ^13.0.0
yjs@13.6.14:
resolution: {integrity: sha512-D+7KcUr0j+vBCUSKXXEWfA+bG4UQBviAwP3gYBhkstkgwy5+8diOPMx0iqLIOxNo/HxaREUimZRxqHGAHCL2BQ==}
engines: {node: '>=16.0.0', npm: '>=8.0.0'}
snapshots:
'@hocuspocus/common@2.11.3':
dependencies:
lib0: 0.2.93
'@hocuspocus/server@2.11.3(y-protocols@1.0.6)(yjs@13.6.14)':
dependencies:
'@hocuspocus/common': 2.11.3
async-lock: 1.4.1
@ -46,82 +146,34 @@ packages:
transitivePeerDependencies:
- bufferutil
- utf-8-validate
dev: false
/@oven/bun-darwin-aarch64@1.1.1:
resolution: {integrity: sha512-RDs5ZMSkcurj4YqPtkcKGYUA46/LDcw7tQ0a4hBI/mtjpYySYmIIYkSeeotl9IJMNcG+ZsHpRc4b7ROFRYhxEw==}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: false
'@oven/bun-darwin-aarch64@1.1.1':
optional: true
/@oven/bun-darwin-x64-baseline@1.1.1:
resolution: {integrity: sha512-sJKZqgT9JSbxTPLULHdcYiKy+F4x2gq114FxDwEqn3YVZnBqSO0X9GCqWOa1CNqUaxGvJnNgn+HDkIQlnXVLiA==}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
'@oven/bun-darwin-x64-baseline@1.1.1':
optional: true
/@oven/bun-darwin-x64@1.1.1:
resolution: {integrity: sha512-RiRbhu9htOML4+81AfHIvjgdVU3jsn+EiyvwuUv5j91vgGrZLkNXebGZXt2eGDDutGzHqvQJqW6sxQ+UNJQi7w==}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
'@oven/bun-darwin-x64@1.1.1':
optional: true
/@oven/bun-linux-aarch64@1.1.1:
resolution: {integrity: sha512-9twn92P90pAwyvC6PzcWv/3a2B2/01TzdCwslWNaI0LdQ3b+sJR4IvdXG1yQI3N2Ne/ticM7eww2eWma4I0LRQ==}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
'@oven/bun-linux-aarch64@1.1.1':
optional: true
/@oven/bun-linux-x64-baseline@1.1.1:
resolution: {integrity: sha512-2nXg32DLs0xaZH5GafJ16UqrDr4XGRXTeyZW3PNhplaFY0m3fRDXCqDsXmTvsQoGO/FEtMrEmJSWXbLa7u0B4A==}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
'@oven/bun-linux-x64-baseline@1.1.1':
optional: true
/@oven/bun-linux-x64@1.1.1:
resolution: {integrity: sha512-2JPkRTCSXe5w9JvMucx7fgN77yQK+XZ+fY7WlEsZnAR4PjEGImZA12nGNbnxEHM3TmOEivy2PP00nAXeu9LViA==}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
'@oven/bun-linux-x64@1.1.1':
optional: true
/@oven/bun-windows-x64-baseline@1.1.1:
resolution: {integrity: sha512-3q/THmrP1yA8/YTJoS29Et5a+AxP2jGX96cYHlOZEjoTj/FBNFSuuPVvvFEpjrRkQ8Oz9iNE/C6ltna8WKSUxQ==}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
'@oven/bun-windows-x64-baseline@1.1.1':
optional: true
/@oven/bun-windows-x64@1.1.1:
resolution: {integrity: sha512-oolhIph8Kah6K/7kPUjcqgc2N5lS6RD4yruwrG2QYhxcYWTh7m36Ngp709l8+trhLLaUyTnvr4MvuiKPl1cRjQ==}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
'@oven/bun-windows-x64@1.1.1':
optional: true
/async-lock@1.4.1:
resolution: {integrity: sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==}
dev: false
async-lock@1.4.1: {}
/bun@1.1.1:
resolution: {integrity: sha512-gV90TkJgHvI50X9BoKQ3zVpPEY6YP0vqOww2uZmsOyckZSRlcFYWhXZwFj6PV8KCFINYs8VZ65m59U2RuFYfWw==}
cpu: [arm64, x64]
os: [darwin, linux, win32]
hasBin: true
requiresBuild: true
bun@1.1.1:
optionalDependencies:
'@oven/bun-darwin-aarch64': 1.1.1
'@oven/bun-darwin-x64': 1.1.1
@ -131,62 +183,26 @@ packages:
'@oven/bun-linux-x64-baseline': 1.1.1
'@oven/bun-windows-x64': 1.1.1
'@oven/bun-windows-x64-baseline': 1.1.1
dev: false
/isomorphic.js@0.2.5:
resolution: {integrity: sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==}
dev: false
isomorphic.js@0.2.5: {}
/kleur@4.1.5:
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
engines: {node: '>=6'}
dev: false
kleur@4.1.5: {}
/lib0@0.2.93:
resolution: {integrity: sha512-M5IKsiFJYulS+8Eal8f+zAqf5ckm1vffW0fFDxfgxJ+uiVopvDdd3PxJmz0GsVi3YNO7QCFSq0nAsiDmNhLj9Q==}
engines: {node: '>=16'}
hasBin: true
lib0@0.2.93:
dependencies:
isomorphic.js: 0.2.5
dev: false
/typescript@5.4.4:
resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==}
engines: {node: '>=14.17'}
hasBin: true
dev: false
typescript@5.4.4: {}
/uuid@9.0.1:
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
hasBin: true
dev: false
uuid@9.0.1: {}
/ws@8.16.0:
resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
dev: false
ws@8.16.0: {}
/y-protocols@1.0.6(yjs@13.6.14):
resolution: {integrity: sha512-vHRF2L6iT3rwj1jub/K5tYcTT/mEYDUppgNPXwp8fmLpui9f7Yeq3OEtTLVF012j39QnV+KEQpNqoN7CWU7Y9Q==}
engines: {node: '>=16.0.0', npm: '>=8.0.0'}
peerDependencies:
yjs: ^13.0.0
y-protocols@1.0.6(yjs@13.6.14):
dependencies:
lib0: 0.2.93
yjs: 13.6.14
dev: false
/yjs@13.6.14:
resolution: {integrity: sha512-D+7KcUr0j+vBCUSKXXEWfA+bG4UQBviAwP3gYBhkstkgwy5+8diOPMx0iqLIOxNo/HxaREUimZRxqHGAHCL2BQ==}
engines: {node: '>=16.0.0', npm: '>=8.0.0'}
yjs@13.6.14:
dependencies:
lib0: 0.2.93
dev: false

6270
apps/web/pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -41,3 +41,7 @@ services:
interval: 5s
timeout: 4s
retries: 5
chromadb:
image: chromadb/chroma:latest
ports:
- "8000:8000"

952
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff