RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Clean query. (#4259)
Kevin Huf948c0d9f1fa
diff --git a/agent/component/__init__.py b/agent/component/__init__.pyindex c124136b08..0d414fca99 100644--- a/agent/component/__init__.py+++ b/agent/component/__init__.py@@ -36,12 +36,12 @@ from .iteration import Iteration, IterationParamfrom .iterationitem import IterationItem, IterationItemParam-def component_class(class_name):m = importlib.import_module("agent.component")c = getattr(m, class_name)return c+__all__ = ["Begin","BeginParam",diff --git a/rag/nlp/query.py b/rag/nlp/query.pyindex 2d94a96c7b..ab5c22e329 100644--- a/rag/nlp/query.py+++ b/rag/nlp/query.py@@ -59,7 +59,7 @@ class FulltextQueryer:"",),(r"(^| )(what|who|how|which|where|why)('re|'s)? ", " "),- (r"(^| )('s|'re|is|are|were|was|do|does|did|don't|doesn't|didn't|has|have|be|there|you|me|your|my|mine|just|please|may|i|should|would|wouldn't|will|won't|done|go|for|with|so|the|a|an|by|i'm|it's|he's|she's|they|they're|you're|as|by|on|in|at|up|out|down|of) ", " ")+ (r"(^| )('s|'re|is|are|were|was|do|does|did|don't|doesn't|didn't|has|have|be|there|you|me|your|my|mine|just|please|may|i|should|would|wouldn't|will|won't|done|go|for|with|so|the|a|an|by|i'm|it's|he's|she's|they|they're|you're|as|by|on|in|at|up|out|down|of|to|or|and|if) ", " ")]for r, p in patts:txt = re.sub(r, p, txt, flags=re.IGNORECASE)@@ -67,7 +67,7 @@ class FulltextQueryer:def question(self, txt, tbl="qa", min_match:float=0.6):txt = re.sub(- r"[ :\r\n\t,,。??/`!!&\^%%()^\[\]]+",+ r"[ :|\r\n\t,,。??/`!!&^%%()\[\]{}<>]+"," ",rag_tokenizer.tradi2simp(rag_tokenizer.strQ2B(txt.lower())),).strip()@@ -81,16 +81,20 @@ class FulltextQueryer:tks_w = [(re.sub(r"[ \\\"'^]", "", tk), w) for tk, w in tks_w]tks_w = [(re.sub(r"^[a-z0-9]$", "", tk), w) for tk, w in tks_w if tk]tks_w = [(re.sub(r"^[\+-]", "", tk), w) for tk, w in tks_w if tk]+ tks_w = [(tk.strip(), w) for tk, w in tks_w if tk.strip()]syns = []for tk, w in tks_w:syn = self.syn.lookup(tk)syn = rag_tokenizer.tokenize(" ".join(syn)).split()keywords.extend(syn)- syn = ["\"{}\"^{:.4f}".format(s, w / 4.) for s in syn if s]+ syn = ["\"{}\"^{:.4f}".format(s, w / 4.) for s in syn if s.strip()]syns.append(" ".join(syn))q = ["({}^{:.4f}".format(tk, w) + " {})".format(syn) for (tk, w), syn in zip(tks_w, syns) if tk and not re.match(r"[.^+\(\)-]", tk)]for i in range(1, len(tks_w)):+ left, right = tks_w[i - 1][0].strip(), tks_w[i][0].strip()+ if not left or not right:+ continueq.append('"%s %s"^%.4f'% (