refactor: update ATTR_FUNC_MAPPING and tools to match other tools (#3709)
* Refactor YfinanceToolComponent to inherit from LCToolComponent and remove unused outputs * Refactor `PythonREPLToolComponent` to use new input configuration and update method signatures * Add functions to handle dict values in ATTR_FUNC_MAPPING for '_outputs_maps' and '_inputs' * Handle '_outputs_maps' argument in frontend node creation * Add unit test for custom component subclassing from LCToolComponent * Add input and output handling to PythonREPLToolComponent - Introduced `input_value` to `inputs` for capturing user input. - Added `outputs` to define the output structure, including `api_run_model` and `tool` for backward compatibility. - Implemented `run_model` method to execute the tool and return results as `Data`. * Add input and output handling to YfinanceToolComponent - Introduced `MessageTextInput` for user queries. - Added `Output` definitions for `api_run_model` and `tool` methods. - Implemented `run_model` method to execute tool with user input. * Add input and output definitions to YfinanceTool for better data handling * Update error message to use display_name instead of vertex_type in edge validation * Add unit test for YfinanceToolComponent template output validation * Refactor tool components to include 'Data' output and update input types - Added 'Data' output type to 'Agent Flow', 'Sequential Agent', and 'Complex Agent' starter projects. - Updated input types to use 'MessageTextInput' and 'MultiselectInput' for better input handling. - Refactored code to align with new input and output structures, ensuring backward compatibility. * Add unit test for PythonREPLToolComponent template validation * test: disblable test --------- Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
parent
f706554456
commit
bee466e52b
12 changed files with 276 additions and 69 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import ast
|
||||
import types
|
||||
from textwrap import dedent
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
|
@ -540,3 +541,25 @@ def test_build_config_field_value_keys(component):
|
|||
def test_custom_component_multiple_outputs(code_component_with_multiple_outputs, active_user):
|
||||
frontnd_node_dict, _ = build_custom_component_template(code_component_with_multiple_outputs, active_user.id)
|
||||
assert frontnd_node_dict["outputs"][0]["types"] == ["Text"]
|
||||
|
||||
|
||||
def test_custom_component_subclass_from_lctoolcomponent():
|
||||
# Import LCToolComponent and create a subclass
|
||||
code = dedent("""
|
||||
from langflow.base.langchain_utilities.model import LCToolComponent
|
||||
from langchain_core.tools import Tool
|
||||
class MyComponent(LCToolComponent):
|
||||
name: str = "MyComponent"
|
||||
description: str = "MyComponent"
|
||||
|
||||
def build_tool(self) -> Tool:
|
||||
return Tool(name="MyTool", description="MyTool")
|
||||
|
||||
def run_model(self)-> Data:
|
||||
return Data(data="Hello World")
|
||||
""")
|
||||
component = Component(_code=code)
|
||||
frontend_node, _ = build_custom_component_template(component)
|
||||
assert "outputs" in frontend_node
|
||||
assert frontend_node["outputs"][0]["types"] != []
|
||||
assert frontend_node["outputs"][1]["types"] != []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue