diff --git a/src/backend/langflow/interface/tools/base.py b/src/backend/langflow/interface/tools/base.py index 4be0452e7..e74d49384 100644 --- a/src/backend/langflow/interface/tools/base.py +++ b/src/backend/langflow/interface/tools/base.py @@ -36,7 +36,7 @@ TOOL_INPUTS = { field_type="BaseLanguageModel", required=True, is_list=False, show=True ), "func": TemplateField( - field_type="function", + field_type="Callable", required=True, is_list=False, show=True, @@ -126,7 +126,7 @@ class ToolCreator(LangChainTypeCreator): elif tool_type in CUSTOM_TOOLS: # Get custom tool params params = self.type_to_loader_dict[name]["params"] # type: ignore - base_classes = ["function"] + base_classes = ["Callable"] if node := customs.get_custom_nodes("tools").get(tool_type): return node elif tool_type in FILE_TOOLS: diff --git a/src/backend/langflow/template/frontend_node/agents.py b/src/backend/langflow/template/frontend_node/agents.py index b3f9b4545..1d9d44aaa 100644 --- a/src/backend/langflow/template/frontend_node/agents.py +++ b/src/backend/langflow/template/frontend_node/agents.py @@ -206,7 +206,7 @@ class InitializeAgentNode(FrontendNode): ], ) description: str = """Construct a zero shot agent from an LLM and tools.""" - base_classes: list[str] = ["AgentExecutor", "function"] + base_classes: list[str] = ["AgentExecutor", "Callable"] def to_dict(self): return super().to_dict() diff --git a/src/backend/langflow/template/frontend_node/chains.py b/src/backend/langflow/template/frontend_node/chains.py index b678dec3b..1b1142ba6 100644 --- a/src/backend/langflow/template/frontend_node/chains.py +++ b/src/backend/langflow/template/frontend_node/chains.py @@ -140,7 +140,7 @@ class SeriesCharacterChainNode(FrontendNode): "Chain", "ConversationChain", "SeriesCharacterChain", - "function", + "Callable", ] @@ -241,7 +241,7 @@ class CombineDocsChainNode(FrontendNode): ], ) description: str = """Load question answering chain.""" - base_classes: list[str] = ["BaseCombineDocumentsChain", "function"] + base_classes: list[str] = ["BaseCombineDocumentsChain", "Callable"] def to_dict(self): return super().to_dict() diff --git a/src/backend/langflow/template/frontend_node/tools.py b/src/backend/langflow/template/frontend_node/tools.py index 579b32da3..315b216a4 100644 --- a/src/backend/langflow/template/frontend_node/tools.py +++ b/src/backend/langflow/template/frontend_node/tools.py @@ -35,7 +35,7 @@ class ToolNode(FrontendNode): ), TemplateField( name="func", - field_type="function", + field_type="Callable", required=True, is_list=False, show=True, @@ -135,7 +135,7 @@ class PythonFunctionNode(FrontendNode): ], ) description: str = "Python function to be executed." - base_classes: list[str] = ["function"] + base_classes: list[str] = ["Callable"] def to_dict(self): return super().to_dict() diff --git a/src/backend/langflow/utils/util.py b/src/backend/langflow/utils/util.py index 4d96709b5..9dddde032 100644 --- a/src/backend/langflow/utils/util.py +++ b/src/backend/langflow/utils/util.py @@ -60,7 +60,7 @@ def build_template_from_function( # the output to be a function base_classes = get_base_classes(_class) if add_function: - base_classes.append("function") + base_classes.append("Callable") return { "template": format_dict(variables, name), @@ -114,7 +114,7 @@ def build_template_from_class( # Adding function to base classes to allow # the output to be a function if add_function: - base_classes.append("function") + base_classes.append("Callable") return { "template": format_dict(variables, name), "description": docs.short_description or "", @@ -178,7 +178,7 @@ def build_template_from_method( # Adding function to base classes to allow the output to be a function if add_function: - base_classes.append("function") + base_classes.append("Callable") return { "template": format_dict(variables, class_name), diff --git a/tests/test_agents_template.py b/tests/test_agents_template.py index e354d4a16..f2ce4e3e2 100644 --- a/tests/test_agents_template.py +++ b/tests/test_agents_template.py @@ -12,7 +12,7 @@ def test_zero_shot_agent(client: TestClient, logged_in_headers): "ZeroShotAgent", "BaseSingleActionAgent", "Agent", - "function", + "Callable", } template = zero_shot_agent["template"] @@ -202,7 +202,7 @@ def test_initialize_agent(client: TestClient, logged_in_headers): agents = json_response["agents"] initialize_agent = agents["AgentInitializer"] - assert initialize_agent["base_classes"] == ["AgentExecutor", "function"] + assert initialize_agent["base_classes"] == ["AgentExecutor", "Callable"] template = initialize_agent["template"] assert template["agent"] == { diff --git a/tests/test_chains_template.py b/tests/test_chains_template.py index eb20a0571..ecbb9445c 100644 --- a/tests/test_chains_template.py +++ b/tests/test_chains_template.py @@ -22,7 +22,7 @@ def test_conversation_chain(client: TestClient, logged_in_headers): "ConversationChain", "LLMChain", "Chain", - "function", + "Callable", } template = chain["template"] @@ -111,7 +111,7 @@ def test_llm_chain(client: TestClient, logged_in_headers): # Test the base classes, template, memory, verbose, llm, input_key, output_key, and _type objects assert set(chain["base_classes"]) == { - "function", + "Callable", "LLMChain", "Chain", } @@ -182,7 +182,7 @@ def test_llm_checker_chain(client: TestClient, logged_in_headers): # Test the base classes, template, memory, verbose, llm, input_key, output_key, and _type objects assert set(chain["base_classes"]) == { - "function", + "Callable", "LLMCheckerChain", "Chain", } @@ -216,7 +216,7 @@ def test_llm_math_chain(client: TestClient, logged_in_headers): chain = chains["LLMMathChain"] # Test the base classes, template, memory, verbose, llm, input_key, output_key, and _type objects assert set(chain["base_classes"]) == { - "function", + "Callable", "LLMMathChain", "Chain", } @@ -309,7 +309,7 @@ def test_series_character_chain(client: TestClient, logged_in_headers): # Test the base classes, template, memory, verbose, llm, input_key, output_key, and _type objects assert set(chain["base_classes"]) == { - "function", + "Callable", "LLMChain", "BaseCustomChain", "Chain", diff --git a/tests/test_template.py b/tests/test_template.py index 81f2a6020..e88fc6484 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -69,7 +69,7 @@ def test_build_template_from_function(): "ExampleClass1", type_to_loader_dict, add_function=True ) assert result_with_function is not None - assert "function" in result_with_function["base_classes"] + assert "Callable" in result_with_function["base_classes"] # Test with invalid name with pytest.raises(ValueError, match=r".* not found"):