fix: update node logic (#2515)
* Fixed bug where updating the node does not remove edited status * Fixed order of edited override * Made all node-changing functions to alter type the right way * Update StoreMessageComponent for enhanced message handling - Changed base class from CustomComponent to Component - Added multiple input fields: message, sender, sender_name, session_id - Included output field for stored messages - Improved logic to handle both string and Message types - Enhanced error handling and validation for message storage * Apply Ruff formatting * Update StoreMessageComponent for enhanced message handling * Apply Ruff formatting * Feat: add more types * Format code * feat: Add CreateListComponent for creating a list of texts This commit adds a new component called CreateListComponent, which is responsible for creating a list of texts. The component takes in one or more texts as input and outputs a list of Data objects. This component is useful for scenarios where a list of texts needs to be processed or manipulated. The CreateListComponent class is added to the helpers module in the langflow.components package. It includes the necessary inputs and outputs, as well as a create_list method that generates the list of Data objects based on the input texts. This commit also includes some minor changes to other files, such as renaming the UUIDGeneratorComponent to IDGeneratorComponent and updating import statements. * [autofix.ci] apply automated fixes * Changed native categories to use the keys of the style utils categories, which is updated * change component name * chore: add the name attribute to the CustomComponent * chore: assign the value of name to the components * chore: change the logic of the type value returned * chore: extract code to new func * chore: change component_name value * [autofix.ci] apply automated fixes * Formatted files --------- Co-authored-by: Rodrigo <rodrigosilvanader@gmail.com> Co-authored-by: rodrigosnader <rodrigosnader@users.noreply.github.com> Co-authored-by: igorrCarvalho <igorsilvabhz6@gmail.com> Co-authored-by: anovazzi1 <otavio2204@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
parent
8017122d29
commit
17b730b6cf
143 changed files with 179 additions and 37 deletions
|
|
@ -180,8 +180,12 @@ export default function ParameterComponent({
|
|||
handleOnNewValueHook(newValue, dbValue, skipSnapshot);
|
||||
};
|
||||
|
||||
const handleNodeClass = (newNodeClass: APIClassType, code?: string): void => {
|
||||
handleNodeClassHook(newNodeClass, code);
|
||||
const handleNodeClass = (
|
||||
newNodeClass: APIClassType,
|
||||
code?: string,
|
||||
type?: string,
|
||||
): void => {
|
||||
handleNodeClassHook(newNodeClass, code, type);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect } from "react";
|
||||
import { NATIVE_CATEGORIES } from "../../constants/constants";
|
||||
import { NodeDataType } from "../../types/flow";
|
||||
import { nodeNames } from "../../utils/styleUtils";
|
||||
|
||||
const useCheckCodeValidity = (
|
||||
data: NodeDataType,
|
||||
|
|
@ -14,7 +14,7 @@ const useCheckCodeValidity = (
|
|||
// first check if data.type in NATIVE_CATEGORIES
|
||||
// if not return
|
||||
if (
|
||||
!NATIVE_CATEGORIES.includes(types[data.type]) ||
|
||||
!Object.keys(nodeNames).includes(types[data.type]) ||
|
||||
!data.node?.template?.code?.value
|
||||
)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ const useHandleNodeClass = (
|
|||
display_name: newNodeClass.display_name ?? data.node!.display_name,
|
||||
};
|
||||
if (type) {
|
||||
newNode.data.node.template[name].type = type;
|
||||
newNode.data.type = type;
|
||||
}
|
||||
newNode.data.node.template[name].value = code;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,9 @@ const useUpdateNodeCode = (
|
|||
|
||||
newNode.data = {
|
||||
...newNode.data,
|
||||
node: newNodeClass,
|
||||
node: { ...newNodeClass, edited: false },
|
||||
description: newNodeClass.description ?? dataNode.description,
|
||||
display_name: newNodeClass.display_name ?? dataNode.display_name,
|
||||
edited: false,
|
||||
};
|
||||
if (type) {
|
||||
newNode.data.type = type;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// src/constants/constants.ts
|
||||
|
||||
import { languageMap } from "../types/components";
|
||||
import { nodeNames } from "../utils/styleUtils";
|
||||
|
||||
/**
|
||||
* invalid characters for flow name
|
||||
|
|
@ -723,27 +724,6 @@ export const PRIORITY_SIDEBAR_ORDER = [
|
|||
"vectorstores",
|
||||
"embeddings",
|
||||
];
|
||||
export const NATIVE_CATEGORIES = [
|
||||
"inputs",
|
||||
"outputs",
|
||||
"prompts",
|
||||
"data",
|
||||
"prompt",
|
||||
"models",
|
||||
"helpers",
|
||||
"experimental",
|
||||
"agents",
|
||||
"vectorstores",
|
||||
"retrievers",
|
||||
"embeddings",
|
||||
"chains",
|
||||
"tools",
|
||||
"memories",
|
||||
"textsplitters",
|
||||
"toolkits",
|
||||
"prototypes",
|
||||
"langchain_utilities",
|
||||
];
|
||||
|
||||
export const AUTHORIZED_DUPLICATE_REQUESTS = [
|
||||
"/health",
|
||||
|
|
|
|||
|
|
@ -390,7 +390,11 @@ export default function NodeToolbarComponent({
|
|||
});
|
||||
};
|
||||
|
||||
const handleNodeClass = (newNodeClass: APIClassType, code?: string): void => {
|
||||
const handleNodeClass = (
|
||||
newNodeClass: APIClassType,
|
||||
code?: string,
|
||||
type?: string,
|
||||
): void => {
|
||||
if (!data.node) return;
|
||||
if (data.node!.template[name].value !== code) {
|
||||
takeSnapshot();
|
||||
|
|
@ -406,6 +410,10 @@ export default function NodeToolbarComponent({
|
|||
display_name: newNodeClass.display_name ?? data.node!.display_name,
|
||||
};
|
||||
|
||||
if (type) {
|
||||
newNode.data.type = type;
|
||||
}
|
||||
|
||||
newNode.data.node.template[name].value = code;
|
||||
|
||||
return newNode;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue