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): class InputValueRequest(BaseModel):
components: Optional[List[str]] = None components: Optional[List[str]] = []
input_value: Optional[str] = None input_value: Optional[str] = None
# add an example # add an example

View file

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

View file

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

View file

@ -428,6 +428,8 @@ class Vertex:
results=result_dict, results=result_dict,
artifacts=artifacts, artifacts=artifacts,
messages=messages, messages=messages,
component_display_name=self.display_name,
component_id=self.id,
) )
self.set_result(result_dict) 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. :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 = validate_input(graph_data, tweaks)
nodes_map = {node.get("id"): node for node in nodes} nodes_map = {node.get("id"): node for node in nodes}

View file

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

View file

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

View file

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

View file

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