Skip to content
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

Langflow Python API delayed response #1287

Closed
sampratha28 opened this issue Jan 4, 2024 · 10 comments
Closed

Langflow Python API delayed response #1287

sampratha28 opened this issue Jan 4, 2024 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@sampratha28
Copy link

I am callling the langflow python API through python requests module.

it is taking too long to respond compared to the time taken for response in the langflow UI.

How do i fix this

Copy link

dosubot bot commented Jan 4, 2024

🤖

Hello @sampratha28! 👋

Just a quick intro: I'm Dosu, a friendly bot here to offer some help while you're waiting for a human maintainer. From bug solving to answering questions, even helping you become a contributor, I'm at your service. 🤖

Don't worry, we'll figure out your issue together. 😉

Based on the information provided, it's difficult to pinpoint the exact cause of the delay you're experiencing when calling the langflow Python API through the Python requests module. However, I can suggest a few general areas to investigate:

  1. Network Latency: The delay might be due to network latency between your client and the server hosting the langflow API. You can use network diagnostic tools to check this.

  2. Server Load: If the server is under heavy load, it might take longer to respond to requests. You can check the server's CPU and memory usage to see if this is the case.

  3. API Implementation: The implementation of the API could also affect response times. For example, if the API is doing a lot of heavy computation or database queries, it might take longer to respond. You can use profiling tools to investigate this.

  4. Client-side Issues: The issue might be on the client side. For example, if your Python script is doing a lot of other work or waiting for other resources, it might take longer to get a response from the API. You can use Python profiling tools to check this.

As per the context provided, the Python API for langflow is structured using FastAPI's APIRouter with a base prefix of "/api/v1" and includes various routers. If the delay is happening on specific routes, you might want to investigate those routes in more detail.

If you're still having trouble, it would be helpful if you could provide more information about the specific API calls you're making, the exact delays you're experiencing, and any other relevant details about your setup. This could help in identifying the cause of the delay.

For more detailed analysis, you might want to consider using a tool like Postman to test your API calls and measure response times. This could help you identify if the delay is consistent across all API calls or specific to certain ones.

I hope this helps! If you have any more questions or need further clarification, feel free to ask.

-Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the question Further information is requested label Jan 4, 2024
@ogabrielluiz
Copy link
Contributor

Hi @sampratha28

When you call the API the build process has to occur while in the UI you have to press the build button before starting the chat. The first message always builds the flow and then that session is cached so you can reuse it.

@YamonBot
Copy link
Contributor

YamonBot commented Jan 4, 2024

I recommend using the API to specify a session ID to prevent the session from expiring. If not specified, calling the API by default initiates a new flow rather than continuing an existing session. This approach causes overhead each time the API is called, as it uses an external database to maintain conversation continuity but triggers a new agent executor process.

@sampratha28
Copy link
Author

sampratha28 commented Jan 5, 2024

@ogabrielluiz @yamonkjd thanks. This was helpful

But for how long will the session be cached? Because after a certain time, i am getting ''Graph not found in the session' error. But it works the next time i hit the API with the same session id.
Is there any timeout happening there?

@YamonBot
Copy link
Contributor

YamonBot commented Jan 9, 2024

@ogabrielluiz @yamonkjd thanks. This was helpful

But for how long will the session be cached? Because after a certain time, i am getting ''Graph not found in the session' error. But it works the next time i hit the API with the same session id. Is there any timeout happening there?

I don't know if I'm judging correctly, but it seems that when there are more than two workers, the session may not be found properly in certain situations.

@ogabrielluiz
Copy link
Contributor

That is correct when not using a cache like Redis. The session data is store in memory and can't be shared between the two processes.

Copy link

dosubot bot commented Apr 9, 2024

Hi, @sampratha28,

I'm helping the langflow team manage their backlog and am marking this issue as stale.

It looks like you're experiencing delayed response times with the Langflow Python API and seeking guidance on how to address this issue. There have been suggestions to investigate network latency, server load, API implementation, and client-side issues. Additionally, recommendations have been made to use a session ID to prevent the session from expiring and to consider using a cache like Redis to store session data. Further investigation is needed to determine if there is a timeout issue and to address potential issues with multiple workers.

Could you please confirm if this issue is still relevant to the latest version of the langflow repository? If it is, please let the langflow team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!

@anovazzi1
Copy link
Contributor

Hello, @YamonBot
Sorry for the delay. Did you try using the new version? Does the error still persist?

@carlosrcoelho
Copy link
Contributor

Hi @sampratha28

We hope you're doing well. Just a friendly reminder that if we do not hear back from you within the next 3 days, we will close this issue. If you need more time or further assistance, please let us know.


Thank you for your understanding!

@carlosrcoelho carlosrcoelho self-assigned this Jul 22, 2024
@carlosrcoelho
Copy link
Contributor

Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants