refactor: extract file path length limit to shared constant
• Add DEFAULT_MAX_FILE_PATH_LENGTH constant • Replace hardcoded 4090 in Milvus impl
This commit is contained in:
parent
8e7014d366
commit
c8c3545454
3 changed files with 11 additions and 3 deletions
|
|
@ -26,6 +26,9 @@ DEFAULT_RELATED_CHUNK_NUMBER = 5
|
||||||
# Separator for graph fields
|
# Separator for graph fields
|
||||||
GRAPH_FIELD_SEP = "<SEP>"
|
GRAPH_FIELD_SEP = "<SEP>"
|
||||||
|
|
||||||
|
# File path configuration for vector and graph database
|
||||||
|
DEFAULT_MAX_FILE_PATH_LENGTH = 4090
|
||||||
|
|
||||||
# Logging configuration defaults
|
# Logging configuration defaults
|
||||||
DEFAULT_LOG_MAX_BYTES = 10485760 # Default 10MB
|
DEFAULT_LOG_MAX_BYTES = 10485760 # Default 10MB
|
||||||
DEFAULT_LOG_BACKUP_COUNT = 5 # Default 5 backups
|
DEFAULT_LOG_BACKUP_COUNT = 5 # Default 5 backups
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ from dataclasses import dataclass
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from lightrag.utils import logger, compute_mdhash_id
|
from lightrag.utils import logger, compute_mdhash_id
|
||||||
from ..base import BaseVectorStorage
|
from ..base import BaseVectorStorage
|
||||||
|
from ..constants import DEFAULT_MAX_FILE_PATH_LENGTH
|
||||||
import pipmaster as pm
|
import pipmaster as pm
|
||||||
|
|
||||||
if not pm.is_installed("pymilvus"):
|
if not pm.is_installed("pymilvus"):
|
||||||
|
|
@ -47,7 +48,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
FieldSchema(
|
FieldSchema(
|
||||||
name="file_path",
|
name="file_path",
|
||||||
dtype=DataType.VARCHAR,
|
dtype=DataType.VARCHAR,
|
||||||
max_length=4090,
|
max_length=DEFAULT_MAX_FILE_PATH_LENGTH,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
@ -64,7 +65,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
||||||
FieldSchema(
|
FieldSchema(
|
||||||
name="file_path",
|
name="file_path",
|
||||||
dtype=DataType.VARCHAR,
|
dtype=DataType.VARCHAR,
|
||||||
max_length=4090,
|
max_length=DEFAULT_MAX_FILE_PATH_LENGTH,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ from .constants import (
|
||||||
DEFAULT_MAX_RELATION_TOKENS,
|
DEFAULT_MAX_RELATION_TOKENS,
|
||||||
DEFAULT_MAX_TOTAL_TOKENS,
|
DEFAULT_MAX_TOTAL_TOKENS,
|
||||||
DEFAULT_RELATED_CHUNK_NUMBER,
|
DEFAULT_RELATED_CHUNK_NUMBER,
|
||||||
|
DEFAULT_MAX_FILE_PATH_LENGTH,
|
||||||
)
|
)
|
||||||
from .kg.shared_storage import get_storage_keyed_lock
|
from .kg.shared_storage import get_storage_keyed_lock
|
||||||
import time
|
import time
|
||||||
|
|
@ -3154,7 +3155,10 @@ def build_file_path(already_file_paths, data_list, target):
|
||||||
file_paths_set.add(cur_file_path)
|
file_paths_set.add(cur_file_path)
|
||||||
|
|
||||||
# check the length
|
# check the length
|
||||||
if len(file_paths) + len(GRAPH_FIELD_SEP + cur_file_path) < 4090:
|
if (
|
||||||
|
len(file_paths) + len(GRAPH_FIELD_SEP + cur_file_path)
|
||||||
|
< DEFAULT_MAX_FILE_PATH_LENGTH
|
||||||
|
):
|
||||||
# append
|
# append
|
||||||
file_paths += (
|
file_paths += (
|
||||||
GRAPH_FIELD_SEP + cur_file_path if file_paths else cur_file_path
|
GRAPH_FIELD_SEP + cur_file_path if file_paths else cur_file_path
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue