Merge branch 'python_custom_node_component' of github.com:logspace-ai/langflow into python_custom_node_component
This commit is contained in:
commit
b46a967452
3 changed files with 10 additions and 7 deletions
|
|
@ -19,7 +19,7 @@ from langflow.interface.types import (
|
||||||
build_langchain_template_custom_component,
|
build_langchain_template_custom_component,
|
||||||
)
|
)
|
||||||
|
|
||||||
from langflow.interface.types import langchain_types_dict
|
from langflow.interface.types import build_langchain_types_dict
|
||||||
from langflow.database.base import get_session
|
from langflow.database.base import get_session
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ router = APIRouter(tags=["Base"])
|
||||||
|
|
||||||
@router.get("/all")
|
@router.get("/all")
|
||||||
def get_all():
|
def get_all():
|
||||||
return langchain_types_dict
|
return build_langchain_types_dict()
|
||||||
|
|
||||||
|
|
||||||
# For backwards compatibility we will keep the old endpoint
|
# For backwards compatibility we will keep the old endpoint
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import ast
|
import ast
|
||||||
|
import inspect
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from typing import Dict, Any, Union
|
from typing import Dict, Any, Type, Union
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,10 +15,15 @@ class CodeParser:
|
||||||
A parser for Python source code, extracting code details.
|
A parser for Python source code, extracting code details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, code: str) -> None:
|
def __init__(self, code: Union[str, Type]) -> None:
|
||||||
"""
|
"""
|
||||||
Initializes the parser with the provided code.
|
Initializes the parser with the provided code.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(code, type):
|
||||||
|
if not inspect.isclass(code):
|
||||||
|
raise ValueError("The provided code must be a class.")
|
||||||
|
# If the code is a class, get its source code
|
||||||
|
code = inspect.getsource(code)
|
||||||
self.code = code
|
self.code = code
|
||||||
self.data: Dict[str, Any] = {
|
self.data: Dict[str, Any] = {
|
||||||
"imports": [],
|
"imports": [],
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,3 @@ def build_langchain_template_custom_component(custom_component: CustomComponent)
|
||||||
frontend_node.get("base_classes").append(base_class)
|
frontend_node.get("base_classes").append(base_class)
|
||||||
|
|
||||||
return frontend_node
|
return frontend_node
|
||||||
|
|
||||||
|
|
||||||
langchain_types_dict = build_langchain_types_dict()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue