🐛 fix(endpoints.py): handle duplicate paths in settings.COMPONENTS_PATH to avoid processing the same path multiple times
🐛 fix(settings.py): convert Path objects to strings in settings.COMPONENTS_PATH to ensure consistency and avoid potential issues
This commit is contained in:
parent
cce3bd3305
commit
2e0de1926e
2 changed files with 14 additions and 4 deletions
|
|
@ -42,10 +42,18 @@ def get_all():
|
|||
custom_components_from_file = {}
|
||||
if settings.COMPONENTS_PATH:
|
||||
logger.info(f"Building custom components from {settings.COMPONENTS_PATH}")
|
||||
custom_component_dicts = [
|
||||
build_langchain_custom_component_list_from_path(str(path))
|
||||
for path in settings.COMPONENTS_PATH
|
||||
]
|
||||
|
||||
custom_component_dicts = []
|
||||
processed_paths = []
|
||||
for path in settings.COMPONENTS_PATH:
|
||||
if path in processed_paths:
|
||||
continue
|
||||
custom_component_dict = build_langchain_custom_component_list_from_path(
|
||||
str(path)
|
||||
)
|
||||
custom_component_dicts.append(custom_component_dict)
|
||||
processed_paths.append(str(path))
|
||||
|
||||
logger.info(f"Loading {len(custom_component_dicts)} category(ies)")
|
||||
for custom_component_dict in custom_component_dicts:
|
||||
# custom_component_dict is a dict of dicts
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ class Settings(BaseSettings):
|
|||
value = json.loads(str(value))
|
||||
if isinstance(value, list):
|
||||
for item in value:
|
||||
if isinstance(item, Path):
|
||||
item = str(item)
|
||||
if item not in getattr(self, key):
|
||||
getattr(self, key).append(item)
|
||||
logger.debug(f"Extended {key}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue