-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
How use async APIs ? #1559
Comments
Hey @songjinu, nice to see you back! Hope all is well on your end. 🚀 To parallelly call the API Here's an example of how you might implement this: import { api } from "../../controllers/API/api";
/**
* Calls the process API for a given flow ID.
* @param {string} flowId - The ID of the flow.
* @returns {Promise<AxiosResponse<any>>} The API response.
*/
async function processFlow(flowId: string) {
return await api.get(`/api/v1/process/${flowId}`);
}
/**
* Parallelly processes multiple flows.
* @param {string[]} flowIds - An array of flow IDs to process.
* @returns {Promise<AxiosResponse<any>[]>} An array of API responses.
*/
async function processFlowsParallel(flowIds: string[]) {
const promises = flowIds.map(flowId => processFlow(flowId));
return await Promise.all(promises);
}
// Example usage
const flowIds = ['flowId1', 'flowId2', 'flowId3']; // Replace these with actual flow IDs
processFlowsParallel(flowIds)
.then(responses => {
console.log('All flows processed:', responses);
})
.catch(error => {
console.error('Error processing flows:', error);
}); In this example, Regarding the current implementation of the As for the async feature development in the Langflow codebase, it is currently "in development." Contributions to this implementation are welcome. You can track the progress of this feature in the documentation. I hope this helps! If you have any other questions, feel free to ask. Sources
|
Describe the bug
I wanna parallelly call this API: /api/v1/process/{flow_id} by 'sync:false'.
But all APIs performed sequentially.
My flow is simple like ConversationChain with ChatOpenAI.
I wanna service to 100 over users.
This feature is neccessary to me.
I tried apply with celery. but this always return 'Pending'
I read this feature is developing : https://docs.langflow.org/guides/async-tasks#introduction
How can I use this feature?
The text was updated successfully, but these errors were encountered: