Sfoglia il codice sorgente

refine error log while chunking (#1937)

### What problem does this PR solve?



### Type of change

- [x] Refactoring
tags/v0.10.0
Kevin Hu 1 anno fa
parent
commit
da8802d010
Nessun account collegato all'indirizzo email del committer
2 ha cambiato i file con 19 aggiunte e 12 eliminazioni
  1. 3
    1
      api/apps/document_app.py
  2. 16
    11
      rag/svr/task_executor.py

+ 3
- 1
api/apps/document_app.py Vedi File

@@ -501,7 +501,9 @@ def upload_and_parse():
"callback": dummy,
"parser_config": parser_config,
"from_page": 0,
"to_page": 100000
"to_page": 100000,
"tenant_id": kb.tenant_id,
"lang": kb.language
}
threads.append(exe.submit(FACTORY.get(d["parser_id"], naive).chunk, d["name"], blob, **kwargs))

+ 16
- 11
rag/svr/task_executor.py Vedi File

@@ -146,27 +146,32 @@ def build(row):
binary = get_minio_binary(bucket, name)
cron_logger.info(
"From minio({}) {}/{}".format(timer() - st, row["location"], row["name"]))
cks = chunker.chunk(row["name"], binary=binary, from_page=row["from_page"],
to_page=row["to_page"], lang=row["language"], callback=callback,
kb_id=row["kb_id"], parser_config=row["parser_config"], tenant_id=row["tenant_id"])
cron_logger.info(
"Chunkking({}) {}/{}".format(timer() - st, row["location"], row["name"]))
except TimeoutError as e:
callback(-1, f"Internal server error: Fetch file timeout. Could you try it again.")
callback(-1, f"Internal server error: Fetch file from minio timeout. Could you try it again.")
cron_logger.error(
"Chunkking {}/{}: Fetch file timeout.".format(row["location"], row["name"]))
"Minio {}/{}: Fetch file from minio timeout.".format(row["location"], row["name"]))
return
except Exception as e:
if re.search("(No such file|not found)", str(e)):
callback(-1, "Can not find file <%s>" % row["name"])
callback(-1, "Can not find file <%s> from minio. Could you try it again?" % row["name"])
else:
callback(-1, f"Internal server error: %s" %
callback(-1, f"Get file from minio: %s" %
str(e).replace("'", ""))
traceback.print_exc()
return

try:
cks = chunker.chunk(row["name"], binary=binary, from_page=row["from_page"],
to_page=row["to_page"], lang=row["language"], callback=callback,
kb_id=row["kb_id"], parser_config=row["parser_config"], tenant_id=row["tenant_id"])
cron_logger.info(
"Chunking({}) {}/{}".format(timer() - st, row["location"], row["name"]))
except Exception as e:
callback(-1, f"Internal server error while chunking: %s" %
str(e).replace("'", ""))
cron_logger.error(
"Chunkking {}/{}: {}".format(row["location"], row["name"], str(e)))

"Chunking {}/{}: {}".format(row["location"], row["name"], str(e)))
traceback.print_exc()
return

docs = []

Loading…
Annulla
Salva