[extract_info_from_class.py] Remove unnecessary code

This commit removes the file `extract_info_from_class.py` which contained unnecessary code.

[v1/endpoints.py] Fix error handling in custom_component endpoint

This commit fixes the error handling in the `custom_component` endpoint in `endpoints.py`. If the class template extracted from the code is not valid, an error message is printed.

[importing/utils.py] Comment out unused code

This commit comments out unused code in `get_function_custom` function in `utils.py` file.

[initialize/loading.py] Comment out unused code

This commit comments out unused code in the `instantiate_tool` function in `loading.py` file.

[interface/tools/custom.py] Refactor code and add properties

This commit refactors the code in `CustomComponent` class in `custom.py` file. It adds properties for `data`, `is_valid`, and `args_and_return_type`.

[interface/types.py] Add base classes to custom component template

This commit adds base classes to the custom component template in the `build_langchain_template_custom_component` function in `types.py` file.

[utils/constants.py] Remove unnecessary import

This commit removes an unnecessary import in `DEFAULT_CUSTOM_COMPONENT_CODE` constant in `constants.py` file.
This commit is contained in:
gustavoschaedler 2023-07-04 21:00:02 +01:00
commit 13bb0280f5
8 changed files with 128 additions and 176 deletions

View file

@ -178,8 +178,9 @@ def instantiate_tool(node_type, class_object, params):
params["func"] = get_function(params.get("code"))
return class_object(**params)
elif node_type == "CustomComponent":
params["func"] = get_function_custom(params.get("code"))
return class_object(**params)
return get_function_custom(params.get("code"))
# params["func"] = get_function_custom(params.get("code"))
# return class_object(**params)
# For backward compatibility
elif node_type == "PythonFunction":
function_string = params["code"]