Refactor code and fix formatting issues

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-27 23:46:11 -03:00
commit 6737c845eb
11 changed files with 101 additions and 165 deletions

View file

@ -1,4 +1,4 @@
from datetime import datetime,timezone
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Optional
from uuid import UUID, uuid4
@ -26,16 +26,10 @@ class Variable(VariableBase, table=True):
description="Unique ID for the variable",
)
# name is unique per user
created_at: datetime = Field(
default_factory=utc_now, description="Creation time of the variable"
)
updated_at: Optional[datetime] = Field(
None, description="Last update time of the variable"
)
created_at: datetime = Field(default_factory=utc_now, description="Creation time of the variable")
updated_at: Optional[datetime] = Field(None, description="Last update time of the variable")
# foreign key to user table
user_id: UUID = Field(
description="User ID associated with this variable", foreign_key="user.id"
)
user_id: UUID = Field(description="User ID associated with this variable", foreign_key="user.id")
user: "User" = Relationship(back_populates="variables")

View file

@ -246,10 +246,7 @@ export default function CodeTabsComponent({
)
.map((templateField, indx) => {
return (
<TableRow
key={indx}
className="h-10"
>
<TableRow key={indx} className="h-10">
<TableCell className="p-0 text-center text-sm text-foreground">
{templateField}
</TableCell>

View file

@ -127,7 +127,8 @@ export default function InputComponent({
if (password) {
// check if all chars are •
if (
e.target.value.split("").every((char) => char === "•") && e.target.value !== ""
e.target.value.split("").every((char) => char === "•") &&
e.target.value !== ""
) {
setErrorData({
title: `Invalid characters: ${e.target.value}`,

View file

@ -4,12 +4,12 @@ import DeleteConfirmationModal from "../../modals/DeleteConfirmationModal";
import useAlertStore from "../../stores/alertStore";
import { useGlobalVariablesStore } from "../../stores/globalVariables";
import { ResponseErrorDetailAPI } from "../../types/api";
import { InputGlobalComponentType } from "../../types/components";
import { cn } from "../../utils/utils";
import AddNewVariableButton from "../addNewVariableButtonComponent/addNewVariableButton";
import ForwardedIconComponent from "../genericIconComponent";
import InputComponent from "../inputComponent";
import { CommandItem } from "../ui/command";
import { InputGlobalComponentType } from "../../types/components";
export default function InputGlobalComponent({
disabled,

View file

@ -1,16 +1,28 @@
const AstraSVG = (props) => (
<svg width="96" height="96" viewBox="12 33 72 29" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
<g clip-path="url(#clip0_702_1449)">
{/* <rect width="96" height="96" rx="6" fill="white"/> */}
<path d="M38.0469 33H12V62.1892H38.0469L44.5902 57.1406V38.0485L38.0469 33ZM17.0478 38.0485H39.5424V57.1459H17.0478V38.0485Z" fill="black"/>
<path d="M82.0705 38.2605V33.3243H58.2546L51.788 38.2605V45.038L58.2546 49.9742H79.0107V56.9286H53.076V61.8648H77.5334L84 56.9286V49.9742L77.5334 45.038H56.7772V38.2605H82.0705Z" fill="black"/>
</g>
<defs>
<clipPath id="clip0_702_1449">
<rect width="96" height="96" fill="white"/>
</clipPath>
</defs>
</svg>
<svg
width="96"
height="96"
viewBox="12 33 72 29"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<g clip-path="url(#clip0_702_1449)">
{/* <rect width="96" height="96" rx="6" fill="white"/> */}
<path
d="M38.0469 33H12V62.1892H38.0469L44.5902 57.1406V38.0485L38.0469 33ZM17.0478 38.0485H39.5424V57.1459H17.0478V38.0485Z"
fill="black"
/>
<path
d="M82.0705 38.2605V33.3243H58.2546L51.788 38.2605V45.038L58.2546 49.9742H79.0107V56.9286H53.076V61.8648H77.5334L84 56.9286V49.9742L77.5334 45.038H56.7772V38.2605H82.0705Z"
fill="black"
/>
</g>
<defs>
<clipPath id="clip0_702_1449">
<rect width="96" height="96" fill="white" />
</clipPath>
</defs>
</svg>
);
export default AstraSVG;

View file

@ -617,12 +617,14 @@ export default function NodeToolbarComponent({
open={showModalAdvanced}
setOpen={setShowModalAdvanced}
/>
{showconfirmShare&&<ShareModal
open={showconfirmShare}
setOpen={setShowconfirmShare}
is_component={true}
component={flowComponent!}
/>}
{showconfirmShare && (
<ShareModal
open={showconfirmShare}
setOpen={setShowconfirmShare}
is_component={true}
component={flowComponent!}
/>
)}
{hasCode && (
<div className="hidden">
<CodeAreaComponent

View file

@ -69,15 +69,14 @@ export type InputListComponentType = {
editNode?: boolean;
};
export type InputGlobalComponentType =
{
disabled: boolean,
onChange: (value: string) => void,
setDb: (value: boolean) => void,
name: string,
data: NodeDataType,
editNode?: boolean,
};
export type InputGlobalComponentType = {
disabled: boolean;
onChange: (value: string) => void;
setDb: (value: boolean) => void;
name: string;
data: NodeDataType;
editNode?: boolean;
};
export type KeyPairListComponentType = {
value: any;

View file

@ -305,10 +305,7 @@
"_type": "initialize_agent"
},
"description": "Construct a zero shot agent from an LLM and tools.",
"base_classes": [
"AgentExecutor",
"function"
],
"base_classes": ["AgentExecutor", "function"],
"display_name": "AgentInitializer"
},
"id": "AgentInitializer-QiQ4x",
@ -372,9 +369,7 @@
"_type": "PythonFunctionTool"
},
"description": "Python function to be executed.",
"base_classes": [
"Tool"
],
"base_classes": ["Tool"],
"display_name": "PythonFunctionTool"
},
"id": "PythonFunctionTool-kX99N",
@ -434,9 +429,7 @@
"selected": false,
"data": {
"sourceHandle": {
"baseClasses": [
"Tool"
],
"baseClasses": ["Tool"],
"dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-kX99N"
},
@ -822,10 +815,7 @@
"_type": "initialize_agent"
},
"description": "Construct a zero shot agent from an LLM and tools.",
"base_classes": [
"AgentExecutor",
"function"
],
"base_classes": ["AgentExecutor", "function"],
"display_name": "AgentInitializer"
},
"id": "AgentInitializer-YJgqs",
@ -889,9 +879,7 @@
"_type": "PythonFunctionTool"
},
"description": "Python function to be executed.",
"base_classes": [
"Tool"
],
"base_classes": ["Tool"],
"display_name": "PythonFunctionTool"
},
"id": "PythonFunctionTool-gqQDg",
@ -951,9 +939,7 @@
"selected": false,
"data": {
"sourceHandle": {
"baseClasses": [
"Tool"
],
"baseClasses": ["Tool"],
"dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-gqQDg"
},
@ -1339,10 +1325,7 @@
"_type": "initialize_agent"
},
"description": "Construct a zero shot agent from an LLM and tools.",
"base_classes": [
"AgentExecutor",
"function"
],
"base_classes": ["AgentExecutor", "function"],
"display_name": "AgentInitializer"
},
"id": "AgentInitializer-grV0u",
@ -1406,9 +1389,7 @@
"_type": "PythonFunctionTool"
},
"description": "Python function to be executed.",
"base_classes": [
"Tool"
],
"base_classes": ["Tool"],
"display_name": "PythonFunctionTool"
},
"id": "PythonFunctionTool-SctM2",
@ -1468,9 +1449,7 @@
"selected": false,
"data": {
"sourceHandle": {
"baseClasses": [
"Tool"
],
"baseClasses": ["Tool"],
"dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-SctM2"
},
@ -2210,10 +2189,7 @@
"_type": "initialize_agent"
},
"description": "Construct a zero shot agent from an LLM and tools.",
"base_classes": [
"AgentExecutor",
"function"
],
"base_classes": ["AgentExecutor", "function"],
"display_name": "AgentInitializer"
},
"id": "AgentInitializer-EE8R4",
@ -2277,9 +2253,7 @@
"_type": "PythonFunctionTool"
},
"description": "Python function to be executed.",
"base_classes": [
"Tool"
],
"base_classes": ["Tool"],
"display_name": "PythonFunctionTool"
},
"id": "PythonFunctionTool-YKkDL",
@ -2339,9 +2313,7 @@
"selected": false,
"data": {
"sourceHandle": {
"baseClasses": [
"Tool"
],
"baseClasses": ["Tool"],
"dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-YKkDL"
},
@ -2727,10 +2699,7 @@
"_type": "initialize_agent"
},
"description": "Construct a zero shot agent from an LLM and tools.",
"base_classes": [
"AgentExecutor",
"function"
],
"base_classes": ["AgentExecutor", "function"],
"display_name": "AgentInitializer"
},
"id": "AgentInitializer-goPm2",
@ -2794,9 +2763,7 @@
"_type": "PythonFunctionTool"
},
"description": "Python function to be executed.",
"base_classes": [
"Tool"
],
"base_classes": ["Tool"],
"display_name": "PythonFunctionTool"
},
"id": "PythonFunctionTool-SQikY",
@ -2856,9 +2823,7 @@
"selected": false,
"data": {
"sourceHandle": {
"baseClasses": [
"Tool"
],
"baseClasses": ["Tool"],
"dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-SQikY"
},
@ -2881,4 +2846,4 @@
"user_id": "6f6ebc2c-9e7a-4c35-84fc-51760db10d9b"
}
]
}
}

View file

@ -46,9 +46,7 @@
"dynamic": false,
"info": "",
"title_case": false,
"input_types": [
"Text"
]
"input_types": ["Text"]
},
"name": {
"type": "str",
@ -66,9 +64,7 @@
"dynamic": false,
"info": "",
"title_case": false,
"input_types": [
"Text"
]
"input_types": ["Text"]
},
"return_direct": {
"type": "bool",
@ -90,10 +86,7 @@
"_type": "PythonFunctionTool"
},
"description": "Python function to be executed.",
"base_classes": [
"BaseTool",
"Tool"
],
"base_classes": ["BaseTool", "Tool"],
"display_name": "PythonFunctionTool",
"documentation": "",
"custom_fields": {},
@ -208,9 +201,7 @@
"dynamic": false,
"info": "",
"title_case": false,
"input_types": [
"Text"
]
"input_types": ["Text"]
},
"code": {
"type": "code",
@ -269,10 +260,7 @@
"max_iterations": null,
"memory": null
},
"output_types": [
"AgentExecutor",
"Callable"
],
"output_types": ["AgentExecutor", "Callable"],
"field_formatters": {},
"pinned": false,
"beta": true
@ -372,9 +360,7 @@
"dynamic": false,
"info": "",
"title_case": false,
"input_types": [
"Text"
]
"input_types": ["Text"]
},
"openai_api_base": {
"type": "str",
@ -392,9 +378,7 @@
"dynamic": false,
"info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1.\n\nYou can change this to use other APIs like JinaChat, LocalAI and Prem.",
"title_case": false,
"input_types": [
"Text"
]
"input_types": ["Text"]
},
"openai_api_key": {
"type": "str",
@ -412,9 +396,7 @@
"dynamic": false,
"info": "",
"title_case": false,
"input_types": [
"Text"
]
"input_types": ["Text"]
},
"temperature": {
"type": "float",
@ -462,10 +444,7 @@
"openai_api_key": null,
"temperature": null
},
"output_types": [
"BaseLanguageModel",
"BaseLLM"
],
"output_types": ["BaseLanguageModel", "BaseLLM"],
"field_formatters": {},
"pinned": false,
"beta": true
@ -528,10 +507,7 @@
"type": "Tool"
},
"sourceHandle": {
"baseClasses": [
"BaseTool",
"Tool"
],
"baseClasses": ["BaseTool", "Tool"],
"dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-RfJui"
}
@ -553,4 +529,4 @@
"name": "Untitled document (20)",
"last_tested_version": "0.7.0a0",
"is_component": false
}
}

View file

@ -62,27 +62,21 @@
"name": "text_input",
"display_name": "Text Input",
"advanced": false,
"input_types": [
"str"
],
"input_types": ["str"],
"dynamic": false,
"info": "",
"value": ""
},
"_type": "CustomComponent"
},
"base_classes": [
"str"
],
"base_classes": ["str"],
"display_name": "text checkpoint",
"documentation": "http://docs.langflow.org/components/custom",
"custom_fields": {
"save_path": null,
"text_input": null
},
"output_types": [
"str"
],
"output_types": ["str"],
"field_formatters": {},
"beta": true
},
@ -161,18 +155,14 @@
"_type": "CustomComponent"
},
"description": "Converts audio to text using OpenAI's Whisper.",
"base_classes": [
"str"
],
"base_classes": ["str"],
"display_name": "Whisper Transcriber",
"documentation": "",
"custom_fields": {
"OpenAIKey": null,
"audio": null
},
"output_types": [
"str"
],
"output_types": ["str"],
"field_formatters": {},
"beta": true
},
@ -196,15 +186,11 @@
"targetHandle": {
"fieldName": "text_input",
"id": "CustomComponent-MtJjl",
"inputTypes": [
"str"
],
"inputTypes": ["str"],
"type": "str"
},
"sourceHandle": {
"baseClasses": [
"str"
],
"baseClasses": ["str"],
"dataType": "CustomComponent",
"id": "CustomComponent-7NQoq"
}
@ -228,4 +214,4 @@
"folder": null,
"id": "1b0814b7-2964-4e09-9b4b-f7413c4fb50b",
"user_id": "8b5cf798-f1b8-4108-88fd-d7274d08d471"
}
}

View file

@ -6,20 +6,24 @@ test.describe("group node test", () => {
await page.goto("/");
await page.locator('//*[@id="new-project-btn"]').click();
await page.getByRole('heading', { name: 'Data Ingestion' }).click();
await page.getByRole("heading", { name: "Data Ingestion" }).click();
await page.waitForTimeout(2000);
await page.getByLabel('fit view').click();
await page.keyboard.down('Control');
await page.getByTestId("title-OpenAIEmbeddings").click({modifiers: ['Control']});
await page.getByTestId("title-URL").click({modifiers: ['Control']});
await page.getByTestId("title-Recursive Character Text Splitter").click({modifiers: ['Control']});
await page.keyboard.up('Control');
await page.getByRole('button', { name: 'Group' }).click();
await page.getByLabel("fit view").click();
await page.keyboard.down("Control");
await page
.getByTestId("title-OpenAIEmbeddings")
.click({ modifiers: ["Control"] });
await page.getByTestId("title-URL").click({ modifiers: ["Control"] });
await page
.getByTestId("title-Recursive Character Text Splitter")
.click({ modifiers: ["Control"] });
await page.keyboard.up("Control");
await page.getByRole("button", { name: "Group" }).click();
await page.getByTestId(/input-collection_name_Chroma-.*/).click();
await page.getByTestId(/input-collection_name_Chroma-.*/).fill('test');
await page.getByTestId(/input-collection_name_Chroma-.*/).fill("test");
await page.getByTestId("title-Group").click();
await page.keyboard.press("Control+g")
const value = await page.getByTestId('input-collection_name').inputValue()
expect(value).toBe('test');
})
await page.keyboard.press("Control+g");
const value = await page.getByTestId("input-collection_name").inputValue();
expect(value).toBe("test");
});
});