Skip to content

Commit 449d65d

Browse files
committed
fix: MCP auto select datasource error
1 parent 144c67a commit 449d65d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

backend/apps/chat/task/llm.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,14 @@ def select_datasource(self):
520520
answer=orjson.dumps({'content': full_text}).decode(),
521521
datasource=_datasource,
522522
engine_type=_engine_type)
523+
if self.ds:
524+
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question,
525+
self.ds.oid if isinstance(self.ds,
526+
CoreDatasource) else 1)
527+
self.chat_question.data_training = get_training_template(self.session, self.chat_question.question,
528+
self.ds.id, self.ds.oid)
523529

524-
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question,
525-
self.ds.oid if isinstance(self.ds,
526-
CoreDatasource) else 1)
527-
self.chat_question.data_training = get_training_template(self.session, self.chat_question.question,
528-
self.ds.id, self.ds.oid)
529-
530-
self.init_messages()
530+
self.init_messages()
531531

532532
if _error:
533533
raise _error
@@ -1110,6 +1110,7 @@ def run_task(self, in_chat: bool = True):
11101110
SQLBotLogUtil.info(image_url)
11111111
yield f'![{chart["type"]}]({image_url})'
11121112
except Exception as e:
1113+
traceback.print_exc()
11131114
error_msg: str
11141115
if isinstance(e, SingleMessageError):
11151116
error_msg = str(e)

0 commit comments

Comments
 (0)