feat: Add CustomComponent tool to Langflow API
- Added support for the CustomComponent tool in the Langflow API. - The tool has been added to the config.yaml file. - The CustomComponentNode class has been implemented in the frontend nodes. - The code changes include modifications in various files for the implementation of the CustomComponent tool. - The code changes include the addition of a new field "code" in the TemplateField class. - The build_langchain_template_custom_component function has been implemented to build the template for the CustomComponent tool. - New custom fields "my_id", "year", and "other_field" have been added to the template for the CustomComponent tool.
This commit is contained in:
parent
78fd021f23
commit
82b76840e3
9 changed files with 144 additions and 26 deletions
|
|
@ -131,7 +131,7 @@ def instantiate_tool(node_type, class_object, params):
|
|||
if node_type == "JsonSpec":
|
||||
params["dict_"] = load_file_into_dict(params.pop("path"))
|
||||
return class_object(**params)
|
||||
elif node_type == "PythonFunctionTool":
|
||||
elif node_type in ["PythonFunctionTool", "CustomComponent"]:
|
||||
params["func"] = get_function(params.get("code"))
|
||||
return class_object(**params)
|
||||
# For backward compatibility
|
||||
|
|
@ -243,7 +243,8 @@ def replace_zero_shot_prompt_with_prompt_template(nodes):
|
|||
if tool["type"] != "chatOutputNode"
|
||||
and "Tool" in tool["data"]["node"]["base_classes"]
|
||||
]
|
||||
node["data"] = build_prompt_template(prompt=node["data"], tools=tools)
|
||||
node["data"] = build_prompt_template(
|
||||
prompt=node["data"], tools=tools)
|
||||
break
|
||||
return nodes
|
||||
|
||||
|
|
@ -260,7 +261,8 @@ def load_agent_executor(agent_class: type[agent_module.Agent], params, **kwargs)
|
|||
tool_names = [tool.name for tool in allowed_tools]
|
||||
# Agent class requires an output_parser but Agent classes
|
||||
# have a default output_parser.
|
||||
agent = agent_class(allowed_tools=tool_names, llm_chain=llm_chain) # type: ignore
|
||||
agent = agent_class(allowed_tools=tool_names,
|
||||
llm_chain=llm_chain) # type: ignore
|
||||
return AgentExecutor.from_agent_and_tools(
|
||||
agent=agent,
|
||||
tools=allowed_tools,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue