formating and linting
This commit is contained in:
parent
c41957c67e
commit
4ff42190a1
9 changed files with 26 additions and 25 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from langflow.graph.utils import extract_input_variables_from_prompt
|
||||
from pydantic import BaseModel, validator
|
||||
|
||||
from langflow.graph.utils import extract_input_variables_from_prompt
|
||||
|
||||
|
||||
class Code(BaseModel):
|
||||
code: str
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from fastapi import HTTPException
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from langflow.api.base import (
|
||||
Code,
|
||||
CodeValidationResponse,
|
||||
|
|
@ -6,12 +7,8 @@ from langflow.api.base import (
|
|||
PromptValidationResponse,
|
||||
validate_prompt,
|
||||
)
|
||||
|
||||
from langflow.utils.validate import validate_code
|
||||
from langflow.utils.logger import logger
|
||||
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from langflow.utils.validate import validate_code
|
||||
|
||||
# build router
|
||||
router = APIRouter(prefix="/validate", tags=["validate"])
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from abc import ABC, abstractmethod
|
||||
import abc
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Dict, List, Optional, Type, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ class LangChainTypeCreator(BaseModel, ABC):
|
|||
type_dict: Optional[Dict] = None
|
||||
|
||||
@property
|
||||
def frontend_node_class(self) -> str:
|
||||
def frontend_node_class(self) -> Type[FrontendNode]:
|
||||
"""The class type of the FrontendNode created in frontend_node."""
|
||||
return FrontendNode
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Dict, List, Optional
|
||||
from langflow.custom.customs import get_custom_nodes
|
||||
|
||||
from langflow.custom.customs import get_custom_nodes
|
||||
from langflow.interface.base import LangChainTypeCreator
|
||||
from langflow.interface.custom_lists import chain_type_to_cls_dict
|
||||
from langflow.settings import settings
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
from typing import Optional
|
||||
from typing import Dict, Optional, Type
|
||||
|
||||
from langchain.chains import ConversationChain
|
||||
from langflow.graph.utils import extract_input_variables_from_prompt
|
||||
from pydantic import root_validator, Field
|
||||
from langchain.memory.buffer import ConversationBufferMemory
|
||||
from langchain.schema import BaseMemory
|
||||
from pydantic import Field, root_validator
|
||||
|
||||
from langflow.graph.utils import extract_input_variables_from_prompt
|
||||
|
||||
DEFAULT_SUFFIX = """"
|
||||
Current conversation:
|
||||
|
|
@ -93,7 +94,7 @@ class TimeTravelGuideChain(BaseCustomChain):
|
|||
AI:"""
|
||||
|
||||
|
||||
CUSTOM_CHAINS = {
|
||||
CUSTOM_CHAINS: Dict[str, Type[ConversationChain]] = {
|
||||
"SeriesCharacterChain": SeriesCharacterChain,
|
||||
"MidJourneyPromptChain": MidJourneyPromptChain,
|
||||
"TimeTravelGuideChain": TimeTravelGuideChain,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# This module is used to import any langchain class by name.
|
||||
|
||||
import importlib
|
||||
from typing import Any
|
||||
from typing import Any, Type
|
||||
|
||||
from langchain import PromptTemplate
|
||||
from langchain.agents import Agent
|
||||
|
|
@ -10,7 +10,6 @@ from langchain.chat_models.base import BaseChatModel
|
|||
from langchain.llms.base import BaseLLM
|
||||
from langchain.tools import BaseTool
|
||||
|
||||
|
||||
from langflow.interface.tools.util import get_tool_by_name
|
||||
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ def import_class(class_path: str) -> Any:
|
|||
return getattr(module, class_name)
|
||||
|
||||
|
||||
def import_prompt(prompt: str) -> PromptTemplate:
|
||||
def import_prompt(prompt: str) -> Type[PromptTemplate]:
|
||||
from langflow.interface.prompts.custom import CUSTOM_PROMPTS
|
||||
|
||||
"""Import prompt from prompt name"""
|
||||
|
|
@ -105,7 +104,7 @@ def import_tool(tool: str) -> BaseTool:
|
|||
return get_tool_by_name(tool)
|
||||
|
||||
|
||||
def import_chain(chain: str) -> Chain:
|
||||
def import_chain(chain: str) -> Type[Chain]:
|
||||
"""Import chain from chain name"""
|
||||
from langflow.interface.chains.custom import CUSTOM_CHAINS
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List, Optional, Type
|
||||
|
||||
from langflow.interface.base import LangChainTypeCreator
|
||||
from langflow.interface.custom_lists import memory_type_to_cls_dict
|
||||
from langflow.settings import settings
|
||||
from langflow.template.base import FrontendNode
|
||||
from langflow.template.nodes import MemoryFrontendNode
|
||||
from langflow.utils.util import build_template_from_class
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ class MemoryCreator(LangChainTypeCreator):
|
|||
type_name: str = "memories"
|
||||
|
||||
@property
|
||||
def frontend_node_class(self) -> str:
|
||||
def frontend_node_class(self) -> Type[FrontendNode]:
|
||||
"""The class type of the FrontendNode created in frontend_node."""
|
||||
return MemoryFrontendNode
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from typing import Dict, List, Optional
|
||||
|
||||
from langchain.prompts import loading
|
||||
from langchain import prompts
|
||||
from langchain.prompts import loading
|
||||
|
||||
from langflow.custom.customs import get_custom_nodes
|
||||
from langflow.interface.base import LangChainTypeCreator
|
||||
from langflow.interface.importing.utils import import_class
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Dict, List, Optional
|
||||
from typing import Dict, List, Optional, Type
|
||||
|
||||
from langchain.prompts import PromptTemplate
|
||||
from pydantic import root_validator
|
||||
|
|
@ -7,7 +7,6 @@ from langflow.graph.utils import extract_input_variables_from_prompt
|
|||
from langflow.template.base import Template, TemplateField
|
||||
from langflow.template.nodes import PromptTemplateNode
|
||||
|
||||
|
||||
# Steps to create a BaseCustomPrompt:
|
||||
# 1. Create a prompt template that endes with:
|
||||
# Current conversation:
|
||||
|
|
@ -71,7 +70,9 @@ Human: {input}
|
|||
input_variables: List[str] = ["character", "series"]
|
||||
|
||||
|
||||
CUSTOM_PROMPTS = {"SeriesCharacterPrompt": SeriesCharacterPrompt}
|
||||
CUSTOM_PROMPTS: Dict[str, Type[BaseCustomPrompt]] = {
|
||||
"SeriesCharacterPrompt": SeriesCharacterPrompt
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
prompt = SeriesCharacterPrompt(character="Harry Potter", series="Harry Potter")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue