-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cURL command in API section is not accurate #3377
Labels
Comments
The cURL command example in the API section should indeed quote the import useFlowStore from "@/stores/flowStore";
/**
* Function to get the curl code for the API
* @param {string} flowId - The id of the flow
* @param {boolean} isAuth - If the API is authenticated
* @returns {string} - The curl code
*/
export function getCurlRunCode(
flowId: string,
isAuth: boolean,
tweaksBuildedObject?: {},
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
return `curl -X POST \\
"${window.location.protocol}//${window.location.host}/api/v1/run/${
endpointName || flowId
}?stream=false" \\
-H 'Content-Type: application/json'\\${
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
}
-d '{"input_value": "message",
"output_type": "${hasChatOutput ? 'chat' : 'text'}",
"input_type": "${hasChatInput ? 'chat' : 'text'}",
"tweaks": ${tweaksString}}'
`;
}
/**
* Generates a cURL command for making a POST request to a webhook endpoint.
*
* @param {Object} options - The options for generating the cURL command.
* @param {string} options.flowId - The ID of the flow.
* @param {boolean} options.isAuth - Indicates whether authentication is required.
* @param {string} options.endpointName - The name of the webhook endpoint.
* @returns {string} The cURL command.
*/
export function getCurlWebhookCode(
flowId,
isAuth,
endpointName?: string | null,
) {
return `curl -X POST \\
"${window.location.protocol}//${window.location.host}/api/v1/webhook/${
endpointName || flowId
}" \\
-H 'Content-Type: application/json'\\${
!isAuth ? `\n -H 'x-api-key: <your api key>'\\` : ""
}
-d '{"any": "data"}'
`;
} This update ensures that the |
Issue was recently fixed by #3337 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug Description
the example's output_type value should be quoted.
Reproduction
setup a flow , and try to call it.
Expected behavior
copy the command and paste it should be OK to run.
Who can help?
No response
Operating System
Docker image v1.0.15
Langflow Version
v1.0.15
Python Version
None
Screenshot
No response
Flow File
No response
The text was updated successfully, but these errors were encountered: