Files
ragflow/api/db/__init__.py

93 lines
2.7 KiB
Python
Raw Normal View History

#
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from enum import IntEnum
feat: bump Python minimum from 3.12 to 3.13, drop strenum backport (#14767) Closes #14753 ## What changed | File | Change | |---|---| | `pyproject.toml` | `requires-python` → `>=3.13,<3.15`; remove `strenum==0.4.15` | | `Dockerfile` | `uv python install 3.13`, `uv sync --python 3.13` | | `.github/workflows/tests.yml` | `uv sync --python 3.13` on both matrix legs | | `CLAUDE.md` | dev setup command + requirements note updated | | `deepdoc/parser/mineru_parser.py` | `from strenum import StrEnum` → `from enum import StrEnum` | | `agent/tools/code_exec.py` | same | `StrEnum` has been in the stdlib since Python 3.11 — the `strenum` backport package is no longer needed once the floor is 3.13. ## Why uv.lock is not regenerated `uv lock --python 3.13` fails because: 1. The infiniflow/graspologic fork pins `numpy>=1.26.4,<2.0.0` 2. `tensorflow-cpu>=2.20.0` (the first release with cp313 wheels) depends on `ml-dtypes>=0.5.1`, which requires `numpy>=2.1.0` 3. These two constraints are irreconcilable on Python 3.13 The lockfile regeneration requires loosening the `numpy` upper bound in the `infiniflow/graspologic` fork. Once that fork commit is updated and the SHA in `pyproject.toml:49` is bumped, `uv lock --python 3.13` will succeed. ## RFC corrections Two claims in the original RFC (#14753) did not hold up under code review: - **"graspologic hard-blocks 3.13"** — the infiniflow fork at the pinned commit has no `<3.13` Python constraint. The blocker is the transitive `numpy<2.0.0` conflict with tensorflow-cpu's test dependency, not a direct Python version cap. - **"free-threading throughput gains for I/O-bound workload"** — Python 3.13 free-threading requires a special `--disable-gil` build and provides no benefit for async I/O code (the GIL is already released during I/O). The real motivation is forward compatibility and improved error messages.
2026-05-15 08:40:53 +02:00
from enum import StrEnum
from common.constants import PipelineTaskType
class UserTenantRole(StrEnum):
OWNER = "owner"
ADMIN = "admin"
NORMAL = "normal"
INVITE = "invite"
class TenantPermission(StrEnum):
ME = "me"
TEAM = "team"
class SerializedType(IntEnum):
PICKLE = 1
JSON = 2
class FileType(StrEnum):
PDF = "pdf"
DOC = "doc"
VISUAL = "visual"
AURAL = "aural"
VIRTUAL = "virtual"
FOLDER = "folder"
OTHER = "other"
VALID_FILE_TYPES = {FileType.PDF, FileType.DOC, FileType.VISUAL, FileType.AURAL, FileType.VIRTUAL, FileType.FOLDER, FileType.OTHER}
class InputType(StrEnum):
LOAD_STATE = "load_state" # e.g. loading a current full state or a save state, such as from a file
POLL = "poll" # e.g. calling an API to get all documents in the last hour
EVENT = "event" # e.g. registered an endpoint as a listener, and processing connector events
SLIM_RETRIEVAL = "slim_retrieval"
class CanvasCategory(StrEnum):
Agent = "agent_canvas"
DataFlow = "dataflow_canvas"
VALID_PIPELINE_TASK_TYPES = {
PipelineTaskType.PARSE,
PipelineTaskType.DOWNLOAD,
PipelineTaskType.RAPTOR,
PipelineTaskType.GRAPH_RAG,
PipelineTaskType.MINDMAP,
PipelineTaskType.ARTIFACT,
PipelineTaskType.SKILL,
}
# KB-level fan-out task types: their Task row uses GRAPH_RAPTOR_FAKE_DOC_ID as a
# sentinel doc_id, and ``task_executor.collect_task`` substitutes the first real
# doc_id from ``msg["doc_ids"]`` before re-running ``TaskService.get_task`` so
# the join through Document → Knowledgebase → Tenant resolves and tenant_id /
# kb_id / language are hydrated onto the task dict. Add new fan-out task types
# here or TaskContext will raise "Task must contain 'tenant_id'".
PIPELINE_SPECIAL_PROGRESS_FREEZE_TASK_TYPES = {
PipelineTaskType.RAPTOR.lower(),
PipelineTaskType.GRAPH_RAG.lower(),
PipelineTaskType.MINDMAP.lower(),
PipelineTaskType.ARTIFACT.lower(),
PipelineTaskType.SKILL.lower(),
}
KNOWLEDGEBASE_FOLDER_NAME = ".knowledgebase"
SKILLS_FOLDER_NAME = "skills"