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

View file

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

View file

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

View file

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

View file

@ -1,16 +1,28 @@
const AstraSVG = (props) => ( const AstraSVG = (props) => (
<svg width="96" height="96" viewBox="12 33 72 29" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> <svg
<g clip-path="url(#clip0_702_1449)"> width="96"
{/* <rect width="96" height="96" rx="6" fill="white"/> */} height="96"
<path d="M38.0469 33H12V62.1892H38.0469L44.5902 57.1406V38.0485L38.0469 33ZM17.0478 38.0485H39.5424V57.1459H17.0478V38.0485Z" fill="black"/> viewBox="12 33 72 29"
<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"/> fill="none"
</g> xmlns="http://www.w3.org/2000/svg"
<defs> {...props}
<clipPath id="clip0_702_1449"> >
<rect width="96" height="96" fill="white"/> <g clip-path="url(#clip0_702_1449)">
</clipPath> {/* <rect width="96" height="96" rx="6" fill="white"/> */}
</defs> <path
</svg> 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; export default AstraSVG;

View file

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

View file

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

View file

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

View file

@ -46,9 +46,7 @@
"dynamic": false, "dynamic": false,
"info": "", "info": "",
"title_case": false, "title_case": false,
"input_types": [ "input_types": ["Text"]
"Text"
]
}, },
"name": { "name": {
"type": "str", "type": "str",
@ -66,9 +64,7 @@
"dynamic": false, "dynamic": false,
"info": "", "info": "",
"title_case": false, "title_case": false,
"input_types": [ "input_types": ["Text"]
"Text"
]
}, },
"return_direct": { "return_direct": {
"type": "bool", "type": "bool",
@ -90,10 +86,7 @@
"_type": "PythonFunctionTool" "_type": "PythonFunctionTool"
}, },
"description": "Python function to be executed.", "description": "Python function to be executed.",
"base_classes": [ "base_classes": ["BaseTool", "Tool"],
"BaseTool",
"Tool"
],
"display_name": "PythonFunctionTool", "display_name": "PythonFunctionTool",
"documentation": "", "documentation": "",
"custom_fields": {}, "custom_fields": {},
@ -208,9 +201,7 @@
"dynamic": false, "dynamic": false,
"info": "", "info": "",
"title_case": false, "title_case": false,
"input_types": [ "input_types": ["Text"]
"Text"
]
}, },
"code": { "code": {
"type": "code", "type": "code",
@ -269,10 +260,7 @@
"max_iterations": null, "max_iterations": null,
"memory": null "memory": null
}, },
"output_types": [ "output_types": ["AgentExecutor", "Callable"],
"AgentExecutor",
"Callable"
],
"field_formatters": {}, "field_formatters": {},
"pinned": false, "pinned": false,
"beta": true "beta": true
@ -372,9 +360,7 @@
"dynamic": false, "dynamic": false,
"info": "", "info": "",
"title_case": false, "title_case": false,
"input_types": [ "input_types": ["Text"]
"Text"
]
}, },
"openai_api_base": { "openai_api_base": {
"type": "str", "type": "str",
@ -392,9 +378,7 @@
"dynamic": false, "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.", "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, "title_case": false,
"input_types": [ "input_types": ["Text"]
"Text"
]
}, },
"openai_api_key": { "openai_api_key": {
"type": "str", "type": "str",
@ -412,9 +396,7 @@
"dynamic": false, "dynamic": false,
"info": "", "info": "",
"title_case": false, "title_case": false,
"input_types": [ "input_types": ["Text"]
"Text"
]
}, },
"temperature": { "temperature": {
"type": "float", "type": "float",
@ -462,10 +444,7 @@
"openai_api_key": null, "openai_api_key": null,
"temperature": null "temperature": null
}, },
"output_types": [ "output_types": ["BaseLanguageModel", "BaseLLM"],
"BaseLanguageModel",
"BaseLLM"
],
"field_formatters": {}, "field_formatters": {},
"pinned": false, "pinned": false,
"beta": true "beta": true
@ -528,10 +507,7 @@
"type": "Tool" "type": "Tool"
}, },
"sourceHandle": { "sourceHandle": {
"baseClasses": [ "baseClasses": ["BaseTool", "Tool"],
"BaseTool",
"Tool"
],
"dataType": "PythonFunctionTool", "dataType": "PythonFunctionTool",
"id": "PythonFunctionTool-RfJui" "id": "PythonFunctionTool-RfJui"
} }

View file

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

View file

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