Merge branch 'zustand/io/migration' of personal:logspace-ai/langflow into zustand/io/migration

This commit is contained in:
anovazzi1 2024-03-11 18:18:51 -03:00
commit b3ed843140
9 changed files with 33 additions and 23 deletions

View file

@ -259,7 +259,7 @@ class VerticesBuiltResponse(BaseModel):
class InputValueRequest(BaseModel):
components: Optional[List[str]] = None
components: Optional[List[str]] = []
input_value: Optional[str] = None
# add an example

View file

@ -171,8 +171,7 @@ class Graph:
raise ValueError(f"Error running graph: {exc}") from exc
# Get the outputs
vertex_outputs = []
for vertex_id in self.vertices:
vertex = self.get_vertex(vertex_id)
for vertex in self.vertices:
if vertex is None:
raise ValueError(f"Vertex {vertex_id} not found")
@ -202,8 +201,10 @@ class Graph:
for input_dict in inputs:
components: Union[str, list[str]] = input_dict.get("components", [])
if not isinstance(components, list):
components = [components]
if components and not isinstance(components, list):
raise ValueError(f"Invalid components value: {components}. Expected list")
elif components is None:
components = []
if INPUT_FIELD_NAME not in input_dict:
input_value = ""

View file

@ -13,6 +13,8 @@ class ResultData(BaseModel):
messages: Optional[list[ChatOutputResponse]] = Field(default_factory=list)
timedelta: Optional[float] = None
duration: Optional[str] = None
component_display_name: Optional[str] = None
component_id: Optional[str] = None
@field_serializer("results")
def serialize_results(self, value):

View file

@ -428,6 +428,8 @@ class Vertex:
results=result_dict,
artifacts=artifacts,
messages=messages,
component_display_name=self.display_name,
component_id=self.id,
)
self.set_result(result_dict)

View file

@ -272,6 +272,9 @@ def process_tweaks(graph_data: Dict[str, Any], tweaks: Union["Tweaks", Dict[str,
:raises ValueError: If the input is not in the expected format.
"""
if not isinstance(tweaks, dict):
tweaks = tweaks.model_dump()
nodes = validate_input(graph_data, tweaks)
nodes_map = {node.get("id"): node for node in nodes}

View file

@ -103,7 +103,7 @@ export default function App() {
</ErrorBoundary>
<div></div>
<div className="app-div">
<div className="flex flex-col-reverse" style={{zIndex: 999}}>
<div className="flex flex-col-reverse" style={{ zIndex: 999 }}>
{tempNotificationList.map((alert) => (
<div key={alert.id}>
{alert.type === "error" && (
@ -118,7 +118,7 @@ export default function App() {
</div>
))}
</div>
<div className="flex flex-col-reverse z-40">
<div className="z-40 flex flex-col-reverse">
{tempNotificationList.map((alert) => (
<div key={alert.id}>
{alert.type === "notice" ? (
@ -129,13 +129,15 @@ export default function App() {
id={alert.id}
removeAlert={removeAlert}
/>
) : alert.type === "success" && (
<SuccessAlert
key={alert.id}
title={alert.title}
id={alert.id}
removeAlert={removeAlert}
/>
) : (
alert.type === "success" && (
<SuccessAlert
key={alert.id}
title={alert.title}
id={alert.id}
removeAlert={removeAlert}
/>
)
)}
</div>
))}

View file

@ -75,7 +75,11 @@ export default function GenericNode({
// This one should run only once
// first check if data.type in NATIVE_CATEGORIES
// if not return
if (!NATIVE_CATEGORIES.includes(types[data.type]) || !data.node?.template?.code?.value) return;
if (
!NATIVE_CATEGORIES.includes(types[data.type]) ||
!data.node?.template?.code?.value
)
return;
const thisNodeTemplate = templates[data.type].template;
// if the template does not have a code key
// return
@ -110,7 +114,7 @@ export default function GenericNode({
updateNodeInternals(data.id);
},
[data.id, data.node, setNode,setIsOutdated]
[data.id, data.node, setNode, setIsOutdated]
);
if (!data.node!.template) {

View file

@ -386,7 +386,7 @@ export function getCurlCode(
-H 'Content-Type: application/json'\\${
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
}
-d '{"inputs": ${inputs}, "tweaks": ${
-d '{"inputs": [${inputs}], "tweaks": ${
tweak && tweak.length > 0
? buildTweakObject(tweak)
: JSON.stringify(tweaks, null, 2)

View file

@ -24,9 +24,7 @@ def test_document_to_record_component():
# Act
# Replace with your actual test data
document = Document(
page_content="key: value", metadata={"url": "https://example.com"}
)
document = Document(page_content="key: value", metadata={"url": "https://example.com"})
result = document_to_record_component.build(document)
# Assert
@ -44,9 +42,7 @@ def test_uuid_generator_component():
# Act
build_config = frontend_node.get("template")
field_name = "unique_id"
build_config = uuid_generator_component.update_build_config(
build_config, None, field_name
)
build_config = uuid_generator_component.update_build_config(build_config, None, field_name)
unique_id = build_config["unique_id"]["value"]
result = uuid_generator_component.build(unique_id)