Trouble with Asynchronous API Calls #1566
Replies: 2 comments
-
Hey @peterjacksonwonka! Nice to see you back in the world of async adventures 🌀 Based on your description, it seems like you're trying to make multiple API calls concurrently, but they're executing sequentially. This behavior can occur if the promises representing the API calls are not being handled correctly. In JavaScript, you can use Here's an example of how you might implement this in your code: import { api } from "../../controllers/API/api";
async function processFlow(flowId: string) {
return await api.get(`/api/v1/process/${flowId}`);
}
async function processFlowsParallel(flowIds: string[]) {
const promises = flowIds.map(flowId => processFlow(flowId));
return await Promise.all(promises);
}
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, This solution was suggested in a similar open issue How use async APIs ? in the Langflow repository. Please note that I hope this helps! If you have any other questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Hi! 👋 We are using other channels as our official means of communication with users. We apologize for the delayed response. Thank you for your understanding. Best regards, |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make multiple API calls simultaneously,
but it seems like each call waits for the previous one to finish before starting,
even when I set the async option to false.
It seems like the asynchronous calls are not working properly.
I initiated the calls by creating a flow and then calling the API with the endpoint /api/v1/process/{flowId}.
The API I tested involves a flow.
It loads documents using a loader component, stores them in Chroma db component, and then retrieves them.
I get the same results when testing with a flow that only includes chatopenai component.
How can I properly implement asynchronous behavior for these API calls?
Beta Was this translation helpful? Give feedback.
All reactions