Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add flow notes #3460

Merged
merged 71 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
eab4490
feat: Add NoteDraggableComponent to extraSidebarComponent
anovazzi1 Aug 20, 2024
fa2f40b
feat: Add NoteNode component for displaying and editing notes
anovazzi1 Aug 20, 2024
af36430
feat: Add NoteNode and NoteDraggableComponent for managing notes in F…
anovazzi1 Aug 20, 2024
44a3102
feat: Add DRAG_EVENTS_CUSTOM_TYPESS constant for custom drag event types
anovazzi1 Aug 20, 2024
401e15b
feat: Add support functions for custom drag event types
anovazzi1 Aug 20, 2024
ab3a527
feat: Add support for custom drag event types in PageComponent
anovazzi1 Aug 20, 2024
3b35bb7
feat: Add NoteDataType for managing note data in FlowPage
anovazzi1 Aug 20, 2024
d859ceb
refactor: create new types for noteNode
anovazzi1 Aug 20, 2024
bcb7548
feat: Update NoteNode component to use new NoteDataType
anovazzi1 Aug 20, 2024
edf1bc7
node with title and description
anovazzi1 Aug 20, 2024
1032be0
feat: Add "note" alias for StickyNote in nodeIconsLucide
anovazzi1 Aug 20, 2024
3eba0ea
refactor: Update NodeDescription component to use emptyPlaceholder prop
anovazzi1 Aug 20, 2024
f744500
refactor: Remove unused Textarea import in NoteNode component
anovazzi1 Aug 20, 2024
2d7a3fd
add initial resize to note component
anovazzi1 Aug 20, 2024
fba8926
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 20, 2024
9059b95
refactor: add code validation functionality on tanstack mutation (#3469)
lucaseduoli Aug 21, 2024
a245352
refactor: Update NodeName component to use full width in GenericNode
anovazzi1 Aug 21, 2024
1e3b4e6
refactor: Update NodeDescription component to use full height in Gene…
anovazzi1 Aug 21, 2024
08afd1d
refactor: Update NodeDescription component to use full height in Gene…
anovazzi1 Aug 21, 2024
3953e5a
refactor: Update NodeDescription component to use full height in Gene…
anovazzi1 Aug 21, 2024
529af50
increase size control on note node
anovazzi1 Aug 21, 2024
735ef91
refactor: Update NoteNode component to use constants for min and max …
anovazzi1 Aug 21, 2024
cc13c77
fix overflow issue
anovazzi1 Aug 21, 2024
8b1bf70
refactor: update NoteDraggableComponent
anovazzi1 Aug 21, 2024
67d2a94
refactor: Update NoteNode component to use constants for min and max …
anovazzi1 Aug 21, 2024
73a8f64
update component to accept multiple colors
anovazzi1 Aug 22, 2024
68d29bd
update note colors
anovazzi1 Aug 22, 2024
d9b1514
update min width
anovazzi1 Aug 22, 2024
1649e99
refactor: Update NodeDescription component to accept additional styli…
anovazzi1 Aug 22, 2024
7c00ebe
fix bug on description size
anovazzi1 Aug 22, 2024
e506936
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 23, 2024
f4e1b66
feat: skip note nodes when building vertices"
ogabrielluiz Aug 23, 2024
577c602
fix: update serialization and improve error handling (#3516)
ogabrielluiz Aug 23, 2024
59b41ad
fix: no module named 'psycopg2' (#3526)
italojohnny Aug 23, 2024
5ed1837
feat: add compression support to frontend and backend (#3484)
lucaseduoli Aug 23, 2024
7831e23
refactor: add code validation functionality on tanstack mutation (#3469)
lucaseduoli Aug 21, 2024
b48d104
refactor: Update NodeName component to use full width in GenericNode
anovazzi1 Aug 21, 2024
b076faf
fix imports
anovazzi1 Aug 26, 2024
27b0600
refactor: remove unused import in styleUtils.ts
anovazzi1 Aug 26, 2024
2f142b5
refactor: update checkOldNodesOutput to include only generic nodes
anovazzi1 Aug 26, 2024
eee8be0
refactor: improve checkOldNodesOutput to include only generic nodes
anovazzi1 Aug 26, 2024
a78fe8f
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 26, 2024
7b56e4e
📝 (frontend): Add data-testid attribute to elements for testing purpo…
Cristhianzl Aug 26, 2024
139d42c
✨ (stop-building.spec.ts): Add a 1-second delay after clicking the st…
Cristhianzl Aug 26, 2024
49f5ec9
refactor: update NodeName and GenericNode components to improve UI an…
anovazzi1 Aug 26, 2024
ab41dd1
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 26, 2024
645e4ae
chore: Update NodeDescription component to use dark mode placeholder …
anovazzi1 Aug 26, 2024
8c0da68
chore: Update sidebar note component icon to use StickyNote instead o…
anovazzi1 Aug 26, 2024
7e91353
refactor(main.py): remove unused imports and middleware related to GZ…
ogabrielluiz Aug 27, 2024
da7f585
add center postion in the flow
anovazzi1 Aug 27, 2024
f69ace3
chore: Update NoteNode icon to use SquarePen instead of StickyNote
anovazzi1 Aug 27, 2024
7d4f3d1
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 27, 2024
55648fe
chore: Update API base URL
anovazzi1 Aug 27, 2024
5b2e59f
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 27, 2024
f5f7669
chore: add feature flag for MVPs
anovazzi1 Aug 27, 2024
d8a2ff3
code format
anovazzi1 Aug 27, 2024
3eda53b
✨ (NoteNode/index.tsx): Wrap IconComponent in a div with data-testid …
Cristhianzl Aug 27, 2024
b46f3a1
chore: Update types-markdown to version 3.7.0.20240822
anovazzi1 Aug 27, 2024
a30cd5a
feat: Add lazy loading for images in sticky-notes.spec.ts
anovazzi1 Aug 28, 2024
6a3ca26
Merge remote-tracking branch 'origin/main' into feature/flowNotes
anovazzi1 Aug 28, 2024
4ee39c9
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 28, 2024
fbff7f4
update poetry lock
anovazzi1 Aug 28, 2024
299e953
Merge branch 'feature/flowNotes' of personal:langflow-ai/langflow int…
anovazzi1 Aug 28, 2024
f4d3fc4
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 28, 2024
85f3df1
Merge remote-tracking branch 'origin/main' into feature/flowNotes
anovazzi1 Aug 28, 2024
4c0043d
Merge branch 'main' into feature/flowNotes
ogabrielluiz Aug 29, 2024
56059c4
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 29, 2024
7cc739d
Refactor feature flag import for ENABLE_MVPS across components and tests
ogabrielluiz Aug 29, 2024
100f216
Merge branch 'main' into feature/flowNotes
ogabrielluiz Aug 29, 2024
f25390a
Merge branch 'main' into feature/flowNotes
ogabrielluiz Aug 30, 2024
595da0f
Add skip marker to unimplemented test in test_graph_state_model.py
ogabrielluiz Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,032 changes: 1,058 additions & 974 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/backend/base/langflow/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ async def build_vertices(
build_task = asyncio.create_task(await asyncio.to_thread(_build_vertex, vertex_id, graph))
try:
await build_task
except asyncio.CancelledError:
except asyncio.CancelledError as exc:
logger.exception(exc)
build_task.cancel()
return

Expand Down
4 changes: 3 additions & 1 deletion src/backend/base/langflow/graph/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from langflow.graph.graph.utils import find_start_component_id, process_flow, should_continue, sort_up_to_vertex
from langflow.graph.schema import InterfaceComponentTypes, RunOutputs
from langflow.graph.vertex.base import Vertex, VertexStates
from langflow.graph.vertex.schema import NodeData
from langflow.graph.vertex.schema import NodeData, NodeTypeEnum
from langflow.graph.vertex.types import ComponentVertex, InterfaceVertex, StateVertex
from langflow.logging.logger import LogConfig, configure
from langflow.schema import Data
Expand Down Expand Up @@ -1582,6 +1582,8 @@ def _build_vertices(self) -> list["Vertex"]:
"""Builds the vertices of the graph."""
vertices: list["Vertex"] = []
for frontend_data in self._vertices:
if frontend_data.get("type") == NodeTypeEnum.NoteNode:
continue
try:
vertex_instance = self.get_vertex(frontend_data["id"])
except ValueError:
Expand Down
8 changes: 8 additions & 0 deletions src/backend/base/langflow/graph/vertex/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from enum import Enum

from typing_extensions import NotRequired, TypedDict


class NodeTypeEnum(str, Enum):
NoteNode = "noteNode"
GenericNode = "genericNode"


class Position(TypedDict):
x: float
y: float
Expand All @@ -16,3 +23,4 @@ class NodeData(TypedDict):
positionAbsolute: NotRequired[Position]
selected: NotRequired[bool]
parent_node_id: NotRequired[str]
type: NotRequired[NodeTypeEnum]
4 changes: 1 addition & 3 deletions src/backend/base/langflow/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
)
from langflow.interface.types import get_and_cache_all_types_dict
from langflow.interface.utils import setup_llm_caching
from langflow.logging.logger import configure
from langflow.services.deps import get_cache_service, get_settings_service, get_telemetry_service
from langflow.services.plugins.langfuse_plugin import LangfuseInstance
from langflow.services.utils import initialize_services, teardown_services
from langflow.logging.logger import configure

# Ignore Pydantic deprecation warnings from Langchain
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)
Expand Down Expand Up @@ -133,8 +133,6 @@ def create_app():
allow_headers=["*"],
)
app.add_middleware(JavaScriptMIMETypeMiddleware)
# ! Deactivating this until we find a better solution
# app.add_middleware(RequestCancelledMiddleware)

@app.middleware("http")
async def flatten_query_string_lists(request: Request, call_next):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def test_graph_state_model_serialization():
assert serialized_state_model["chat_input"]["message"]["text"] == "Test Sender Name"


@pytest.mark.skip(reason="Not implemented yet")
def test_graph_state_model_json_schema():
chat_input = ChatInput(_id="chat_input")
chat_input.set(input_value="Test Sender Name")
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"moment": "^2.30.1",
"openseadragon": "^4.1.1",
"p-debounce": "^4.0.0",
"pako": "^2.1.0",
"playwright": "^1.44.1",
"react": "^18.3.1",
"react-ace": "^11.0.1",
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,11 @@ body {
width: 100%;
height: 100%;
}
.react-flow__resize-control.handle {
width: 0.75rem!important;
height: 0.75rem !important;
background-color: white !important;
border-color: var(--border) !important;
z-index: 1000 !important;
border-radius: 20% !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ export default function NodeDescription({
description,
selected,
nodeId,
emptyPlaceholder = "Double Click to Edit Description",
charLimit,
inputClassName,
mdClassName,
style,
}: {
description?: string;
selected: boolean;
nodeId: string;
emptyPlaceholder?: string;
charLimit?: number;
inputClassName?: string;
mdClassName?: string;
style?: React.CSSProperties;
}) {
const [inputDescription, setInputDescription] = useState(false);
const [nodeDescription, setNodeDescription] = useState(description);
Expand All @@ -31,35 +41,20 @@ export default function NodeDescription({
}, [description]);

return (
<div className="generic-node-desc">
<div
className={cn(
"generic-node-desc",
!inputDescription ? "overflow-auto" : "",
)}
>
{inputDescription ? (
<Textarea
className="nowheel min-h-40"
autoFocus
onBlur={() => {
setInputDescription(false);
setNodeDescription(nodeDescription);
setNode(nodeId, (old) => ({
...old,
data: {
...old.data,
node: {
...old.data.node,
description: nodeDescription,
},
},
}));
}}
value={nodeDescription}
onChange={(e) => setNodeDescription(e.target.value)}
onKeyDown={(e) => {
handleKeyDown(e, nodeDescription, "");
if (
e.key === "Enter" &&
e.shiftKey === false &&
e.ctrlKey === false &&
e.altKey === false
) {
<>
<Textarea
maxLength={charLimit}
className={cn("nowheel h-full", inputClassName)}
autoFocus
style={style}
onBlur={() => {
setInputDescription(false);
setNodeDescription(nodeDescription);
setNode(nodeId, (old) => ({
Expand All @@ -72,13 +67,50 @@ export default function NodeDescription({
},
},
}));
}
}}
/>
}}
value={nodeDescription}
onChange={(e) => setNodeDescription(e.target.value)}
onKeyDown={(e) => {
handleKeyDown(e, nodeDescription, "");
if (
e.key === "Enter" &&
e.shiftKey === false &&
e.ctrlKey === false &&
e.altKey === false
) {
setInputDescription(false);
setNodeDescription(nodeDescription);
setNode(nodeId, (old) => ({
...old,
data: {
...old.data,
node: {
...old.data.node,
description: nodeDescription,
},
},
}));
}
}}
/>
{charLimit && (
<div
className={cn(
"text-left text-xs",
(nodeDescription?.length ?? 0) >= charLimit
? "text-error"
: "text-primary",
)}
data-testid="note_char_limit"
>
{nodeDescription?.length ?? 0}/{charLimit}
</div>
)}
</>
) : (
<div
className={cn(
"nodoubleclick generic-node-desc-text cursor-text word-break-break-word",
"nodoubleclick generic-node-desc-text h-full cursor-text word-break-break-word dark:text-note-placeholder",
description === "" || !description ? "font-light italic" : "",
)}
onDoubleClick={(e) => {
Expand All @@ -87,9 +119,14 @@ export default function NodeDescription({
}}
>
{description === "" || !description ? (
"Double Click to Edit Description"
emptyPlaceholder
) : (
<Markdown className="markdown prose flex flex-col text-primary word-break-break-word dark:prose-invert">
<Markdown
className={cn(
"markdown prose flex h-full w-full flex-col text-primary word-break-break-word dark:prose-invert",
mdClassName,
)}
>
{String(description)}
</Markdown>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default function NodeName({
const [nodeName, setNodeName] = useState(display_name);
const takeSnapshot = useFlowsManagerStore((state) => state.takeSnapshot);
const setNode = useFlowStore((state) => state.setNode);

useEffect(() => {
if (!selected) {
setInputName(false);
Expand All @@ -29,7 +28,7 @@ export default function NodeName({
}, [display_name]);

return inputName ? (
<div>
<div className="w-full">
<InputComponent
onBlur={() => {
setInputName(false);
Expand Down Expand Up @@ -58,7 +57,7 @@ export default function NodeName({
/>
</div>
) : (
<div className="group flex items-center gap-1">
<div className="group flex w-full items-center gap-1">
<ShadTooltip content={display_name}>
<div
onDoubleClick={(event) => {
Expand All @@ -68,7 +67,7 @@ export default function NodeName({
event.preventDefault();
}}
data-testid={"title-" + display_name}
className="nodoubleclick generic-node-tooltip-div cursor-text text-primary"
className="nodoubleclick w-full cursor-text truncate text-primary"
>
{display_name}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/CustomNodes/GenericNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ export default function GenericNode({
>
<div
className={
"generic-node-title-arrangement rounded-full" +
(!showNode && " justify-center")
"generic-node-title-arrangement " +
(!showNode ? " justify-center" : "")
}
data-testid="generic-node-title-arrangement"
>
Expand Down
Loading