From 820c0c37124ff012a85c42cb2fc88299892222f1 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Thu, 2 May 2024 15:54:16 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(chat.py):=20fix=20type=20annota?= =?UTF-8?q?tion=20for=20'data'=20parameter=20in=20retrieve=5Fvertices=5For?= =?UTF-8?q?der=20function=20to=20allow=20None=20as=20a=20value=20?= =?UTF-8?q?=F0=9F=90=9B=20(constants.py):=20fix=20import=20statement=20for?= =?UTF-8?q?=20JsonSpec=20from=20langchain.tools.json.tool=20to=20langchain?= =?UTF-8?q?=5Fcommunity.tools.json.tool=20=F0=9F=90=9B=20(index.tsx):=20ad?= =?UTF-8?q?d=20data-testid=20attribute=20to=20the=20div=20element=20to=20i?= =?UTF-8?q?mprove=20testability=20=F0=9F=90=9B=20(buildUtils.ts):=20add=20?= =?UTF-8?q?debugger=20statement=20for=20debugging=20purposes=20?= =?UTF-8?q?=F0=9F=90=9B=20(chatInputOutput.spec.ts):=20fix=20click=20event?= =?UTF-8?q?=20target=20from=20"Run"=20to=20"Playground"=20=F0=9F=90=9B=20(?= =?UTF-8?q?fileUploadComponent.spec.ts):=20fix=20click=20event=20target=20?= =?UTF-8?q?from=20"Run"=20to=20"Playground"=20=F0=9F=90=9B=20(textInputOut?= =?UTF-8?q?put.spec.ts):=20fix=20click=20event=20target=20from=20"Run"=20t?= =?UTF-8?q?o=20"Playground"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/base/langflow/api/v1/chat.py | 2 +- .../base/langflow/interface/tools/constants.py | 2 +- .../src/CustomNodes/GenericNode/index.tsx | 6 +++++- src/frontend/src/utils/buildUtils.ts | 15 +++++++++++---- .../tests/end-to-end/chatInputOutput.spec.ts | 6 +++--- .../tests/end-to-end/fileUploadComponent.spec.ts | 2 +- .../tests/end-to-end/textInputOutput.spec.ts | 4 ++-- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/backend/base/langflow/api/v1/chat.py b/src/backend/base/langflow/api/v1/chat.py index 2ec62501a..d44d96e72 100644 --- a/src/backend/base/langflow/api/v1/chat.py +++ b/src/backend/base/langflow/api/v1/chat.py @@ -54,7 +54,7 @@ async def try_running_celery_task(vertex, user_id): @router.post("/build/{flow_id}/vertices", response_model=VerticesOrderResponse) async def retrieve_vertices_order( flow_id: str, - data: Annotated[Optional[FlowDataRequest], Body(embed=True)] = None, + data: Optional[Annotated[Optional[FlowDataRequest], Body(embed=True)]] = None, stop_component_id: Optional[str] = None, start_component_id: Optional[str] = None, chat_service: "ChatService" = Depends(get_chat_service), diff --git a/src/backend/base/langflow/interface/tools/constants.py b/src/backend/base/langflow/interface/tools/constants.py index 7b07922e5..27b42b327 100644 --- a/src/backend/base/langflow/interface/tools/constants.py +++ b/src/backend/base/langflow/interface/tools/constants.py @@ -1,7 +1,7 @@ from langchain import tools from langchain.agents import Tool from langchain.agents.load_tools import _BASE_TOOLS, _EXTRA_LLM_TOOLS, _EXTRA_OPTIONAL_TOOLS, _LLM_TOOLS -from langchain.tools.json.tool import JsonSpec +from langchain_community.tools.json.tool import JsonSpec from langflow.interface.importing.utils import import_class from langflow.interface.tools.custom import PythonFunctionTool diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 29673fdb8..64d3b4bea 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -645,7 +645,11 @@ export default function GenericNode({ variant="secondary" className={"group h-9 px-1.5"} > -
+
{renderIconStatus(buildStatus, validationStatus)}
diff --git a/src/frontend/src/utils/buildUtils.ts b/src/frontend/src/utils/buildUtils.ts index 5d3de6ea9..2f5d557c5 100644 --- a/src/frontend/src/utils/buildUtils.ts +++ b/src/frontend/src/utils/buildUtils.ts @@ -1,11 +1,11 @@ import { AxiosError } from "axios"; +import { Edge, Node } from "reactflow"; import { BuildStatus } from "../constants/enums"; import { getVerticesOrder, postBuildVertex } from "../controllers/API"; import useAlertStore from "../stores/alertStore"; import useFlowStore from "../stores/flowStore"; import { VertexBuildTypeAPI } from "../types/api"; import { VertexLayerElementType } from "../types/zustand/flow"; -import { Edge, Node } from "reactflow"; type BuildVerticesParams = { flowId: string; // Assuming FlowType is the type for your flow @@ -52,8 +52,8 @@ export async function updateVerticesOrder( flowId: string, startNodeId?: string | null, stopNodeId?: string | null, - nodes?:Node[], - edges?:Edge[] + nodes?: Node[], + edges?: Edge[] ): Promise<{ verticesLayers: VertexLayerElementType[][]; verticesIds: string[]; @@ -64,12 +64,19 @@ export async function updateVerticesOrder( const setErrorData = useAlertStore.getState().setErrorData; let orderResponse; try { - orderResponse = await getVerticesOrder(flowId, startNodeId, stopNodeId, nodes, edges); + orderResponse = await getVerticesOrder( + flowId, + startNodeId, + stopNodeId, + nodes, + edges + ); } catch (error: any) { setErrorData({ title: "Oops! Looks like you missed something", list: [error.response?.data?.detail ?? "Unknown Error"], }); + debugger; useFlowStore.getState().setIsBuilding(false); throw new Error("Invalid nodes"); } diff --git a/src/frontend/tests/end-to-end/chatInputOutput.spec.ts b/src/frontend/tests/end-to-end/chatInputOutput.spec.ts index bc507efb7..50548ab21 100644 --- a/src/frontend/tests/end-to-end/chatInputOutput.spec.ts +++ b/src/frontend/tests/end-to-end/chatInputOutput.spec.ts @@ -45,7 +45,7 @@ test("user must interact with chat with Input/Output", async ({ page }) => { await page .getByTestId("input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); - await page.getByText("Run", { exact: true }).click(); + await page.getByText("Playground", { exact: true }).click(); await page.getByPlaceholder("Send a message...").fill("Hello, how are you?"); await page.getByTestId("icon-LucideSend").click(); let valueUser = await page.getByTestId("sender_name_user").textContent(); @@ -65,7 +65,7 @@ test("user must interact with chat with Input/Output", async ({ page }) => { await page.getByTestId("input-sender_name").nth(1).fill("TestSenderNameUser"); await page.getByTestId("input-sender_name").nth(0).fill("TestSenderNameAI"); - await page.getByText("Run", { exact: true }).click(); + await page.getByText("Playground", { exact: true }).click(); await page.getByTestId("icon-LucideSend").click(); valueUser = await page @@ -138,7 +138,7 @@ test("chat_io_teste", async ({ page }) => { } ); await page.getByLabel("fit view").click(); - await page.getByText("Run", { exact: true }).click(); + await page.getByText("Playground", { exact: true }).click(); await page.getByPlaceholder("Send a message...").click(); await page.getByPlaceholder("Send a message...").fill("teste"); await page.getByRole("button").nth(1).click(); diff --git a/src/frontend/tests/end-to-end/fileUploadComponent.spec.ts b/src/frontend/tests/end-to-end/fileUploadComponent.spec.ts index 7141c6a7f..e38ff1bc0 100644 --- a/src/frontend/tests/end-to-end/fileUploadComponent.spec.ts +++ b/src/frontend/tests/end-to-end/fileUploadComponent.spec.ts @@ -79,7 +79,7 @@ test("dropDownComponent", async ({ page }) => { // Release the mouse await page.mouse.up(); - await page.getByText("Run", { exact: true }).click(); + await page.getByText("Playground", { exact: true }).click(); await page.getByText("Run Flow", { exact: true }).click(); await page.waitForTimeout(3000); const textOutput = await page.getByPlaceholder("Empty").first().inputValue(); diff --git a/src/frontend/tests/end-to-end/textInputOutput.spec.ts b/src/frontend/tests/end-to-end/textInputOutput.spec.ts index 5312cb96b..9ac25bd8f 100644 --- a/src/frontend/tests/end-to-end/textInputOutput.spec.ts +++ b/src/frontend/tests/end-to-end/textInputOutput.spec.ts @@ -117,7 +117,7 @@ test("TextInputOutputComponent", async ({ page }) => { await page .getByTestId("input-openai_api_key") .fill(process.env.OPENAI_API_KEY ?? ""); - await page.getByText("Run", { exact: true }).click(); + await page.getByText("Playground", { exact: true }).click(); await page.getByText("Run Flow", { exact: true }).click(); await page.waitForTimeout(5000); @@ -138,7 +138,7 @@ test("TextInputOutputComponent", async ({ page }) => { .getByTestId("input-input_value") .nth(0) .fill("This is a test, again just to be sure!"); - await page.getByText("Run", { exact: true }).click(); + await page.getByText("Playground", { exact: true }).click(); await page.getByText("Run Flow", { exact: true }).click(); await page.waitForTimeout(5000);