diff --git a/api/apps/file_app.py b/api/apps/file_app.py index 93fd3fdb389c7758dcb905fc6d3fe64838fff59f..b94c15506f4464ef4237c7fd9f69c4cdd84403e5 100644 --- a/api/apps/file_app.py +++ b/api/apps/file_app.py @@ -335,7 +335,7 @@ def get(file_id): response = flask.make_response(MINIO.get(file.parent_id, file.location)) ext = re.search(r"\.([^.]+)$", file.name) if ext: - if doc.type == FileType.VISUAL.value: + if file.type == FileType.VISUAL.value: response.headers.set('Content-Type', 'image/%s' % ext.group(1)) else: response.headers.set( diff --git a/rag/nlp/__init__.py b/rag/nlp/__init__.py index 61ba8401bb5ef98f2df2f2ed95ccf4aa7eeacbda..3a921c2ca6e1c2cfafc112b763fcfe394c9d2a02 100644 --- a/rag/nlp/__init__.py +++ b/rag/nlp/__init__.py @@ -28,11 +28,17 @@ all_codecs = [ def find_codec(blob): global all_codecs for c in all_codecs: + try: + blob[:1024].decode(c) + return c + except Exception as e: + pass try: blob.decode(c) return c except Exception as e: pass + return "utf-8"