mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: support select terminology in chat by using assistant
This commit is contained in:
@@ -220,7 +220,8 @@ class LLMService:
|
||||
self.chat_question.data = orjson.dumps(data.get('data')).decode()
|
||||
analysis_msg: List[Union[BaseMessage, dict[str, Any]]] = []
|
||||
|
||||
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question, self.current_user.oid)
|
||||
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question,
|
||||
self.current_user.oid)
|
||||
|
||||
analysis_msg.append(SystemMessage(content=self.chat_question.analysis_sys_question()))
|
||||
analysis_msg.append(HumanMessage(content=self.chat_question.analysis_user_question()))
|
||||
@@ -498,6 +499,10 @@ class LLMService:
|
||||
answer=orjson.dumps({'content': full_text}).decode(),
|
||||
datasource=_datasource,
|
||||
engine_type=_engine_type)
|
||||
|
||||
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question,
|
||||
self.ds.oid if isinstance(self.ds,
|
||||
CoreDatasource) else 1)
|
||||
self.init_messages()
|
||||
|
||||
if _error:
|
||||
@@ -894,7 +899,10 @@ class LLMService:
|
||||
|
||||
def run_task(self, in_chat: bool = True):
|
||||
try:
|
||||
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question, self.current_user.oid)
|
||||
if self.ds:
|
||||
self.chat_question.terminologies = get_terminology_template(self.session, self.chat_question.question,
|
||||
self.ds.oid if isinstance(self.ds,
|
||||
CoreDatasource) else 1)
|
||||
self.init_messages()
|
||||
|
||||
# return id
|
||||
|
||||
@@ -418,7 +418,9 @@ def to_xml_string(_dict: list[dict] | dict, root: str = 'terminologies') -> str:
|
||||
return pretty_xml
|
||||
|
||||
|
||||
def get_terminology_template(session: SessionDep, question: str, oid: int) -> str:
|
||||
def get_terminology_template(session: SessionDep, question: str, oid: Optional[int] = 1) -> str:
|
||||
if not oid:
|
||||
oid = 1
|
||||
_results = select_terminology_by_word(session, question, oid)
|
||||
if _results and len(_results) > 0:
|
||||
terminology = to_xml_string(_results)
|
||||
|
||||
Reference in New Issue
Block a user