Skip to content

Commit 996f416

Browse files
authored
fix(core): Fix param cache error (#2500)
# Description Closes #2495 # How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration # Snapshots: Include snapshots for easier review. # Checklist: - [x] My code follows the style guidelines of this project - [x] I have already rebased the commits and make the commit message conform to the project standard. - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] Any dependent changes have been merged and published in downstream modules
2 parents ca0d1ec + e4d91ff commit 996f416

File tree

4 files changed

+8
-77
lines changed

4 files changed

+8
-77
lines changed

packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/api_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def _parse_domain_type(dialogue: ConversationVo) -> Optional[str]:
814814
)
815815
else:
816816
spaces = knowledge_service.get_knowledge_space(
817-
KnowledgeSpaceRequest(id=dialogue.select_param)
817+
KnowledgeSpaceRequest(name=dialogue.select_param)
818818
)
819819
if len(spaces) == 0:
820820
raise ValueError(f"Knowledge space {dialogue.select_param} not found")

packages/dbgpt-core/src/dbgpt/util/configure/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def parse_config(
661661
def parse_description(
662662
cls,
663663
target_cls: Type[T],
664-
cache_enable: bool = True,
664+
cache_enable: bool = False,
665665
skip_base: bool = False,
666666
_visited: Optional[Set[str]] = None,
667667
_call_path: Optional[List[str]] = None,

packages/dbgpt-core/src/dbgpt/util/configure/markdown.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def generate_class_doc(self, cls: Type, output_dir: Path) -> List[str]:
201201
self.processed_classes.add(doc_id)
202202
generated_files = []
203203

204-
descriptions = ConfigurationManager.parse_description(cls, verbose=True)
204+
descriptions = ConfigurationManager.parse_description(
205+
cls, cache_enable=True, verbose=True
206+
)
205207
cfg_type, cfg_desc = self._parse_class_metadata(cls)
206208

207209
filename = self.generate_safe_filename(doc_id)
@@ -308,7 +310,9 @@ def _collect_relationships(
308310
return
309311
processed.add(class_id)
310312

311-
descriptions = ConfigurationManager.parse_description(cls, verbose=True)
313+
descriptions = ConfigurationManager.parse_description(
314+
cls, cache_enable=True, verbose=True
315+
)
312316
for param in descriptions:
313317
if param.nested_fields:
314318
for nested_type, nested_params in param.nested_fields.items():

packages/dbgpt-core/src/dbgpt/util/parameter_utils.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -613,79 +613,6 @@ def _get_parameter_descriptions(
613613

614614
return ConfigurationManager.parse_description(dataclass_type)
615615

616-
# # Get descriptions from parent classes
617-
# parent_descriptions = {}
618-
# for parent in dataclass_type.__mro__[1:]:
619-
# if parent is object or not is_dataclass(parent):
620-
# continue
621-
# for parent_param in _get_parameter_descriptions(parent):
622-
# if parent_param.description:
623-
# parent_descriptions[parent_param.param_name] = parent_param.description # noqa
624-
#
625-
# descriptions = []
626-
# for fd in fields(dataclass_type):
627-
# ext_metadata = {
628-
# k: v for k, v in fd.metadata.items() if k not in ["help", "valid_values"]
629-
# }
630-
# default_value = fd.default if fd.default != MISSING else None
631-
# if fd.name in kwargs:
632-
# default_value = kwargs[fd.name]
633-
#
634-
# # Get base type information
635-
# is_array = False
636-
# type_name, sub_types = type_to_string(fd.type)
637-
# real_type_name = type_name
638-
#
639-
# if type_name == "array" and sub_types:
640-
# is_array = True
641-
# real_type_name = sub_types[0]
642-
#
643-
# if real_type_name == "unknown":
644-
# real_type_name = fd.type.__name__
645-
#
646-
# # Check if field type is a dataclass
647-
# field_type = fd.type
648-
# nested_fields = None
649-
#
650-
# if hasattr(field_type, "__origin__") and field_type.__origin__ is Union:
651-
# # Handle Optional types
652-
# field_type = field_type.__args__[0]
653-
#
654-
# if is_dataclass(field_type):
655-
# # Recursively get descriptions for nested dataclass
656-
# nested_fields = _get_parameter_descriptions(
657-
# field_type, parent_field=fd.name, **kwargs
658-
# )
659-
# # Set the type name to the full path of the nested class
660-
# real_type_name = f"{field_type.__module__}.{field_type.__name__}"
661-
#
662-
# required = True
663-
# if fd.default != MISSING or fd.default_factory != MISSING:
664-
# required = False
665-
#
666-
# description = fd.metadata.get("help")
667-
# if not description:
668-
# description = parent_descriptions.get(fd.name)
669-
#
670-
# descriptions.append(
671-
# ParameterDescription(
672-
# is_array=is_array,
673-
# param_class=f"{dataclass_type.__module__}.{dataclass_type.__name__}",
674-
# param_name=fd.name,
675-
# param_type=real_type_name,
676-
# description=description,
677-
# label=fd.metadata.get("label", fd.name),
678-
# required=required,
679-
# default_value=default_value,
680-
# valid_values=fd.metadata.get("valid_values", None),
681-
# ext_metadata=ext_metadata,
682-
# parent_field=parent_field,
683-
# nested_fields=nested_fields,
684-
# )
685-
# )
686-
#
687-
# return descriptions
688-
689616

690617
def _build_parameter_class(desc: List[ParameterDescription]) -> Type:
691618
from dbgpt.util.module_utils import import_from_string

0 commit comments

Comments
 (0)