Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

resolve table issues (#125)

KevinHuShde09b0e1a4f1
diff --git a/Dockerfile b/Dockerfile
index 49d3045cc1..c174ccb800 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,7 +14,6 @@ ADD ./rag ./rag
ENV PYTHONPATH=/ragflow/
ENV HF_ENDPOINT=https://hf-mirror.com
-/root/miniconda3/envs/py11/bin/pip install peewee==3.17.1
ADD docker/entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
diff --git a/Dockerfile.cuda b/Dockerfile.cuda
index a5db6177dc..2bed3fb61e 100644
--- a/Dockerfile.cuda
+++ b/Dockerfile.cuda
@@ -19,7 +19,6 @@ ADD ./rag ./rag
ENV PYTHONPATH=/ragflow/
ENV HF_ENDPOINT=https://hf-mirror.com
-/root/miniconda3/envs/py11/bin/pip install peewee==3.17.1
ADD docker/entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
diff --git a/api/apps/conversation_app.py b/api/apps/conversation_app.py
index ef99a162c6..648ecd3d91 100644
--- a/api/apps/conversation_app.py
+++ b/api/apps/conversation_app.py
@@ -309,6 +309,7 @@ def use_sql(question, field_map, tenant_id, chat_mdl):
# compose markdown table
clmns = "|"+"|".join([re.sub(r"(/.*|([^()]+))", "", field_map.get(tbl["columns"][i]["name"], tbl["columns"][i]["name"])) for i in clmn_idx]) + ("|原文|" if docid_idx and docid_idx else "|")
line = "|"+"|".join(["------" for _ in range(len(clmn_idx))]) + ("|------|" if docid_idx and docid_idx else "")
+ line = re.sub(r"T[0-9]{2}:[0-9]{2}:[0-9]{2}\|", "|", line)
rows = ["|"+"|".join([rmSpace(str(r[i])) for i in clmn_idx]).replace("None", " ") + "|" for r in tbl["rows"]]
if not docid_idx or not docnm_idx:
chat_logger.warning("SQL missing field: " + sql)
diff --git a/api/db/init_data.py b/api/db/init_data.py
index de201d3d0f..189e5437be 100644
--- a/api/db/init_data.py
+++ b/api/db/init_data.py
@@ -94,7 +94,7 @@ def init_llm_factory():
"name": "Local",
"logo": "",
"tags": "LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION",
- "status": "0",
+ "status": "1",
},{
"name": "Moonshot",
"logo": "",
diff --git a/api/db/services/knowledgebase_service.py b/api/db/services/knowledgebase_service.py
index 46fe4bcdf5..be2c96400f 100644
--- a/api/db/services/knowledgebase_service.py
+++ b/api/db/services/knowledgebase_service.py
@@ -78,7 +78,7 @@ class KnowledgebaseService(CommonService):
if isinstance(v, dict):
assert isinstance(old[k], dict)
dfs_update(old[k], v)
- if isinstance(v, list):
+ elif isinstance(v, list):
assert isinstance(old[k], list)
old[k] = list(set(old[k]+v))
else: old[k] = v
diff --git a/rag/app/table.py b/rag/app/table.py
index 3b6cff38ea..6f40da48d7 100644
--- a/rag/app/table.py
+++ b/rag/app/table.py
@@ -73,9 +73,9 @@ def trans_datatime(s):
def trans_bool(s):
- if re.match(r"(true|yes|是)$", str(s).strip(), flags=re.IGNORECASE):
+ if re.match(r"(true|yes|是|\*|✓|✔|☑|✅|√)$", str(s).strip(), flags=re.IGNORECASE):
return ["yes", "是"]
- if re.match(r"(false|no|否)$", str(s).strip(), flags=re.IGNORECASE):
+ if re.match(r"(false|no|否|⍻|×)$", str(s).strip(), flags=re.IGNORECASE):
return ["no", "否"]
@@ -107,9 +107,9 @@ def column_data_type(arr):
arr[i] = trans[ty](str(arr[i]))
except Exception as e:
arr[i] = None
- if ty == "text":
- if len(arr) > 128 and uni / len(arr) < 0.1:
- ty = "keyword"
+ #if ty == "text":
+ # if len(arr) > 128 and uni / len(arr) < 0.1:
+ # ty = "keyword"
return arr, ty
@@ -170,7 +170,7 @@ def chunk(filename, binary=None, from_page=0, to_page=10000000000, lang="Chinese
PY = Pinyin()
fieds_map = {
"text": "_tks",
- "int": "_int",
+ "int": "_long",
"keyword": "_kwd",
"float": "_flt",
"datetime": "_dt",
@@ -189,7 +189,7 @@ def chunk(filename, binary=None, from_page=0, to_page=10000000000, lang="Chinese
df[clmns[j]] = cln
if ty == "text":
txts.extend([str(c) for c in cln if c])
- clmns_map = [(py_clmns[i] + fieds_map[clmn_tys[i]], clmns[i].replace("_", " "))
+ clmns_map = [(py_clmns[i].lower() + fieds_map[clmn_tys[i]], clmns[i].replace("_", " "))
for i in range(len(clmns))]
eng = lang.lower() == "english"#is_english(txts)
@@ -204,6 +204,8 @@ def chunk(filename, binary=None, from_page=0, to_page=10000000000, lang="Chinese
continue
if not str(row[clmns[j]]):
continue
+ if pd.isna(row[clmns[j]]):
+ continue
fld = clmns_map[j][0]
d[fld] = row[clmns[j]] if clmn_tys[j] != "text" else huqie.qie(
row[clmns[j]])
@@ -223,7 +225,7 @@ def chunk(filename, binary=None, from_page=0, to_page=10000000000, lang="Chinese
if __name__ == "__main__":
import sys
- def dummy(a, b):
+ def dummy(prog=None, msg=""):
pass
chunk(sys.argv[1], callback=dummy)
diff --git a/rag/utils/__init__.py b/rag/utils/__init__.py
index 4de8d19076..2ff34b35a8 100644
--- a/rag/utils/__init__.py
+++ b/rag/utils/__init__.py
@@ -19,8 +19,8 @@ from .minio_conn import MINIO
from .es_conn import ELASTICSEARCH
def rmSpace(txt):
- txt = re.sub(r"([^a-z0-9.,]) +([^ ])", r"\1\2", txt)
- return re.sub(r"([^ ]) +([^a-z0-9.,])", r"\1\2", txt)
+ txt = re.sub(r"([^a-z0-9.,]) +([^ ])", r"\1\2", txt, flags=re.IGNORECASE)
+ return re.sub(r"([^ ]) +([^a-z0-9.,])", r"\1\2", txt, flags=re.IGNORECASE)
def findMaxDt(fnm):