Skip to content

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

Fix: ollama model list issue. (#11175)

Kevin Huc30ffb57162d
diff --git a/api/apps/llm_app.py b/api/apps/llm_app.py
index 4c40b8878b..c34d71cc06 100644
--- a/api/apps/llm_app.py
+++ b/api/apps/llm_app.py
@@ -358,7 +358,7 @@ def list_app():
for o in objs:
if o.llm_name + "@" + o.llm_factory in llm_set:
continue
- llms.append({"llm_name": o.llm_name, "model_type": o.model_type, "fid": o.llm_factory, "available": True})
+ llms.append({"llm_name": o.llm_name, "model_type": o.model_type, "fid": o.llm_factory, "available": True, "status": StatusEnum.VALID.value})
res = {}
for m in llms:
diff --git a/api/db/init_data.py b/api/db/init_data.py
index c09de65325..c9c117e5ec 100644
--- a/api/db/init_data.py
+++ b/api/db/init_data.py
@@ -101,6 +101,7 @@ def init_llm_factory():
info = deepcopy(factory_llm_info)
llm_infos = info.pop("llm")
try:
+ LLMFactoriesService.filter_delete([LLMFactories.name == factory_llm_info["name"]])
LLMFactoriesService.save(**info)
except Exception:
pass
diff --git a/api/db/services/document_service.py b/api/db/services/document_service.py
index 0f8dc47521..198028210a 100644
--- a/api/db/services/document_service.py
+++ b/api/db/services/document_service.py
@@ -846,7 +846,7 @@ def queue_raptor_o_graphrag_tasks(sample_doc_id, ty, priority, fake_doc_id="", d
"to_page": 100000000,
"task_type": ty,
"progress_msg": datetime.now().strftime("%H:%M:%S") + " created task " + ty,
- "begin_at": datetime.now(),
+ "begin_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
}
task = new_task()
diff --git a/rag/raptor.py b/rag/raptor.py
index 5dfe33dd30..e6efe35044 100644
--- a/rag/raptor.py
+++ b/rag/raptor.py
@@ -97,7 +97,7 @@ class RecursiveAbstractiveProcessing4TreeOrganizedRetrieval:
async def __call__(self, chunks, random_state, callback=None, task_id: str = ""):
if len(chunks) <= 1:
return []
- chunks = [(s, a) for s, a in chunks if s and a and len(a) > 0]
+ chunks = [(s, a) for s, a in chunks if s and a is not None and len(a) > 0]
layers = [(0, len(chunks))]
start, end = 0, len(chunks)
diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py
index 1de9c16467..9b309ee68d 100644
--- a/rag/svr/task_executor.py
+++ b/rag/svr/task_executor.py
@@ -647,7 +647,7 @@ async def run_raptor_for_kb(row, kb_parser_config, chat_mdl, embd_mdl, vector_si
res = []
tk_count = 0
- async def generate(chunks):
+ async def generate(chunks, did):
nonlocal tk_count, res
raptor = Raptor(
raptor_config.get("max_cluster", 64),
@@ -660,7 +660,7 @@ async def run_raptor_for_kb(row, kb_parser_config, chat_mdl, embd_mdl, vector_si
original_length = len(chunks)
chunks = await raptor(chunks, kb_parser_config["raptor"]["random_seed"], callback, row["id"])
doc = {
- "doc_id": fake_doc_id,
+ "doc_id": did,
"kb_id": [str(row["kb_id"])],
"docnm_kwd": row["name"],
"title_tks": rag_tokenizer.tokenize(row["name"]),
@@ -688,9 +688,8 @@ async def run_raptor_for_kb(row, kb_parser_config, chat_mdl, embd_mdl, vector_si
fields=["content_with_weight", vctr_nm],
sort_by_position=True):
chunks.append((d["content_with_weight"], np.array(d[vctr_nm])))
- callback(progress=(x+1.)/len(doc_ids))
- await generate(chunks)
-
+ await generate(chunks, doc_id)
+ callback(prog=(x+1.)/len(doc_ids))
else:
chunks = []
for doc_id in doc_ids:
@@ -699,7 +698,7 @@ async def run_raptor_for_kb(row, kb_parser_config, chat_mdl, embd_mdl, vector_si
sort_by_position=True):
chunks.append((d["content_with_weight"], np.array(d[vctr_nm])))
- await generate(chunks)
+ await generate(chunks, fake_doc_id)
return res, tk_count