refac: remove not tested components
This commit is contained in:
parent
c333f57a0c
commit
5a55c65642
6 changed files with 35 additions and 15 deletions
|
|
@ -6,7 +6,7 @@ WORKDIR /app
|
|||
RUN apt-get update && apt-get install git -y
|
||||
|
||||
COPY --from=backend_build /app/dist/*.whl /app/
|
||||
RUN pip install langflow-0.0.17-py3-none-any.whl
|
||||
RUN pip install langflow-0.0.19-py3-none-any.whl
|
||||
RUN rm *.whl
|
||||
|
||||
EXPOSE 80
|
||||
|
|
|
|||
9
langflow/backend/allowed_components.py
Normal file
9
langflow/backend/allowed_components.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
CHAINS = ["LLMChain", "LLMMathChain", "LLMRequestsChain", "LLMBashChain"]
|
||||
|
||||
AGENTS = ["ZeroShotAgent"]
|
||||
|
||||
PROMPTS = ["PromptTemplate", "FewShotPromptTemplate"]
|
||||
|
||||
LLMS = ["OpenAI"]
|
||||
|
||||
TOOLS = ["Search", "requests_get", "PAL-MATH", "Calculator"]
|
||||
|
|
@ -5,4 +5,4 @@ docker build -t logspace/backend_build -f build.Dockerfile .
|
|||
VERSION=$(toml get --toml-path pyproject.toml tool.poetry.version)
|
||||
docker build --build-arg VERSION=$VERSION -t ibiscp/langflow_backend:$VERSION .
|
||||
docker push ibiscp/langflow_backend:$VERSION
|
||||
# poetry add --editable ../../../langchain
|
||||
poetry add --editable ../../../langchain
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@ def get_type_list():
|
|||
|
||||
@router.get("/all")
|
||||
def get_all():
|
||||
# library_prompts = {
|
||||
# prompt: signature.get_prompt(prompt) for prompt in list_endpoints.list_prompts()
|
||||
# }
|
||||
# custom_prompts = customs.get_custom_prompts()
|
||||
return {
|
||||
"chains": {
|
||||
chain: signature.get_chain(chain) for chain in list_endpoints.list_chains()
|
||||
|
|
@ -41,7 +37,6 @@ def get_all():
|
|||
"agents": {
|
||||
agent: signature.get_agent(agent) for agent in list_endpoints.list_agents()
|
||||
},
|
||||
# "prompts": {**library_prompts, **custom_prompts},
|
||||
"prompts": {
|
||||
prompt: signature.get_prompt(prompt)
|
||||
for prompt in list_endpoints.list_prompts()
|
||||
|
|
@ -110,7 +105,7 @@ def get_load(data: dict[str, Any]):
|
|||
with io.StringIO() as output_buffer, contextlib.redirect_stdout(output_buffer):
|
||||
result = loaded.run(message)
|
||||
thought = output_buffer.getvalue()
|
||||
|
||||
|
||||
elif extracted_json["_type"] in type_list["chains"]:
|
||||
loaded = load_chain_from_config(extracted_json)
|
||||
|
||||
|
|
@ -128,7 +123,12 @@ def get_load(data: dict[str, Any]):
|
|||
result = "Error: Type should be either agent, chain or llm"
|
||||
thought = ""
|
||||
|
||||
return {"result": result, "thought": re.sub(r'\x1b\[([0-9,A-Z]{1,2}(;[0-9,A-Z]{1,2})?)?[m|K]', '', thought).strip()}
|
||||
return {
|
||||
"result": result,
|
||||
"thought": re.sub(
|
||||
r"\x1b\[([0-9,A-Z]{1,2}(;[0-9,A-Z]{1,2})?)?[m|K]", "", thought
|
||||
).strip(),
|
||||
}
|
||||
|
||||
|
||||
def build_prompt_template(prompt, tools):
|
||||
|
|
@ -147,7 +147,6 @@ def build_prompt_template(prompt, tools):
|
|||
value = "\n\n".join([prefix, tool_strings, format_instructions, suffix])
|
||||
|
||||
prompt["type"] = "PromptTemplate"
|
||||
# prompt["value"] = value
|
||||
|
||||
prompt["node"] = {
|
||||
"template": {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from langchain.chains.conversation import memory as memories
|
|||
from langchain.agents.load_tools import get_all_tool_names
|
||||
from langflow.backend import util
|
||||
from langflow.backend import customs
|
||||
from langflow.backend import allowed_components
|
||||
|
||||
|
||||
# build router
|
||||
|
|
@ -26,7 +27,7 @@ def read_items():
|
|||
"prompts",
|
||||
"llms",
|
||||
# "utilities",
|
||||
"memories",
|
||||
# "memories",
|
||||
# "document_loaders",
|
||||
# "vectorstores",
|
||||
# "docstores",
|
||||
|
|
@ -40,6 +41,7 @@ def list_chains():
|
|||
return [
|
||||
chain.__annotations__["return"].__name__
|
||||
for chain in chains.loading.type_to_loader_dict.values()
|
||||
if chain.__annotations__["return"].__name__ in allowed_components.CHAINS
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -47,7 +49,11 @@ def list_chains():
|
|||
def list_agents():
|
||||
"""List all agent types"""
|
||||
# return list(agents.loading.AGENT_TO_CLASS.keys())
|
||||
return [agent.__name__ for agent in agents.loading.AGENT_TO_CLASS.values()]
|
||||
return [
|
||||
agent.__name__
|
||||
for agent in agents.loading.AGENT_TO_CLASS.values()
|
||||
if agent.__name__ in allowed_components.AGENTS
|
||||
]
|
||||
|
||||
|
||||
@router.get("/prompts")
|
||||
|
|
@ -57,6 +63,7 @@ def list_prompts():
|
|||
library_prompts = [
|
||||
prompt.__annotations__["return"].__name__
|
||||
for prompt in prompts.loading.type_to_loader_dict.values()
|
||||
if prompt.__annotations__["return"].__name__ in allowed_components.PROMPTS
|
||||
]
|
||||
return library_prompts + list(custom_prompts.keys())
|
||||
|
||||
|
|
@ -64,7 +71,11 @@ def list_prompts():
|
|||
@router.get("/llms")
|
||||
def list_llms():
|
||||
"""List all llm types"""
|
||||
return [llm.__name__ for llm in llms.type_to_cls_dict.values()]
|
||||
return [
|
||||
llm.__name__
|
||||
for llm in llms.type_to_cls_dict.values()
|
||||
if llm.__name__ in allowed_components.LLMS
|
||||
]
|
||||
|
||||
|
||||
@router.get("/memories")
|
||||
|
|
@ -104,7 +115,8 @@ def list_tools():
|
|||
tools = []
|
||||
|
||||
for tool in get_all_tool_names():
|
||||
if tool_params := util.get_tool_params(util.get_tools_dict(tool)):
|
||||
tool_params = util.get_tool_params(util.get_tools_dict(tool))
|
||||
if tool_params and tool_params["name"] in allowed_components.TOOLS:
|
||||
tools.append(tool_params["name"])
|
||||
|
||||
return tools
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "langflow"
|
||||
version = "0.0.17"
|
||||
version = "0.0.19"
|
||||
description = "Backend for Langflow"
|
||||
authors = ["Ibis Prevedello <ibiscp@gmail.com>"]
|
||||
# packages = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue