mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-01 08:11:45 +00:00
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
This commit is contained in:
commit
996f41615a
@ -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")
|
||||
|
@ -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,
|
||||
|
@ -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():
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user