style: ruff
This commit is contained in:
parent
35adfaa711
commit
48cb3b06ca
6 changed files with 16 additions and 16 deletions
|
|
@ -7,6 +7,7 @@ from pathlib import Path
|
||||||
|
|
||||||
from langflow.server import LangflowApplication
|
from langflow.server import LangflowApplication
|
||||||
|
|
||||||
|
|
||||||
def serve(
|
def serve(
|
||||||
workers: int = None,
|
workers: int = None,
|
||||||
timeout: int = None,
|
timeout: int = None,
|
||||||
|
|
@ -28,9 +29,12 @@ def serve(
|
||||||
if not timeout:
|
if not timeout:
|
||||||
timeout = 60
|
timeout = 60
|
||||||
|
|
||||||
|
options = {
|
||||||
options = {"bind": "0.0.0.0:5003", "workers": workers, "worker_class": "uvicorn.workers.UvicornWorker", "timeout": timeout}
|
"bind": "0.0.0.0:5003",
|
||||||
|
"workers": workers,
|
||||||
|
"worker_class": "uvicorn.workers.UvicornWorker",
|
||||||
|
"timeout": timeout,
|
||||||
|
}
|
||||||
|
|
||||||
LangflowApplication(app, options).run()
|
LangflowApplication(app, options).run()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from langchain.agents.mrkl import prompt
|
||||||
|
|
||||||
def get_custom_prompts():
|
def get_custom_prompts():
|
||||||
"""Get custom prompts."""
|
"""Get custom prompts."""
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ZeroShotPrompt": {
|
"ZeroShotPrompt": {
|
||||||
"template": {
|
"template": {
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,6 @@ def replace_zero_shot_prompt_with_prompt_template(nodes):
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def load_langchain_type_from_config(config: Dict[str, Any]):
|
def load_langchain_type_from_config(config: Dict[str, Any]):
|
||||||
"""Load langchain type from config"""
|
"""Load langchain type from config"""
|
||||||
# Get type list
|
# Get type list
|
||||||
|
|
@ -52,9 +49,6 @@ def load_langchain_type_from_config(config: Dict[str, Any]):
|
||||||
raise ValueError("Type should be either agent, chain or llm")
|
raise ValueError("Type should be either agent, chain or llm")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def build_prompt_template(prompt, tools):
|
def build_prompt_template(prompt, tools):
|
||||||
"""Build PromptTemplate from ZeroShotPrompt"""
|
"""Build PromptTemplate from ZeroShotPrompt"""
|
||||||
prefix = prompt["node"]["template"]["prefix"]["value"]
|
prefix = prompt["node"]["template"]["prefix"]["value"]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ import re
|
||||||
|
|
||||||
def extract_input_variables(data):
|
def extract_input_variables(data):
|
||||||
"""
|
"""
|
||||||
Extracts input variables from the template and adds them to the input_variables field.
|
Extracts input variables from the template
|
||||||
|
and adds them to the input_variables field.
|
||||||
"""
|
"""
|
||||||
for node in data["nodes"]:
|
for node in data["nodes"]:
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
|
|
@ -59,7 +60,6 @@ def build_json(root, nodes, edges):
|
||||||
elif "dict" in module_type:
|
elif "dict" in module_type:
|
||||||
value = {}
|
value = {}
|
||||||
else:
|
else:
|
||||||
|
|
||||||
children = []
|
children = []
|
||||||
for c in local_nodes:
|
for c in local_nodes:
|
||||||
module_types = [c["data"]["type"]]
|
module_types = [c["data"]["type"]]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import inspect
|
||||||
import re
|
import re
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
from langchain.agents.load_tools import *
|
|
||||||
from langchain.agents.load_tools import (
|
from langchain.agents.load_tools import (
|
||||||
_BASE_TOOLS,
|
_BASE_TOOLS,
|
||||||
_LLM_TOOLS,
|
_LLM_TOOLS,
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,13 @@ class LangflowApplication(BaseApplication):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
config = {key: value for key, value in self.options.items()
|
config = {
|
||||||
if key in self.cfg.settings and value is not None}
|
key: value
|
||||||
|
for key, value in self.options.items()
|
||||||
|
if key in self.cfg.settings and value is not None
|
||||||
|
}
|
||||||
for key, value in config.items():
|
for key, value in config.items():
|
||||||
self.cfg.set(key.lower(), value)
|
self.cfg.set(key.lower(), value)
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
return self.application
|
return self.application
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue