mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Refactor: fix typos (#10200)
### What problem does this PR solve? 1. Fix typos 2. Rename function 3. Use English to write comment ### Type of change - [x] Refactoring Signed-off-by: jinhai <haijin.chn@gmail.com>
This commit is contained in:
@ -244,7 +244,7 @@ class ComponentParamBase(ABC):
|
|||||||
|
|
||||||
if not value_legal:
|
if not value_legal:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Plase check runtime conf, {} = {} does not match user-parameter restriction".format(
|
"Please check runtime conf, {} = {} does not match user-parameter restriction".format(
|
||||||
variable, value
|
variable, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -28,7 +28,7 @@ from rag.llm.chat_model import ERROR_PREFIX
|
|||||||
class CategorizeParam(LLMParam):
|
class CategorizeParam(LLMParam):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Define the Categorize component parameters.
|
Define the categorize component parameters.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|||||||
@ -81,9 +81,9 @@ class LLMParam(ComponentParamBase):
|
|||||||
|
|
||||||
class LLM(ComponentBase):
|
class LLM(ComponentBase):
|
||||||
component_name = "LLM"
|
component_name = "LLM"
|
||||||
|
|
||||||
def __init__(self, canvas, id, param: ComponentParamBase):
|
def __init__(self, canvas, component_id, param: ComponentParamBase):
|
||||||
super().__init__(canvas, id, param)
|
super().__init__(canvas, component_id, param)
|
||||||
self.chat_mdl = LLMBundle(self._canvas.get_tenant_id(), TenantLLMService.llm_id2llm_type(self._param.llm_id),
|
self.chat_mdl = LLMBundle(self._canvas.get_tenant_id(), TenantLLMService.llm_id2llm_type(self._param.llm_id),
|
||||||
self._param.llm_id, max_retries=self._param.max_retries,
|
self._param.llm_id, max_retries=self._param.max_retries,
|
||||||
retry_interval=self._param.delay_after_error
|
retry_interval=self._param.delay_after_error
|
||||||
@ -209,7 +209,7 @@ class LLM(ComponentBase):
|
|||||||
return re.sub(r"```\n*$", "", ans, flags=re.DOTALL)
|
return re.sub(r"```\n*$", "", ans, flags=re.DOTALL)
|
||||||
|
|
||||||
prompt, msg, _ = self._prepare_prompt_variables()
|
prompt, msg, _ = self._prepare_prompt_variables()
|
||||||
error = ""
|
error: str = ""
|
||||||
|
|
||||||
if self._param.output_structure:
|
if self._param.output_structure:
|
||||||
prompt += "\nThe output MUST follow this JSON format:\n"+json.dumps(self._param.output_structure, ensure_ascii=False, indent=2)
|
prompt += "\nThe output MUST follow this JSON format:\n"+json.dumps(self._param.output_structure, ensure_ascii=False, indent=2)
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class MessageParam(ComponentParamBase):
|
|||||||
class Message(ComponentBase):
|
class Message(ComponentBase):
|
||||||
component_name = "Message"
|
component_name = "Message"
|
||||||
|
|
||||||
def get_kwargs(self, script:str, kwargs:dict = {}, delimeter:str=None) -> tuple[str, dict[str, str | list | Any]]:
|
def get_kwargs(self, script:str, kwargs:dict = {}, delimiter:str=None) -> tuple[str, dict[str, str | list | Any]]:
|
||||||
for k,v in self.get_input_elements_from_text(script).items():
|
for k,v in self.get_input_elements_from_text(script).items():
|
||||||
if k in kwargs:
|
if k in kwargs:
|
||||||
continue
|
continue
|
||||||
@ -60,8 +60,8 @@ class Message(ComponentBase):
|
|||||||
if isinstance(v, partial):
|
if isinstance(v, partial):
|
||||||
for t in v():
|
for t in v():
|
||||||
ans += t
|
ans += t
|
||||||
elif isinstance(v, list) and delimeter:
|
elif isinstance(v, list) and delimiter:
|
||||||
ans = delimeter.join([str(vv) for vv in v])
|
ans = delimiter.join([str(vv) for vv in v])
|
||||||
elif not isinstance(v, str):
|
elif not isinstance(v, str):
|
||||||
try:
|
try:
|
||||||
ans = json.dumps(v, ensure_ascii=False)
|
ans = json.dumps(v, ensure_ascii=False)
|
||||||
|
|||||||
@ -83,16 +83,16 @@ def upload(tenant_id):
|
|||||||
return get_json_result(data=False, message="Can't find this folder!", code=404)
|
return get_json_result(data=False, message="Can't find this folder!", code=404)
|
||||||
|
|
||||||
for file_obj in file_objs:
|
for file_obj in file_objs:
|
||||||
# 文件路径处理
|
# Handle file path
|
||||||
full_path = '/' + file_obj.filename
|
full_path = '/' + file_obj.filename
|
||||||
file_obj_names = full_path.split('/')
|
file_obj_names = full_path.split('/')
|
||||||
file_len = len(file_obj_names)
|
file_len = len(file_obj_names)
|
||||||
|
|
||||||
# 获取文件夹路径ID
|
# Get folder path ID
|
||||||
file_id_list = FileService.get_id_list_by_id(pf_id, file_obj_names, 1, [pf_id])
|
file_id_list = FileService.get_id_list_by_id(pf_id, file_obj_names, 1, [pf_id])
|
||||||
len_id_list = len(file_id_list)
|
len_id_list = len(file_id_list)
|
||||||
|
|
||||||
# 创建文件夹结构
|
# Crete file folder
|
||||||
if file_len != len_id_list:
|
if file_len != len_id_list:
|
||||||
e, file = FileService.get_by_id(file_id_list[len_id_list - 1])
|
e, file = FileService.get_by_id(file_id_list[len_id_list - 1])
|
||||||
if not e:
|
if not e:
|
||||||
|
|||||||
@ -111,7 +111,7 @@ class CanvasCategory(StrEnum):
|
|||||||
Agent = "agent_canvas"
|
Agent = "agent_canvas"
|
||||||
DataFlow = "dataflow_canvas"
|
DataFlow = "dataflow_canvas"
|
||||||
|
|
||||||
VALID_CAVAS_CATEGORIES = {CanvasCategory.Agent, CanvasCategory.DataFlow}
|
VALID_CANVAS_CATEGORIES = {CanvasCategory.Agent, CanvasCategory.DataFlow}
|
||||||
|
|
||||||
|
|
||||||
class MCPServerType(StrEnum):
|
class MCPServerType(StrEnum):
|
||||||
|
|||||||
@ -19,7 +19,7 @@ from pathlib import PurePath
|
|||||||
from .user_service import UserService as UserService
|
from .user_service import UserService as UserService
|
||||||
|
|
||||||
|
|
||||||
def split_name_counter(filename: str) -> tuple[str, int | None]:
|
def _split_name_counter(filename: str) -> tuple[str, int | None]:
|
||||||
"""
|
"""
|
||||||
Splits a filename into main part and counter (if present in parentheses).
|
Splits a filename into main part and counter (if present in parentheses).
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ def duplicate_name(query_func, **kwargs) -> str:
|
|||||||
stem = path.stem
|
stem = path.stem
|
||||||
suffix = path.suffix
|
suffix = path.suffix
|
||||||
|
|
||||||
main_part, counter = split_name_counter(stem)
|
main_part, counter = _split_name_counter(stem)
|
||||||
counter = counter + 1 if counter else 1
|
counter = counter + 1 if counter else 1
|
||||||
|
|
||||||
new_name = f"{main_part}({counter}){suffix}"
|
new_name = f"{main_part}({counter}){suffix}"
|
||||||
|
|||||||
Reference in New Issue
Block a user