mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-02 16:45:08 +08:00
Fix: toc async issue. (#12485)
### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -193,7 +193,7 @@ class Retrieval(ToolBase, ABC):
|
|||||||
|
|
||||||
if self._param.toc_enhance:
|
if self._param.toc_enhance:
|
||||||
chat_mdl = LLMBundle(self._canvas._tenant_id, LLMType.CHAT)
|
chat_mdl = LLMBundle(self._canvas._tenant_id, LLMType.CHAT)
|
||||||
cks = settings.retriever.retrieval_by_toc(query, kbinfos["chunks"], [kb.tenant_id for kb in kbs],
|
cks = await settings.retriever.retrieval_by_toc(query, kbinfos["chunks"], [kb.tenant_id for kb in kbs],
|
||||||
chat_mdl, self._param.top_n)
|
chat_mdl, self._param.top_n)
|
||||||
if self.check_if_canceled("Retrieval processing"):
|
if self.check_if_canceled("Retrieval processing"):
|
||||||
return
|
return
|
||||||
|
|||||||
@ -1575,7 +1575,7 @@ async def retrieval_test(tenant_id):
|
|||||||
)
|
)
|
||||||
if toc_enhance:
|
if toc_enhance:
|
||||||
chat_mdl = LLMBundle(kb.tenant_id, LLMType.CHAT)
|
chat_mdl = LLMBundle(kb.tenant_id, LLMType.CHAT)
|
||||||
cks = settings.retriever.retrieval_by_toc(question, ranks["chunks"], tenant_ids, chat_mdl, size)
|
cks = await settings.retriever.retrieval_by_toc(question, ranks["chunks"], tenant_ids, chat_mdl, size)
|
||||||
if cks:
|
if cks:
|
||||||
ranks["chunks"] = cks
|
ranks["chunks"] = cks
|
||||||
if use_kg:
|
if use_kg:
|
||||||
|
|||||||
@ -411,7 +411,7 @@ async def async_chat(dialog, messages, stream=True, **kwargs):
|
|||||||
rank_feature=label_question(" ".join(questions), kbs),
|
rank_feature=label_question(" ".join(questions), kbs),
|
||||||
)
|
)
|
||||||
if prompt_config.get("toc_enhance"):
|
if prompt_config.get("toc_enhance"):
|
||||||
cks = retriever.retrieval_by_toc(" ".join(questions), kbinfos["chunks"], tenant_ids, chat_mdl, dialog.top_n)
|
cks = await retriever.retrieval_by_toc(" ".join(questions), kbinfos["chunks"], tenant_ids, chat_mdl, dialog.top_n)
|
||||||
if cks:
|
if cks:
|
||||||
kbinfos["chunks"] = cks
|
kbinfos["chunks"] = cks
|
||||||
kbinfos["chunks"] = retriever.retrieval_by_children(kbinfos["chunks"], tenant_ids)
|
kbinfos["chunks"] = retriever.retrieval_by_children(kbinfos["chunks"], tenant_ids)
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
import asyncio
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
@ -589,7 +588,7 @@ class Dealer:
|
|||||||
key=lambda x: x[1] * -1)[:topn_tags]
|
key=lambda x: x[1] * -1)[:topn_tags]
|
||||||
return {a.replace(".", "_"): max(1, c) for a, c in tag_fea}
|
return {a.replace(".", "_"): max(1, c) for a, c in tag_fea}
|
||||||
|
|
||||||
def retrieval_by_toc(self, query: str, chunks: list[dict], tenant_ids: list[str], chat_mdl, topn: int = 6):
|
async def retrieval_by_toc(self, query: str, chunks: list[dict], tenant_ids: list[str], chat_mdl, topn: int = 6):
|
||||||
if not chunks:
|
if not chunks:
|
||||||
return []
|
return []
|
||||||
idx_nms = [index_name(tid) for tid in tenant_ids]
|
idx_nms = [index_name(tid) for tid in tenant_ids]
|
||||||
@ -614,7 +613,7 @@ class Dealer:
|
|||||||
if not toc:
|
if not toc:
|
||||||
return chunks
|
return chunks
|
||||||
|
|
||||||
ids = asyncio.run(relevant_chunks_with_toc(query, toc, chat_mdl, topn * 2))
|
ids = await relevant_chunks_with_toc(query, toc, chat_mdl, topn * 2)
|
||||||
if not ids:
|
if not ids:
|
||||||
return chunks
|
return chunks
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user