Add PythonFunctionComponent to langflow utilities
This commit is contained in:
parent
8f8b921ead
commit
63c709ee1d
1 changed files with 24 additions and 0 deletions
24
src/backend/langflow/components/utilities/PythonFunction.py
Normal file
24
src/backend/langflow/components/utilities/PythonFunction.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
|
from langflow import CustomComponent
|
||||||
|
from langflow.field_typing import Code
|
||||||
|
from langflow.interface.custom.utils import get_function
|
||||||
|
|
||||||
|
|
||||||
|
class PythonFunctionComponent(CustomComponent):
|
||||||
|
display_name = "Python Function"
|
||||||
|
description = "Define a Python function."
|
||||||
|
|
||||||
|
def build_config(self):
|
||||||
|
return {
|
||||||
|
"function_code": {
|
||||||
|
"display_name": "Code",
|
||||||
|
"info": "The code for the function.",
|
||||||
|
"show": True,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def build(self, function_code: Code) -> Callable:
|
||||||
|
self.status = function_code
|
||||||
|
func = get_function(function_code)
|
||||||
|
return func
|
||||||
Loading…
Add table
Add a link
Reference in a new issue