fix: update curl code generation (#3191)
* refactor: update getCurlRunCode to use useFlowStore for inputs and outputs Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
15d49d8526
commit
dd3a92b196
1 changed files with 8 additions and 2 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import useFlowStore from "@/stores/flowStore";
|
||||
|
||||
/**
|
||||
* Function to get the curl code for the API
|
||||
* @param {string} flowId - The id of the flow
|
||||
|
|
@ -11,6 +13,10 @@ export function getCurlRunCode(
|
|||
endpointName?: string | null,
|
||||
): string {
|
||||
let tweaksString = "{}";
|
||||
const inputs = useFlowStore.getState().inputs;
|
||||
const outputs = useFlowStore.getState().outputs;
|
||||
const hasChatInput = inputs.some((input) => input.type === "ChatInput");
|
||||
const hasChatOutput = outputs.some((output) => output.type === "ChatOutput");
|
||||
if (tweaksBuildedObject)
|
||||
tweaksString = JSON.stringify(tweaksBuildedObject, null, 2);
|
||||
// show the endpoint name in the curl command if it exists
|
||||
|
|
@ -22,8 +28,8 @@ export function getCurlRunCode(
|
|||
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
|
||||
}
|
||||
-d '{"input_value": "message",
|
||||
"output_type": "chat",
|
||||
"input_type": "chat",
|
||||
"output_type": ${hasChatOutput ? "chat" : "text"},
|
||||
"input_type": ${hasChatInput ? "chat" : "text"},
|
||||
"tweaks": ${tweaksString}}'
|
||||
`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue