From e4d91ff7660902d3efbe77e5560b98903b43f915 Mon Sep 17 00:00:00 2001 From: Fangyin Cheng Date: Fri, 21 Mar 2025 15:55:08 +0800 Subject: [PATCH] fix(core): Fix param cache error --- .../src/dbgpt_app/openapi/api_v1/api_v1.py | 2 +- .../src/dbgpt/util/configure/manager.py | 2 +- .../src/dbgpt/util/configure/markdown.py | 8 +- .../src/dbgpt/util/parameter_utils.py | 73 ------------------- 4 files changed, 8 insertions(+), 77 deletions(-) diff --git a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/api_v1.py b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/api_v1.py index cc611d3d3..399a9c22e 100644 --- a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/api_v1.py +++ b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/api_v1.py @@ -814,7 +814,7 @@ def _parse_domain_type(dialogue: ConversationVo) -> Optional[str]: ) else: spaces = knowledge_service.get_knowledge_space( - KnowledgeSpaceRequest(id=dialogue.select_param) + KnowledgeSpaceRequest(name=dialogue.select_param) ) if len(spaces) == 0: raise ValueError(f"Knowledge space {dialogue.select_param} not found") diff --git a/packages/dbgpt-core/src/dbgpt/util/configure/manager.py b/packages/dbgpt-core/src/dbgpt/util/configure/manager.py index 90e92eafe..3a074f446 100644 --- a/packages/dbgpt-core/src/dbgpt/util/configure/manager.py +++ b/packages/dbgpt-core/src/dbgpt/util/configure/manager.py @@ -661,7 +661,7 @@ class ConfigurationManager: def parse_description( cls, target_cls: Type[T], - cache_enable: bool = True, + cache_enable: bool = False, skip_base: bool = False, _visited: Optional[Set[str]] = None, _call_path: Optional[List[str]] = None, diff --git a/packages/dbgpt-core/src/dbgpt/util/configure/markdown.py b/packages/dbgpt-core/src/dbgpt/util/configure/markdown.py index cedf8ced9..d473cedba 100644 --- a/packages/dbgpt-core/src/dbgpt/util/configure/markdown.py +++ b/packages/dbgpt-core/src/dbgpt/util/configure/markdown.py @@ -201,7 +201,9 @@ class MDXDocGenerator: self.processed_classes.add(doc_id) generated_files = [] - descriptions = ConfigurationManager.parse_description(cls, verbose=True) + descriptions = ConfigurationManager.parse_description( + cls, cache_enable=True, verbose=True + ) cfg_type, cfg_desc = self._parse_class_metadata(cls) filename = self.generate_safe_filename(doc_id) @@ -308,7 +310,9 @@ class MDXDocGenerator: return processed.add(class_id) - descriptions = ConfigurationManager.parse_description(cls, verbose=True) + descriptions = ConfigurationManager.parse_description( + cls, cache_enable=True, verbose=True + ) for param in descriptions: if param.nested_fields: for nested_type, nested_params in param.nested_fields.items(): diff --git a/packages/dbgpt-core/src/dbgpt/util/parameter_utils.py b/packages/dbgpt-core/src/dbgpt/util/parameter_utils.py index 85112a039..742b03691 100644 --- a/packages/dbgpt-core/src/dbgpt/util/parameter_utils.py +++ b/packages/dbgpt-core/src/dbgpt/util/parameter_utils.py @@ -613,79 +613,6 @@ def _get_parameter_descriptions( return ConfigurationManager.parse_description(dataclass_type) - # # Get descriptions from parent classes - # parent_descriptions = {} - # for parent in dataclass_type.__mro__[1:]: - # if parent is object or not is_dataclass(parent): - # continue - # for parent_param in _get_parameter_descriptions(parent): - # if parent_param.description: - # parent_descriptions[parent_param.param_name] = parent_param.description # noqa - # - # descriptions = [] - # for fd in fields(dataclass_type): - # ext_metadata = { - # k: v for k, v in fd.metadata.items() if k not in ["help", "valid_values"] - # } - # default_value = fd.default if fd.default != MISSING else None - # if fd.name in kwargs: - # default_value = kwargs[fd.name] - # - # # Get base type information - # is_array = False - # type_name, sub_types = type_to_string(fd.type) - # real_type_name = type_name - # - # if type_name == "array" and sub_types: - # is_array = True - # real_type_name = sub_types[0] - # - # if real_type_name == "unknown": - # real_type_name = fd.type.__name__ - # - # # Check if field type is a dataclass - # field_type = fd.type - # nested_fields = None - # - # if hasattr(field_type, "__origin__") and field_type.__origin__ is Union: - # # Handle Optional types - # field_type = field_type.__args__[0] - # - # if is_dataclass(field_type): - # # Recursively get descriptions for nested dataclass - # nested_fields = _get_parameter_descriptions( - # field_type, parent_field=fd.name, **kwargs - # ) - # # Set the type name to the full path of the nested class - # real_type_name = f"{field_type.__module__}.{field_type.__name__}" - # - # required = True - # if fd.default != MISSING or fd.default_factory != MISSING: - # required = False - # - # description = fd.metadata.get("help") - # if not description: - # description = parent_descriptions.get(fd.name) - # - # descriptions.append( - # ParameterDescription( - # is_array=is_array, - # param_class=f"{dataclass_type.__module__}.{dataclass_type.__name__}", - # param_name=fd.name, - # param_type=real_type_name, - # description=description, - # label=fd.metadata.get("label", fd.name), - # required=required, - # default_value=default_value, - # valid_values=fd.metadata.get("valid_values", None), - # ext_metadata=ext_metadata, - # parent_field=parent_field, - # nested_fields=nested_fields, - # ) - # ) - # - # return descriptions - def _build_parameter_class(desc: List[ParameterDescription]) -> Type: from dbgpt.util.module_utils import import_from_string