Merge branch 'dev' into modalRefactor

This commit is contained in:
Lucas Oliveira 2023-07-23 19:48:41 -03:00
commit 7239223481
14 changed files with 529 additions and 224 deletions

View file

@ -134,6 +134,7 @@ async def stream_build(flow_id: str):
# to set the input_keys values
artifacts.update(vertex.artifacts)
except Exception as exc:
logger.exception(exc)
params = str(exc)
valid = False
flow_data_store[flow_id]["status"] = BuildStatus.FAILURE

View file

@ -176,6 +176,8 @@ class Vertex:
for node in nodes:
built = node.build()
if isinstance(built, list):
if key not in self.params:
self.params[key] = []
self.params[key].extend(built)
else:
self.params[key].append(built)

View file

@ -98,7 +98,7 @@ class DocumentLoaderVertex(Vertex):
self._built_object
)
return f"""{self.vertex_type}({len(self._built_object)} documents)
\nAvg. Document Length (characters): {avg_length}
\nAvg. Document Length (characters): {int(avg_length)}
Documents: {self._built_object[:3]}..."""
return f"{self.vertex_type}()"
@ -136,7 +136,7 @@ class TextSplitterVertex(Vertex):
self._built_object
)
return f"""{self.vertex_type}({len(self._built_object)} documents)
\nAvg. Document Length (characters): {avg_length}
\nAvg. Document Length (characters): {int(avg_length)}
\nDocuments: {self._built_object[:3]}..."""
return f"{self.vertex_type}()"

View file

@ -59,15 +59,20 @@ def setup_static_files(app: FastAPI, static_files_dir: Path):
return FileResponse(path)
# app = create_app()
# setup_static_files(app, static_files_dir)
def get_static_files_dir():
"""Get the static files directory relative to Langflow's main.py file."""
frontend_path = Path(__file__).parent
return frontend_path / "frontend"
def setup_app(static_files_dir: Optional[Path] = None) -> FastAPI:
"""Setup the FastAPI app."""
# get the directory of the current file
if not static_files_dir:
frontend_path = Path(__file__).parent
static_files_dir = frontend_path / "frontend"
static_files_dir = get_static_files_dir()
if not static_files_dir or not static_files_dir.exists():
raise RuntimeError(f"Static files directory {static_files_dir} does not exist.")
app = create_app()
setup_static_files(app, static_files_dir)
return app

View file

@ -15,6 +15,7 @@ class TextSplittersFrontendNode(FrontendNode):
required=True,
show=True,
name="documents",
is_list=True,
)
)
name = "separator"

View file

@ -259,7 +259,7 @@ class VectorStoreFrontendNode(FrontendNode):
field.required = False
field.show = True
field.advanced = False
field.is_list = True
elif "embedding" in field.name:
# for backwards compatibility
field.name = "embedding"

View file

@ -76,7 +76,7 @@ export async function postValidatePrompt(
*/
export async function getExamples(): Promise<FlowType[]> {
const url =
"https://api.github.com/repos/logspace-ai/langflow_examples/contents/examples?ref=fix_examples";
"https://api.github.com/repos/logspace-ai/langflow_examples/contents/examples?ref=main";
const response = await axios.get(url);
const jsonFiles = response.data.filter((file: any) => {