mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 05:19:05 +08:00
refine components retrieval and rewrite (#2818)
### What problem does this PR solve? ### Type of change - [x] Performance Improvement
This commit is contained in:
parent
a20b82092f
commit
7d80fc474c
@ -50,12 +50,15 @@ class Retrieval(ComponentBase, ABC):
|
|||||||
component_name = "Retrieval"
|
component_name = "Retrieval"
|
||||||
|
|
||||||
def _run(self, history, **kwargs):
|
def _run(self, history, **kwargs):
|
||||||
query = []
|
# query = []
|
||||||
for role, cnt in history[::-1][:self._param.message_history_window_size]:
|
# for role, cnt in history[::-1][:self._param.message_history_window_size]:
|
||||||
if role != "user":continue
|
# if role != "user":continue
|
||||||
query.append(cnt)
|
# query.append(cnt)
|
||||||
# query = "\n".join(query)
|
# # query = "\n".join(query)
|
||||||
query = query[0]
|
# query = query[0]
|
||||||
|
query = self.get_input()
|
||||||
|
query = str(query["content"][0]) if "content" in query else ""
|
||||||
|
|
||||||
kbs = KnowledgebaseService.get_by_ids(self._param.kb_ids)
|
kbs = KnowledgebaseService.get_by_ids(self._param.kb_ids)
|
||||||
if not kbs:
|
if not kbs:
|
||||||
raise ValueError("Can't find knowledgebases by {}".format(self._param.kb_ids))
|
raise ValueError("Can't find knowledgebases by {}".format(self._param.kb_ids))
|
||||||
|
@ -91,7 +91,11 @@ class RewriteQuestion(Generate, ABC):
|
|||||||
raise Exception("Sorry! Nothing relevant found.")
|
raise Exception("Sorry! Nothing relevant found.")
|
||||||
self._loop += 1
|
self._loop += 1
|
||||||
|
|
||||||
conv = self._canvas.get_history(4)
|
hist = self._canvas.get_history(4)
|
||||||
|
conv = []
|
||||||
|
for m in hist:
|
||||||
|
if m["role"] not in ["user", "assistant"]: continue
|
||||||
|
conv.append("{}: {}".format(m["role"].upper(), m["content"]))
|
||||||
conv = "\n".join(conv)
|
conv = "\n".join(conv)
|
||||||
|
|
||||||
chat_mdl = LLMBundle(self._canvas.get_tenant_id(), LLMType.CHAT, self._param.llm_id)
|
chat_mdl = LLMBundle(self._canvas.get_tenant_id(), LLMType.CHAT, self._param.llm_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user