🔨 refactor(langflow): improve code parsing and custom component handling

- Refactor code parsing in `code_parser.py` to handle imports, function definitions, and class attributes more robustly and cleanly.
- Add new methods in `component.py` to parse Assign and AnnAssign statements, and FunctionDef statements.
- Refactor `custom_component.py` to improve the handling of custom components, including better extraction of main class name and template configuration.
- Update `types.py` to better handle the building of custom component templates, including handling of field configurations and error handling.
- Minor formatting fix in `conftest.py` test fixture.

These changes improve the robustness and readability of the code, and provide better handling and validation of custom components.
This commit is contained in:
gustavoschaedler 2023-07-15 00:41:31 +01:00
commit 0aab360629
5 changed files with 106 additions and 38 deletions

View file

@ -252,7 +252,8 @@ class CustomChain(CustomComponent):
def build(self, prompt, llm, input: str) -> Document:
chain = MyCustomChain(prompt=prompt, llm=llm)
return chain(input)'''
return chain(input)
'''
@pytest.fixture