You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To fix the issue where Boolean values are incorrectly formatted for Python in the code export feature, you need to ensure that the Boolean values in the tweaksBuildedObject are correctly converted from JavaScript's true/false to Python's True/False. You can achieve this by modifying the getPythonCode function to replace these values in the JSON string.
Here's the updated code:
/** * Function to get the python code for the API * @param {string} flow - The current flow * @param {any[]} tweak - The tweaks * @returns {string} - The python code */exportdefaultfunctiongetPythonCode(flowName: string,tweaksBuildedObject): string{consttweaksObject=tweaksBuildedObject[0];consttweaksString=JSON.stringify(tweaksObject,null,2).replace(/true/g,"True").replace(/false/g,"False");return`from langflow.load import run_flow_from_jsonTWEAKS = ${tweaksString}result = run_flow_from_json(flow="${flowName}.json", input_value="message", fallback_to_env_vars=True, # False by default tweaks=TWEAKS)`;}
This modification ensures that the Boolean values are correctly formatted for Python when the code is exported. Additionally, the CodeTabsComponent in src/frontend/src/components/codeTabsComponent/index.tsx includes a switch to enable or disable tweaks, which should be considered when exporting the code [1][2][3][4][5].
Error in the Code Export: Boolean values are in the incorrect syntax. 'false' should be changed to 'False', 'true' should be changed to 'True'.
To Reproduce
Steps to reproduce the behavior:
click to export code, and turn on tweaks
Screenshots
![Screenshot 2024-06-10 at 1 42 59 PM](https://private-user-images.githubusercontent.com/15969583/338290226-46fd4e9c-eef4-4b68-8ca1-bc870f2983c4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0NjQyOTYsIm5iZiI6MTcyMTQ2Mzk5NiwicGF0aCI6Ii8xNTk2OTU4My8zMzgyOTAyMjYtNDZmZDRlOWMtZWVmNC00YjY4LThjYTEtYmM4NzBmMjk4M2M0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIwVDA4MjYzNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0ZDQzYjkxNjZlNjQyMTc5OWUwZmRkMTg0ZjdjOGQ2N2I2ZGU4YzAyODBhZTA1ZDYxNTVhZDk3M2U3ODA3N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2lkS1uKHiO_0ZzZrnq9xy3BZlp3AZAx73DrBXX9NiEg)
The text was updated successfully, but these errors were encountered: