🐛 fix(constants.tsx): add check for empty tweak array to avoid JSON.stringify error
This commit is contained in:
parent
ebee617b52
commit
132b2e367b
2 changed files with 4 additions and 3 deletions
|
|
@ -71,7 +71,7 @@ FLOW_ID = "${flowId}"
|
||||||
# You can tweak the flow by adding a tweaks dictionary
|
# You can tweak the flow by adding a tweaks dictionary
|
||||||
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
|
||||||
TWEAKS = ${
|
TWEAKS = ${
|
||||||
tweak ? JSON.stringify(tweak, null, 2) : JSON.stringify(tweaks, null, 2)
|
tweak && tweak.length > 0 ? JSON.stringify(tweak, null, 2) : JSON.stringify(tweaks, null, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
def run_flow(message: str, flow_id: str, tweaks: dict = None) -> dict:
|
def run_flow(message: str, flow_id: str, tweaks: dict = None) -> dict:
|
||||||
|
|
@ -111,7 +111,7 @@ export const getCurlCode = (flow: FlowType, tweak?): string => {
|
||||||
}/api/v1/process/${flowId} \\
|
}/api/v1/process/${flowId} \\
|
||||||
-H 'Content-Type: application/json' \\
|
-H 'Content-Type: application/json' \\
|
||||||
-d '{"inputs": {"input": message}, "tweaks": ${
|
-d '{"inputs": {"input": message}, "tweaks": ${
|
||||||
tweak ? JSON.stringify(tweak, null, 2) : JSON.stringify(tweaks, null, 2)
|
tweak && tweak.length > 0 ? JSON.stringify(tweak, null, 2) : JSON.stringify(tweaks, null, 2)
|
||||||
}}'`;
|
}}'`;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,7 +124,7 @@ export const getPythonCode = (flow: FlowType, tweak?): string => {
|
||||||
const tweaks = buildTweaks(flow);
|
const tweaks = buildTweaks(flow);
|
||||||
return `from langflow import load_flow_from_json
|
return `from langflow import load_flow_from_json
|
||||||
TWEAKS = ${
|
TWEAKS = ${
|
||||||
tweak ? JSON.stringify(tweak, null, 2) : JSON.stringify(tweaks, null, 2)
|
tweak && tweak.length > 0 ? JSON.stringify(tweak, null, 2) : JSON.stringify(tweaks, null, 2)
|
||||||
}
|
}
|
||||||
flow = load_flow_from_json("${flowName}.json", tweaks=TWEAKS)
|
flow = load_flow_from_json("${flowName}.json", tweaks=TWEAKS)
|
||||||
# Now you can use it like any chain
|
# Now you can use it like any chain
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const pythonApiCode = getPythonApiCode(flow, tweak.current);
|
const pythonApiCode = getPythonApiCode(flow, tweak.current);
|
||||||
const curl_code = getCurlCode(flow, tweak.current);
|
const curl_code = getCurlCode(flow, tweak.current);
|
||||||
const pythonCode = getPythonCode(flow, tweak.current);
|
const pythonCode = getPythonCode(flow, tweak.current);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue