formatting
This commit is contained in:
parent
b8f8ec9c90
commit
b9b8937eda
5 changed files with 33 additions and 15 deletions
|
|
@ -68,7 +68,6 @@ def update_frontend_node_with_template_values(frontend_node, raw_template_data):
|
|||
if key == "code" or not isinstance(value_dict, dict) or not frontend_field:
|
||||
continue
|
||||
|
||||
|
||||
value = value_dict.get("value")
|
||||
template_field_type = value_dict.get("type")
|
||||
frontend_node_field_type = frontend_field.get("type")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
from fastapi import APIRouter, HTTPException
|
||||
from langflow.api.v1.base import (Code, CodeValidationResponse,
|
||||
PromptValidationResponse,
|
||||
ValidatePromptRequest, validate_prompt)
|
||||
from langflow.api.v1.base import (
|
||||
Code,
|
||||
CodeValidationResponse,
|
||||
PromptValidationResponse,
|
||||
ValidatePromptRequest,
|
||||
validate_prompt,
|
||||
)
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.utils.validate import validate_code
|
||||
from loguru import logger
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ from typing import Any, Dict, List, Type, Union
|
|||
|
||||
from cachetools import TTLCache, cachedmethod, keys
|
||||
from fastapi import HTTPException
|
||||
from langflow.interface.custom.schema import (CallableCodeDetails,
|
||||
ClassCodeDetails)
|
||||
from langflow.interface.custom.schema import CallableCodeDetails, ClassCodeDetails
|
||||
|
||||
|
||||
class CodeSyntaxError(HTTPException):
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ from collections import defaultdict
|
|||
from typing import ClassVar, Dict, List, Optional
|
||||
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.frontend_node.constants import (CLASSES_TO_REMOVE,
|
||||
FORCE_SHOW_FIELDS)
|
||||
from langflow.template.frontend_node.constants import CLASSES_TO_REMOVE, FORCE_SHOW_FIELDS
|
||||
from langflow.template.frontend_node.formatter import field_formatters
|
||||
from langflow.template.template.base import Template
|
||||
from langflow.utils import constants
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ def create_class(code, class_name):
|
|||
class_code = extract_class_code(module, class_name)
|
||||
compiled_class = compile_class_code(class_code)
|
||||
|
||||
return build_class_constructor( compiled_class, exec_globals, class_name)
|
||||
return build_class_constructor(compiled_class, exec_globals, class_name)
|
||||
|
||||
|
||||
def create_type_ignore_class():
|
||||
|
|
@ -228,7 +228,7 @@ def compile_class_code(class_code):
|
|||
return code_obj
|
||||
|
||||
|
||||
def build_class_constructor( compiled_class, exec_globals, class_name):
|
||||
def build_class_constructor(compiled_class, exec_globals, class_name):
|
||||
"""
|
||||
Builds a constructor function for the dynamically created class.
|
||||
|
||||
|
|
@ -267,11 +267,27 @@ def get_default_imports(code_string):
|
|||
}
|
||||
|
||||
langflow_imports = [
|
||||
"AgentExecutor", "BaseChatMemory", "BaseLanguageModel", "BaseLLM",
|
||||
"BaseLoader", "BaseMemory", "BaseOutputParser", "BasePromptTemplate",
|
||||
"BaseRetriever", "Callable", "Chain", "ChatPromptTemplate", "Data",
|
||||
"Document", "Embeddings", "NestedDict", "Object", "PromptTemplate",
|
||||
"TextSplitter", "Tool", "VectorStore"
|
||||
"AgentExecutor",
|
||||
"BaseChatMemory",
|
||||
"BaseLanguageModel",
|
||||
"BaseLLM",
|
||||
"BaseLoader",
|
||||
"BaseMemory",
|
||||
"BaseOutputParser",
|
||||
"BasePromptTemplate",
|
||||
"BaseRetriever",
|
||||
"Callable",
|
||||
"Chain",
|
||||
"ChatPromptTemplate",
|
||||
"Data",
|
||||
"Document",
|
||||
"Embeddings",
|
||||
"NestedDict",
|
||||
"Object",
|
||||
"PromptTemplate",
|
||||
"TextSplitter",
|
||||
"Tool",
|
||||
"VectorStore",
|
||||
]
|
||||
necessary_imports = find_names_in_code(code_string, langflow_imports + ["Optional", "List", "Dict", "Union"])
|
||||
langflow_module = importlib.import_module("langflow.field_typing")
|
||||
|
|
@ -279,6 +295,7 @@ def get_default_imports(code_string):
|
|||
|
||||
return default_imports
|
||||
|
||||
|
||||
def find_names_in_code(code, names):
|
||||
"""
|
||||
Finds if any of the specified names are present in the given code string.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue