-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat: introduce lfx package #9133
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
Changes from 175 commits
42f2d4a
a407a02
2ed97b9
513901c
79aedd7
2a906bc
0ddc91c
25bc54e
a8c119a
46611b5
9bb7d27
15fa20c
c03841e
206021c
2458279
5ebda30
512a670
6051add
4dc5dc3
4d662ba
5581a58
5c077ff
a2151b6
b438a7f
c477a4d
0e6c208
383bf05
d61f941
ef1e28b
893abec
9da4c67
9061745
56443c2
48deb29
02cdc74
22f8d93
ae65f6b
bd0efd1
9390a50
e82d53b
f66d144
2667987
0873f08
20b7ee6
db7e775
8fd6478
28ae289
ee9dd25
babc8c3
42560e2
f28842a
cc92676
c3bdfdb
20181a3
1135630
0e0bd4c
42a6dbe
9a0982c
6cb4f66
2c12df2
f23564f
0123a19
1cfce62
30f78f4
38dae1b
d5e35ad
2bfd514
724ed40
0d70c2a
ebc5c5d
a1e085e
1ca2e6c
dd25ef5
922dbe6
e9184e2
74190e1
84a82e8
8ae3fda
5456737
a6c5e9c
5321c2a
c6d8d2f
951ed1e
4def785
e2ba23d
64b5ae8
6267254
2c40134
4831b15
fb4ddc8
336d067
07afb20
00c5685
7b5dc35
8dbbf69
c8a78d3
35acbec
d137f07
56332f5
83b401d
a59b2bb
d9a6138
e3212fc
167e901
841b364
5be5049
13e4bb2
9b07d19
d572332
433bb82
ac2f78a
96ef705
6954e96
fa36a26
5d6da9c
9292dde
6ef9dfe
f27b5b0
ac726dd
c7d5277
60a46e7
97a5d61
623d8ae
e483143
5ed9eba
4a63bf8
bde4ae0
9394261
1978f19
992a336
52f46f7
a18dbcd
84cd8a6
ca68e36
8f57f99
17bd16e
745d568
9631e9f
e84c50b
639542a
8d78495
9f5c57c
d6ab2b0
379581e
62f4e35
4bf5d7e
eb7e214
3070b75
b0a625c
a183db9
2e58cf8
09a9e88
2571fef
7e70e6c
60cb32c
6667d7f
2f33b0f
223498e
9d9410f
4d3cf0f
faba650
86d5b60
c898865
69c1bb4
28ec64c
0316386
518f6ec
4247f38
d57e4d3
5c2fece
ef5fdf5
52b2364
ec31c49
6d9db12
7e383af
e4a4d75
46cab82
d8b9078
8bdcc25
ef1bc86
379244d
907034f
6a40de5
b9882c9
58a89fb
df4d79d
d81a8d0
e96832c
04dbb98
85ecbc4
4118921
4e2a0f0
e2151cc
716856c
c4b8c4f
032859b
2a6f471
caa79c0
293df59
4cc06eb
9d7bc8a
38ca8b6
d11a1a8
b007253
a75ed96
9ee2f2b
34ffc82
b83efd0
01783e2
dc2ab23
f841ff7
b4fb627
4834ca6
2b09d9f
884c705
e6f49eb
8a349ab
b892f28
99c3b97
3daf397
d4cf5e4
c6f09d6
bbe4afb
1fb413b
8b3dfaa
7a61708
b6dc2b3
36abc29
a59a0b9
719e6bf
7da946c
6d99dbf
d3d57a4
ae230ac
63faba2
a08f29b
2ac7901
8a9bb67
e381731
42420aa
335309c
98edf47
741fd97
23be702
81144ee
8ff453b
41ea729
81525c5
c7eddfd
a938049
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ maintainers = [ | |
| # Define your main dependencies here | ||
| dependencies = [ | ||
| "langflow-base~=0.5.0", | ||
| "lfx~=0.1.0", | ||
| "beautifulsoup4==4.12.3", | ||
| "google-search-results>=2.4.1,<3.0.0", | ||
| "google-api-python-client==2.154.0", | ||
|
|
@@ -181,9 +182,14 @@ dev = [ | |
| [tool.uv.sources] | ||
| langflow-base = { workspace = true } | ||
| langflow = { workspace = true } | ||
| lfx = { workspace = true } | ||
|
|
||
| [tool.uv.workspace] | ||
| members = ["src/backend/base", "."] | ||
| members = [ | ||
| "src/backend/base", | ||
| ".", | ||
| "src/lfx", | ||
| ] | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["src/backend/langflow"] | ||
|
|
@@ -299,6 +305,7 @@ ignore = [ | |
|
|
||
| # Rules that are TODOs | ||
| "ANN", | ||
| "D10" | ||
|
||
| ] | ||
|
|
||
| # Preview rules that are not yet activated | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,11 @@ | |
| from typing_extensions import override | ||
|
|
||
| from langflow.api.v1.schemas import ChatResponse, PromptResponse | ||
| from langflow.services.deps import get_chat_service, get_socket_service | ||
| from langflow.services.deps import get_chat_service | ||
| from langflow.utils.util import remove_ansi_escape_codes | ||
|
|
||
| if TYPE_CHECKING: | ||
| from langflow.services.socket.service import SocketIOService | ||
| pass | ||
|
||
|
|
||
|
|
||
| # https://github.com/hwchase17/chat-langchain/blob/master/callback.py | ||
|
|
@@ -28,9 +28,7 @@ def ignore_chain(self) -> bool: | |
| def __init__(self, session_id: str): | ||
| self.chat_service = get_chat_service() | ||
| self.client_id = session_id | ||
| self.socketio_service: SocketIOService = get_socket_service() | ||
| self.sid = session_id | ||
| # self.socketio_service = self.chat_service.active_connections[self.client_id] | ||
|
|
||
| @override | ||
| async def on_llm_new_token(self, token: str, **kwargs: Any) -> None: # type: ignore[misc] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,75 @@ | ||
| from typing import Any | ||
|
|
||
| from fastapi import APIRouter, Depends, HTTPException | ||
| from pydantic import BaseModel | ||
|
|
||
| from langflow.graph.graph.schema import GraphDump | ||
| from langflow.services.auth.utils import get_current_active_user | ||
|
|
||
| router = APIRouter(prefix="/starter-projects", tags=["Flows"]) | ||
|
|
||
|
|
||
| # Pydantic models for API schema compatibility | ||
| class ViewPort(BaseModel): | ||
| x: float | ||
| y: float | ||
| zoom: float | ||
|
|
||
|
|
||
| class NodeData(BaseModel): | ||
| # This is a simplified version - the actual NodeData has many more fields | ||
| # but we only need the basic structure for the API schema | ||
| model_config = {"extra": "allow"} # Allow extra fields | ||
|
|
||
|
|
||
| class EdgeData(BaseModel): | ||
| # This is a simplified version - the actual EdgeData has many more fields | ||
| # but we only need the basic structure for the API schema | ||
| model_config = {"extra": "allow"} # Allow extra fields | ||
|
|
||
|
|
||
| class GraphData(BaseModel): | ||
| nodes: list[dict[str, Any]] # Use dict to be flexible with the complex NodeData structure | ||
| edges: list[dict[str, Any]] # Use dict to be flexible with the complex EdgeData structure | ||
| viewport: ViewPort | None = None | ||
|
|
||
|
|
||
| class GraphDumpResponse(BaseModel): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain this? Creating a simplified schema for the starter projects?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Although the endpoint never got used outside of tests, this was needed for it. |
||
| data: GraphData | ||
| is_component: bool | None = None | ||
| name: str | None = None | ||
| description: str | None = None | ||
| endpoint_name: str | None = None | ||
|
|
||
|
|
||
| @router.get("/", dependencies=[Depends(get_current_active_user)], status_code=200) | ||
| async def get_starter_projects() -> list[GraphDump]: | ||
| async def get_starter_projects() -> list[GraphDumpResponse]: | ||
| """Get a list of starter projects.""" | ||
| from langflow.initial_setup.load import get_starter_projects_dump | ||
|
|
||
| try: | ||
| return get_starter_projects_dump() | ||
| # Get the raw data from lfx GraphDump | ||
| raw_data = get_starter_projects_dump() | ||
|
|
||
| # Convert TypedDict GraphDump to Pydantic GraphDumpResponse | ||
| results = [] | ||
| for item in raw_data: | ||
| # Create GraphData | ||
| graph_data = GraphData( | ||
| nodes=item.get("data", {}).get("nodes", []), | ||
| edges=item.get("data", {}).get("edges", []), | ||
| viewport=item.get("data", {}).get("viewport"), | ||
| ) | ||
|
|
||
| # Create GraphDumpResponse | ||
| graph_dump = GraphDumpResponse( | ||
| data=graph_data, | ||
| is_component=item.get("is_component"), | ||
| name=item.get("name"), | ||
| description=item.get("description"), | ||
| endpoint_name=item.get("endpoint_name"), | ||
| ) | ||
| results.append(graph_dump) | ||
|
|
||
| except Exception as exc: | ||
| raise HTTPException(status_code=500, detail=str(exc)) from exc | ||
| return results | ||
Uh oh!
There was an error while loading. Please reload this page.