Skip to content

Commit 5dbfb24

Browse files
chenliang15405alan.cl
andauthored
Fix ChatWithDbQA param validate (#2569)
Co-authored-by: alan.cl <alan.cl@antgroup.com>
1 parent e7b23f6 commit 5dbfb24

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/dbgpt-app/src/dbgpt_app/openapi/api_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async def chat_completions(
7676
"""Chat V2 completions
7777
Args:
7878
request (ChatCompletionRequestBody): The chat request.
79-
flow_service (FlowService): The flow service.
79+
service (FlowService): The flow service.
8080
Raises:
8181
HTTPException: If the request is invalid.
8282
"""

packages/dbgpt-app/src/dbgpt_app/scene/chat_db/professional_qa/chat.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,25 @@ def __init__(self, chat_param: ChatParam, system_app: SystemApp):
2828
- select_param:(str) dbname
2929
"""
3030
self.db_name = chat_param.select_param
31+
self.database = None
3132
self.curr_config = chat_param.real_app_config(ChatWithDBQAConfig)
3233
super().__init__(chat_param=chat_param, system_app=system_app)
3334

35+
if self.db_name is None:
36+
raise Exception(f"Database: {self.db_name} not found")
3437
if self.db_name:
3538
local_db_manager = ConnectorManager.get_instance(self.system_app)
3639
self.database = local_db_manager.get_connector(self.db_name)
3740
self.tables = self.database.get_table_names()
38-
if self.database.is_graph_type():
41+
if self.database is not None and self.database.is_graph_type():
3942
# When the current graph database retrieves source data from ChatDB, the
4043
# topk uses the sum of node table and edge table.
4144
self.top_k = len(list(self.tables))
4245
else:
43-
logger.info(f"Dialect: {self.database.db_type}")
46+
logger.info(
47+
"Dialect: "
48+
f"{self.database.db_type if self.database is not None else None}"
49+
)
4450
self.top_k = self.curr_config.schema_retrieve_top_k
4551

4652
@trace()

packages/dbgpt-serve/src/dbgpt_serve/agent/db/gpts_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ def adapt_native_app_model(dialogue: ConversationVo):
13911391
ChatScene.ChatWithDbQA.value(),
13921392
ChatScene.ChatWithDbExecute.value(),
13931393
ChatScene.ChatDashboard.value(),
1394-
ChatScene.ChatNormal.value,
1394+
ChatScene.ChatNormal.value(),
13951395
]:
13961396
return dialogue
13971397
gpts_dao = GptsAppDao()

0 commit comments

Comments
 (0)