GithubHelp home page GithubHelp logo

Error in the Code Export: Boolean values are in the incorrect syntax. 'false' should be changed to 'False', 'true' should be changed to 'True'. about langflow HOT 2 CLOSED

edwinjosechittilappilly avatar edwinjosechittilappilly commented on June 30, 2024
Error in the Code Export: Boolean values are in the incorrect syntax. 'false' should be changed to 'False', 'true' should be changed to 'True'.

from langflow.

Comments (2)

dosubot avatar dosubot commented on June 30, 2024 3

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
 */
export default function getPythonCode(
  flowName: string,
  tweaksBuildedObject
): string {
  const tweaksObject = tweaksBuildedObject[0];
  const tweaksString = JSON.stringify(tweaksObject, null, 2)
    .replace(/true/g, "True")
    .replace(/false/g, "False");

  return `from langflow.load import run_flow_from_json
TWEAKS = ${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].

To continue talking to Dosu, mention @dosu.

from langflow.

edwinjosechittilappilly avatar edwinjosechittilappilly commented on June 30, 2024

#2130
Bugfix.

from langflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.