linting
This commit is contained in:
parent
03172a19f8
commit
9891d6b68a
7 changed files with 16 additions and 16 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import contextlib
|
from typing import Dict, List
|
||||||
from typing import Dict, Iterable
|
|
||||||
|
|
||||||
from langchain.agents import loading
|
from langchain.agents import loading
|
||||||
|
|
||||||
|
|
@ -33,7 +32,8 @@ class AgentCreator(LangChainTypeCreator):
|
||||||
raise ValueError("Agent not found") from exc
|
raise ValueError("Agent not found") from exc
|
||||||
|
|
||||||
# Now this is a generator
|
# Now this is a generator
|
||||||
def to_list(self) -> Iterable:
|
def to_list(self) -> List[str]:
|
||||||
|
names = []
|
||||||
for name, agent in self.type_to_loader_dict.items():
|
for name, agent in self.type_to_loader_dict.items():
|
||||||
agent_name = (
|
agent_name = (
|
||||||
agent.function_name()
|
agent.function_name()
|
||||||
|
|
@ -41,7 +41,8 @@ class AgentCreator(LangChainTypeCreator):
|
||||||
else agent.__name__
|
else agent.__name__
|
||||||
)
|
)
|
||||||
if agent_name in settings.agents or settings.dev:
|
if agent_name in settings.agents or settings.dev:
|
||||||
yield agent_name
|
names.append(name)
|
||||||
|
return names
|
||||||
|
|
||||||
|
|
||||||
agent_creator = AgentCreator()
|
agent_creator = AgentCreator()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from langchain import LLMChain
|
from langchain import LLMChain
|
||||||
from langchain.agents import AgentExecutor, ZeroShotAgent
|
from langchain.agents import AgentExecutor, ZeroShotAgent
|
||||||
|
|
@ -6,7 +5,6 @@ from langchain.agents.agent_toolkits.json.prompt import JSON_PREFIX, JSON_SUFFIX
|
||||||
from langchain.agents.agent_toolkits.json.toolkit import JsonToolkit
|
from langchain.agents.agent_toolkits.json.toolkit import JsonToolkit
|
||||||
from langchain.agents.mrkl.prompt import FORMAT_INSTRUCTIONS
|
from langchain.agents.mrkl.prompt import FORMAT_INSTRUCTIONS
|
||||||
from langchain.schema import BaseLanguageModel
|
from langchain.schema import BaseLanguageModel
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
|
|
||||||
class MalfoyAgent(AgentExecutor):
|
class MalfoyAgent(AgentExecutor):
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from langchain.prompts import PromptTemplate
|
from langchain.prompts import PromptTemplate
|
||||||
from langflow.graph.utils import extract_input_variables_from_prompt
|
from langflow.graph.utils import extract_input_variables_from_prompt
|
||||||
|
|
@ -13,8 +13,8 @@ You must know all of the knowledge of {character}."""
|
||||||
|
|
||||||
|
|
||||||
class BaseCustomPrompt(PromptTemplate):
|
class BaseCustomPrompt(PromptTemplate):
|
||||||
template: Optional[str] = None
|
template: str = ""
|
||||||
description: str
|
description: Optional[str]
|
||||||
human_text: str = "\n {input}"
|
human_text: str = "\n {input}"
|
||||||
|
|
||||||
@root_validator(pre=False)
|
@root_validator(pre=False)
|
||||||
|
|
@ -41,17 +41,19 @@ class BaseCustomPrompt(PromptTemplate):
|
||||||
for field in self.input_variables
|
for field in self.input_variables
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
description=self.description,
|
description=self.description or "",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SeriesCharacterPrompt(BaseCustomPrompt):
|
class SeriesCharacterPrompt(BaseCustomPrompt):
|
||||||
# Add a very descriptive description for the prompt generator
|
# Add a very descriptive description for the prompt generator
|
||||||
description = "A prompt that asks the AI to act like a character from a series."
|
description: Optional[
|
||||||
|
str
|
||||||
|
] = "A prompt that asks the AI to act like a character from a series."
|
||||||
character: str
|
character: str
|
||||||
series: str
|
series: str
|
||||||
human_text: str = "\n {input}"
|
human_text: str = "\n {input}"
|
||||||
template: Optional[str] = CHARACTER_PROMPT
|
template: str = CHARACTER_PROMPT
|
||||||
|
|
||||||
input_variables: List[str] = ["character", "series"]
|
input_variables: List[str] = ["character", "series"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class FrontendNode(BaseModel):
|
||||||
# Check for list type
|
# Check for list type
|
||||||
if "List" in _type:
|
if "List" in _type:
|
||||||
_type = _type.replace("List[", "")[:-1]
|
_type = _type.replace("List[", "")[:-1]
|
||||||
self.is_list = True
|
field.is_list = True
|
||||||
|
|
||||||
# Replace 'Mapping' with 'dict'
|
# Replace 'Mapping' with 'dict'
|
||||||
if "Mapping" in _type:
|
if "Mapping" in _type:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from typing import Optional
|
||||||
from langchain.agents.mrkl import prompt
|
from langchain.agents.mrkl import prompt
|
||||||
|
|
||||||
from langflow.template.base import FrontendNode, Template, TemplateField
|
from langflow.template.base import FrontendNode, Template, TemplateField
|
||||||
|
|
@ -194,7 +195,7 @@ class InitializeAgentNode(FrontendNode):
|
||||||
return super().to_dict()
|
return super().to_dict()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_field(field: TemplateField, name: str):
|
def format_field(field: TemplateField, name: Optional[str] = None) -> None:
|
||||||
# do nothing and don't return anything
|
# do nothing and don't return anything
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from langflow.graph.graph import Graph
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure():
|
def pytest_configure():
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import importlib
|
import importlib
|
||||||
import re
|
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue