diff --git a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v2.py b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v2.py index cb3454828..ec8865eb6 100644 --- a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v2.py +++ b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v2.py @@ -76,7 +76,7 @@ async def chat_completions( """Chat V2 completions Args: request (ChatCompletionRequestBody): The chat request. - flow_service (FlowService): The flow service. + service (FlowService): The flow service. Raises: HTTPException: If the request is invalid. """ diff --git a/packages/dbgpt-app/src/dbgpt_app/scene/chat_db/professional_qa/chat.py b/packages/dbgpt-app/src/dbgpt_app/scene/chat_db/professional_qa/chat.py index 28529ba7b..d5406d6d9 100644 --- a/packages/dbgpt-app/src/dbgpt_app/scene/chat_db/professional_qa/chat.py +++ b/packages/dbgpt-app/src/dbgpt_app/scene/chat_db/professional_qa/chat.py @@ -28,19 +28,25 @@ class ChatWithDbQA(BaseChat): - select_param:(str) dbname """ self.db_name = chat_param.select_param + self.database = None self.curr_config = chat_param.real_app_config(ChatWithDBQAConfig) super().__init__(chat_param=chat_param, system_app=system_app) + if self.db_name is None: + raise Exception(f"Database: {self.db_name} not found") if self.db_name: local_db_manager = ConnectorManager.get_instance(self.system_app) self.database = local_db_manager.get_connector(self.db_name) self.tables = self.database.get_table_names() - if self.database.is_graph_type(): + if self.database is not None and self.database.is_graph_type(): # When the current graph database retrieves source data from ChatDB, the # topk uses the sum of node table and edge table. self.top_k = len(list(self.tables)) else: - logger.info(f"Dialect: {self.database.db_type}") + logger.info( + "Dialect: " + f"{self.database.db_type if self.database is not None else None}" + ) self.top_k = self.curr_config.schema_retrieve_top_k @trace() diff --git a/packages/dbgpt-serve/src/dbgpt_serve/agent/db/gpts_app.py b/packages/dbgpt-serve/src/dbgpt_serve/agent/db/gpts_app.py index d898ed0e1..a2cd35eb3 100644 --- a/packages/dbgpt-serve/src/dbgpt_serve/agent/db/gpts_app.py +++ b/packages/dbgpt-serve/src/dbgpt_serve/agent/db/gpts_app.py @@ -1391,7 +1391,7 @@ def adapt_native_app_model(dialogue: ConversationVo): ChatScene.ChatWithDbQA.value(), ChatScene.ChatWithDbExecute.value(), ChatScene.ChatDashboard.value(), - ChatScene.ChatNormal.value, + ChatScene.ChatNormal.value(), ]: return dialogue gpts_dao = GptsAppDao()