Merge branch 'refs/heads/main' into dbgpts_hub_dev

# Conflicts:
#	dbgpt/app/initialization/serve_initialization.py
This commit is contained in:
yhjun1026
2024-08-23 15:05:35 +08:00
67 changed files with 8289 additions and 190 deletions

View File

@@ -52,17 +52,17 @@ def initialize_components(
param, system_app, embedding_model_name, embedding_model_path
)
_initialize_rerank_model(param, system_app, rerank_model_name, rerank_model_path)
_initialize_model_cache(system_app)
_initialize_model_cache(system_app, param.port)
_initialize_awel(system_app, param)
# Initialize resource manager of agent
_initialize_resource_manager(system_app)
_initialize_agent(system_app)
_initialize_openapi(system_app)
# Register serve apps
register_serve_apps(system_app, CFG)
register_serve_apps(system_app, CFG, param.port)
def _initialize_model_cache(system_app: SystemApp):
def _initialize_model_cache(system_app: SystemApp, port: int):
from dbgpt.storage.cache import initialize_cache
if not CFG.MODEL_CACHE_ENABLE:
@@ -72,6 +72,8 @@ def _initialize_model_cache(system_app: SystemApp):
storage_type = CFG.MODEL_CACHE_STORAGE_TYPE or "disk"
max_memory_mb = CFG.MODEL_CACHE_MAX_MEMORY_MB or 256
persist_dir = CFG.MODEL_CACHE_STORAGE_DISK_DIR or MODEL_DISK_CACHE_DIR
if CFG.WEBSERVER_MULTI_INSTANCE:
persist_dir = f"{persist_dir}_{port}"
initialize_cache(system_app, storage_type, max_memory_mb, persist_dir)

View File

@@ -1,5 +1,6 @@
"""Import all models to make sure they are registered with SQLAlchemy.
"""
from dbgpt.app.knowledge.chunk_db import DocumentChunkEntity
from dbgpt.app.knowledge.document_db import KnowledgeDocumentEntity
from dbgpt.app.openapi.api_v1.feedback.feed_back_db import ChatFeedBackEntity
@@ -10,7 +11,9 @@ from dbgpt.serve.agent.app.recommend_question.recommend_question import (
)
from dbgpt.serve.agent.hub.db.my_plugin_db import MyPluginEntity
from dbgpt.serve.agent.hub.db.plugin_hub_db import PluginHubEntity
from dbgpt.serve.file.models.models import ServeEntity as FileServeEntity
from dbgpt.serve.flow.models.models import ServeEntity as FlowServeEntity
from dbgpt.serve.flow.models.models import VariablesEntity as FlowVariableEntity
from dbgpt.serve.prompt.models.models import ServeEntity as PromptManageEntity
from dbgpt.serve.rag.models.models import KnowledgeSpaceEntity
from dbgpt.storage.chat_history.chat_history_db import (
@@ -20,6 +23,7 @@ from dbgpt.storage.chat_history.chat_history_db import (
_MODELS = [
PluginHubEntity,
FileServeEntity,
MyPluginEntity,
PromptManageEntity,
KnowledgeSpaceEntity,
@@ -32,4 +36,5 @@ _MODELS = [
ModelInstanceEntity,
FlowServeEntity,
RecommendQuestionEntity,
FlowVariableEntity,
]

View File

@@ -2,11 +2,13 @@ from dbgpt._private.config import Config
from dbgpt.component import SystemApp
def register_serve_apps(system_app: SystemApp, cfg: Config):
def register_serve_apps(system_app: SystemApp, cfg: Config, webserver_port: int):
"""Register serve apps"""
system_app.config.set("dbgpt.app.global.language", cfg.LANGUAGE)
if cfg.API_KEYS:
system_app.config.set("dbgpt.app.global.api_keys", cfg.API_KEYS)
if cfg.ENCRYPT_KEY:
system_app.config.set("dbgpt.app.global.encrypt_key", cfg.ENCRYPT_KEY)
# ################################ Prompt Serve Register Begin ######################################
from dbgpt.serve.prompt.serve import (
@@ -45,6 +47,8 @@ def register_serve_apps(system_app: SystemApp, cfg: Config):
# Register serve app
system_app.register(FlowServe)
# ################################ AWEL Flow Serve Register End ########################################
# ################################ Rag Serve Register Begin ######################################
from dbgpt.serve.rag.serve import (
@@ -55,6 +59,8 @@ def register_serve_apps(system_app: SystemApp, cfg: Config):
# Register serve app
system_app.register(RagServe)
# ################################ Rag Serve Register End ########################################
# ################################ Datasource Serve Register Begin ######################################
from dbgpt.serve.datasource.serve import (
@@ -64,7 +70,8 @@ def register_serve_apps(system_app: SystemApp, cfg: Config):
# Register serve app
system_app.register(DatasourceServe)
# ################################ AWEL Flow Serve Register End ########################################
# ################################ Datasource Serve Register End ########################################
# ################################ Chat Feedback Serve Register End ########################################
from dbgpt.serve.feedback.serve import (
@@ -86,3 +93,32 @@ def register_serve_apps(system_app: SystemApp, cfg: Config):
system_app.register(DbgptsMyServe)
# ################################ DbGpts Register End ########################################
# ################################ File Serve Register Begin ######################################
from dbgpt.configs.model_config import FILE_SERVER_LOCAL_STORAGE_PATH
from dbgpt.serve.file.serve import (
SERVE_CONFIG_KEY_PREFIX as FILE_SERVE_CONFIG_KEY_PREFIX,
)
from dbgpt.serve.file.serve import Serve as FileServe
local_storage_path = (
cfg.FILE_SERVER_LOCAL_STORAGE_PATH or FILE_SERVER_LOCAL_STORAGE_PATH
)
if cfg.WEBSERVER_MULTI_INSTANCE:
local_storage_path = f"{local_storage_path}_{webserver_port}"
# Set config
system_app.config.set(
f"{FILE_SERVE_CONFIG_KEY_PREFIX}local_storage_path", local_storage_path
)
system_app.config.set(
f"{FILE_SERVE_CONFIG_KEY_PREFIX}file_server_port", webserver_port
)
if cfg.FILE_SERVER_HOST:
system_app.config.set(
f"{FILE_SERVE_CONFIG_KEY_PREFIX}file_server_host", cfg.FILE_SERVER_HOST
)
# Register serve app
system_app.register(FileServe)
# ################################ File Serve Register End ########################################