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

FEAT: Added "Run All Prompts" with Concurrent API Request Queuing Mechanism #749

Merged
merged 12 commits into from
Oct 1, 2024

Conversation

tahierhussain
Copy link
Contributor

@tahierhussain tahierhussain commented Sep 27, 2024

What

  1. Added a "Run All Prompts" button to execute all prompts across all LLM profiles for the currently selected document.
  2. Added a "Run All Prompts" button to execute all prompts across all LLM profiles for all documents.
  3. Refactored the code to support concurrent API requests when running multiple prompts.

Why

To enhance the user experience, we implemented "Run All" buttons, allowing users to execute prompts across multiple LLM profiles and documents. However, when too many concurrent API requests were triggered, the application's performance degraded significantly. This occurred because browsers typically handle only 6-7 concurrent API calls at a time, leaving the remaining requests in a pending state. As a result, this increased memory usage and caused the application to slow down.

How

A queuing mechanism has been introduced to limit the number of concurrent API requests to a maximum of 5. API calls beyond this limit are placed in a queue and are processed as ongoing requests complete. This approach ensures stable performance while efficiently handling multiple API calls.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)

Yes. This PR contains major architectural changes in the Prompt Studio, specifically in how the prompt run APIs are handled.

Database Migrations

NA

Env Config

NA

Relevant Docs

NA

Related Issues or PRs

NA

Dependencies Versions

NA

Notes on Testing

NA

Screenshots

image

Checklist

I have read and understood the Contribution Guidelines.

Copy link
Contributor

@vishnuszipstack vishnuszipstack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some NIT comments. You can do it later. Other things seems good to me.

Copy link
Contributor

@harini-venkataraman harini-venkataraman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tahierhussain One quick question here, will this have impact in the PLG features where we make similar calls. We don't make runs in public share, but I am bit concerned about SPS.

@tahierhussain
Copy link
Contributor Author

@tahierhussain One quick question here, will this have impact in the PLG features where we make similar calls. We don't make runs in public share, but I am bit concerned about SPS.

@harini-venkataraman Yes. We don't make run calls in public share. SPS should work fine with minimal changes in the FE. I will be picking it up after we're done with the architectural changes in the FE.

@nehabagdia nehabagdia merged commit 146130b into main Oct 1, 2024
3 of 4 checks passed
@nehabagdia nehabagdia deleted the feat/run-all-prompts branch October 1, 2024 04:39
Copy link

sonarqubecloud bot commented Oct 1, 2024

Copy link
Contributor

github-actions bot commented Oct 1, 2024

filepath function $$\textcolor{#23d18b}{\tt{passed}}$$ SUBTOTAL
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_logs}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_cleanup}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_cleanup\_skip}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_client\_init}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image\_exists}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_image}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config\_without\_mount}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{worker/src/unstract/worker/clients/test\_docker.py}}$$ $$\textcolor{#23d18b}{\tt{test\_run\_container}}$$ $$\textcolor{#23d18b}{\tt{1}}$$ $$\textcolor{#23d18b}{\tt{1}}$$
$$\textcolor{#23d18b}{\tt{TOTAL}}$$ $$\textcolor{#23d18b}{\tt{9}}$$ $$\textcolor{#23d18b}{\tt{9}}$$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants