🔨 refactor(LLMChain.py): remove unused import statement for Text from langflow.field_typing
🔨 refactor(utils.py): rename variable 'return_type' to 'return_types' for clarity 🔨 refactor(types.py): add Optional and Union imports, add type hints for user_id parameter in build_field_config and build_langchain_template_custom_component functions
This commit is contained in:
parent
0e3c80bc40
commit
47e5d49c8f
3 changed files with 10 additions and 8 deletions
|
|
@ -6,7 +6,6 @@ from langflow.field_typing import (
|
||||||
BaseLanguageModel,
|
BaseLanguageModel,
|
||||||
BaseMemory,
|
BaseMemory,
|
||||||
Chain,
|
Chain,
|
||||||
Text,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,5 +26,5 @@ class LLMChainComponent(CustomComponent):
|
||||||
prompt: BasePromptTemplate,
|
prompt: BasePromptTemplate,
|
||||||
llm: BaseLanguageModel,
|
llm: BaseLanguageModel,
|
||||||
memory: Optional[BaseMemory] = None,
|
memory: Optional[BaseMemory] = None,
|
||||||
) -> Union[Chain, Callable, Text]:
|
) -> Union[Chain, Callable]:
|
||||||
return LLMChain(prompt=prompt, llm=llm, memory=memory)
|
return LLMChain(prompt=prompt, llm=llm, memory=memory)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,6 @@ def extract_union_types(return_type: str) -> list[str]:
|
||||||
"""
|
"""
|
||||||
# If the return type is a Union, then we need to parse it
|
# If the return type is a Union, then we need to parse it
|
||||||
return_type = return_type.replace("Union", "").replace("[", "").replace("]", "")
|
return_type = return_type.replace("Union", "").replace("[", "").replace("]", "")
|
||||||
return_type = return_type.split(",")
|
return_types = return_type.split(",")
|
||||||
return_type = [item.strip() for item in return_type]
|
return_types = [item.strip() for item in return_types]
|
||||||
return return_type
|
return return_types
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import ast
|
import ast
|
||||||
import contextlib
|
import contextlib
|
||||||
from typing import Any, List
|
from typing import Any, List, Union, Optional
|
||||||
|
from uuid import UUID
|
||||||
from langflow.api.utils import get_new_key
|
from langflow.api.utils import get_new_key
|
||||||
from langflow.interface.agents.base import agent_creator
|
from langflow.interface.agents.base import agent_creator
|
||||||
from langflow.interface.chains.base import chain_creator
|
from langflow.interface.chains.base import chain_creator
|
||||||
|
|
@ -208,7 +209,9 @@ def update_attributes(frontend_node, template_config):
|
||||||
frontend_node[attribute] = template_config[attribute]
|
frontend_node[attribute] = template_config[attribute]
|
||||||
|
|
||||||
|
|
||||||
def build_field_config(custom_component: CustomComponent, user_id: str = None):
|
def build_field_config(
|
||||||
|
custom_component: CustomComponent, user_id: Optional[Union[str, UUID]] = None
|
||||||
|
):
|
||||||
"""Build the field configuration for a custom component"""
|
"""Build the field configuration for a custom component"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -307,7 +310,7 @@ def add_output_types(frontend_node, return_types: List[str]):
|
||||||
|
|
||||||
|
|
||||||
def build_langchain_template_custom_component(
|
def build_langchain_template_custom_component(
|
||||||
custom_component: CustomComponent, user_id: str = None
|
custom_component: CustomComponent, user_id: Optional[Union[str, UUID]] = None
|
||||||
):
|
):
|
||||||
"""Build a custom component template for the langchain"""
|
"""Build a custom component template for the langchain"""
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue