Skip to content

Commit

Permalink
refactor: parameter component, edit node modal and api modal (#2928)
Browse files Browse the repository at this point in the history
* changed column defs to receive handleOnNewValue and use it to change Advanced variable

* Exported function isTargetHandleConnected

* Refactored types of setNodeClass

* Exported type of handleOnNewValue

* Refactored useHandleNodeClass to only handle changes to node data

* Refactored toggleCellRender to handle advanced values by itself with the handleOnNewValue

* changed setNodeClass types and disabled hook

* changed handleNodeClass on parametercomponent

* changed handleNodeClass on the two components that used it

* refactor: Update handleNodeClass to accept newNodeClass and type only

* Refactor EditNodeModal component to use new handleNodeClass and columnDefs

* Changed columnDefs to receive new handleNodeClass and not receive useless parameters

* changed cellTypeStr to strRender

* Refactored inputFileComponent to use the new handleOnNewValue

* Refactored keypairList to convert values on the fly

* added parameterRenderComponent that renders all parameters in one place

* Exported parameterRenderComponent

* Changed tableNodeCellRender to use ParameterRenderComponent

* changed parameterredercomponent to receive name

* changed strrendercomponent to receive name

* changed nodecellrender to pass name and to check if value is undefined before assigning on templateData

* chore: Refactor use-handle-new-value to handle undefined values in changes

* Used ParameterRenderComponent at parameterComponent

* Refactored parameterRenderComponent to include refresh button

* Created refresh parameter component

* Added nodeId to parameterrendercomponent call

* Removed unused variable

* Refactored refreshButton

* Fixed parameters not showing when they dont have a value

* Created a tweakComplnent that renders the tweak individually, with the same table as the EditNode

* Created tweaks component, that renders all tweaks

* Changed tableNodeCellRender to pass setNode as well

* changed handleOnNewValue to use custom setNode if specified

* added editNodeComponent that handles the table and rowData and columnDefs

* changed editNodeModal to use editNodeComponent instead of table

* changed columndefs type to handle setNode and hideVisibility optional parameters

* changed useRowData to not use myData, and just use nodeClass

* Changed codeTabsPropsType tweaks property to include only the ncessary

* changed codeTabsComponent to use TweaksComponent and handle an internal nodes state

* changed apiModal to handle the tweaks build by finding the differences between old and current node

* fix bug on API modal that refresh tweaks table all the time

* Created new tweaks store type

* Added tweaks store with all of the logic needed to get the tweaks on the API page

* refactored TweakComponent to hold an temporary state to prevent the table from rerendering

* Added TweakComponent into TweaksComponent

* Removed external state on tableAdvancedToggle, making every state come from the Stores

* Removed external state from TableNodeCellRender and added isTweaks to choose which store to use

* Added SetNode type on HandleOnNewValue

* Added custom setNode to handleNodeClass

* Removed unused logic from apiModal

* removed unused old code

* Changed type of getChangesTypes

* Transformed string into object on get codes

* Changed getNodesWithDefaultValue to return nodes that will appear on Tweaks, as well as just the allowed parameters

* added hasTweaks to tabs

* added check of template keys to update the local nodeClass state, allowing the table to be updated just when the number of parameters changes

* passed isTweaks to columnDefs

* removed unused state and passed isTweaks to value getters

* Removed unused state

* updated tabsArrayType with hasTweaks and removed unused types

* Added local nodes tweaks state to the codetabscomponent and refactored conditions of display

* removed unused console.log

* changed advanced toggle to use parameterid given by the value

* changed nodecellrender to use parameter id given by the value

* passed parameter id by value to the renderers

* removed nodeClass from columnDefs definition

* Fixed isTargetHandleConnected returning error if field is undefined

* Fix performance issues on edit node modal

* Fixed scroll overflow issues on tweaksComponent

* Revert "Revert "refactor: update template api, handleonnewvalue and handlenodeclass hooks (#2628)""

This reverts commit 236ae82.

* 📝 (tweaksTest.spec.ts): remove redundant code and improve readability by simplifying the interaction with elements in the test case

* added custom id for tests

* ✨ (frontend): Add unique id prop to input components for better testability and accessibility.

✨ (Hierarchical Tasks Agent.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (Memory Chatbot.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (Sequential Tasks Agent.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-0.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-1.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (chatInputOutputUser-shard-2.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update input list element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update prompt area element IDs to improve clarity and consistency
✨ (decisionFlow.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (freeze-path.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-0.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-1.spec.ts): Update dropdown element IDs to improve clarity and consistency
✨ (generalBugs-shard-3.spec.ts): Update dropdown element IDs to improve clarity and consistency

🔧 (logs.spec.ts, textInputOutput.spec.ts): update dropdown test selectors to match changes in the frontend codebase

* Fixed prompt not holding the value when validating

* Fixed range spec on int component

* Fixed OpenAI Model max tokens range spec

* ✨ (dropdownComponent.spec.ts): Update dropdown test cases to use more descriptive test IDs for better clarity and maintainability
📝 (fileUploadComponent.spec.ts): Add explicit wait for "Run Flow" button to ensure it is loaded before clicking
📝 (folders.spec.ts): Update file path in readFileSync function to use an absolute path for better reliability
📝 (freeze-path.spec.ts): Refactor test code to remove commented out code and improve readability by using more descriptive test IDs and removing unnecessary code snippets

✨ (inputListComponent.spec.ts): Update test file to use consistent naming convention for input elements in the InputListComponent
📝 (intComponent.spec.ts): Refactor test file to use consistent naming convention for input elements in the IntComponent

✨ (nestedComponent.spec.ts): Update test steps and interactions for nestedComponent to improve test coverage and accuracy.

📝 (promptModalComponent.spec.ts): Update test selectors for prompt modal component to improve consistency and readability
📝 (textAreaModalComponent.spec.ts): Update test selectors for text area modal component to improve consistency and readability
📝 (toggleComponent.spec.ts): Update test selectors for toggle component to improve consistency and readability

* 🐛 (intComponent.spec.ts): fix incorrect value comparison in test for IntComponent
🐛 (intComponent.spec.ts): fix missing test step for clicking on a specific element in IntComponent test

* 📝 (Vector Store.spec.ts): increase timeout for waiting for "built successfully" text to improve test reliability and prevent false negatives

* Fixed folders test

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
  • Loading branch information
4 people authored Jul 26, 2024
1 parent 8391086 commit a9863a0
Show file tree
Hide file tree
Showing 80 changed files with 2,035 additions and 2,932 deletions.
2 changes: 2 additions & 0 deletions src/backend/base/langflow/components/models/OpenAIModel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import operator
from functools import reduce

from langflow.field_typing.range_spec import RangeSpec
from langchain_openai import ChatOpenAI
from pydantic.v1 import SecretStr

Expand Down Expand Up @@ -30,6 +31,7 @@ class OpenAIModelComponent(LCModelComponent):
display_name="Max Tokens",
advanced=True,
info="The maximum number of tokens to generate. Set to 0 for unlimited tokens.",
range_spec=RangeSpec(min=0, max=128000),
),
DictInput(name="model_kwargs", display_name="Model Kwargs", advanced=True),
BoolInput(
Expand Down
Loading

0 comments on commit a9863a0

Please sign in to comment.