🚀 feat(constants.tsx): add tweaks parameter to getPythonCode function to allow for customization of flow behavior

The `getPythonCode` function now accepts a `tweaks` parameter which is used to customize the behavior of the flow. The `buildTweaks` function is called to generate the `tweaks` object which is then passed to the `load_flow_from_json` function. This allows for more flexibility in the usage of the flow.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-19 14:24:48 -03:00
commit 8a5525f465

View file

@ -121,9 +121,10 @@ export const getCurlCode = (flow: FlowType): string => {
*/
export const getPythonCode = (flow: FlowType): string => {
const flowName = flow.name;
const tweaks = buildTweaks(flow);
return `from langflow import load_flow_from_json
flow = load_flow_from_json("${flowName}.json")
TWEAKS = ${JSON.stringify(tweaks, null, 2)}
flow = load_flow_from_json("${flowName}.json", tweaks=TWEAKS)
# Now you can use it like any chain
flow("Hey, have you heard of LangFlow?")`;
};