-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Possible to add a manual delay between each API requests? #6017
Comments
To add a manual delay between API requests in Langflow, you can modify the Langflow uses the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
is this not a future by defailt in LangFlow? |
Langflow does not have built-in support for request delays or rate limiting as a default feature. To implement these functionalities, you would need to modify the code, specifically in the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
then modify this component for me and add a new field for delay in seconds, so it would hold the message for that amount before passing it on through its output:
|
To modify the import time
from langflow.base.io.text import TextComponent
from langflow.io import MultilineInput, Output
from langflow.schema.message import Message
class TextOutputComponent(TextComponent):
display_name = "Text Output"
description = "Display a text output in the Playground."
icon = "type"
name = "TextOutput"
inputs = [
MultilineInput(
name="input_value",
display_name="Text",
info="Text to be passed as output.",
),
]
outputs = [
Output(display_name="Message", name="text", method="text_response"),
]
# New attribute for delay
delay_seconds: float = 0.0
def text_response(self) -> Message:
# Introduce a delay before processing the message
if self.delay_seconds > 0:
time.sleep(self.delay_seconds)
message = Message(
text=self.input_value,
)
self.status = self.input_value
return message In this modification, a To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
@dosu |
To add a new field for inputting the number of seconds for the delay, you need to include a import time
from langflow.base.io.text import TextComponent
from langflow.io import MultilineInput, Output, NumberInput
from langflow.schema.message import Message
class TextOutputComponent(TextComponent):
display_name = "Text Output"
description = "Display a text output in the Playground."
icon = "type"
name = "TextOutput"
inputs = [
MultilineInput(
name="input_value",
display_name="Text",
info="Text to be passed as output.",
),
NumberInput(
name="delay_seconds",
display_name="Delay (seconds)",
info="Number of seconds to delay the output.",
default=0
),
]
outputs = [
Output(display_name="Message", name="text", method="text_response"),
]
def text_response(self) -> Message:
# Retrieve the delay value from the input
delay_seconds = self.delay_seconds
if delay_seconds > 0:
time.sleep(delay_seconds) # Introduce delay
message = Message(
text=self.input_value,
)
self.status = self.input_value
return message In this updated version:
To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Possible to add a manual delay between each API requests?
or between 2 components?
or define a global requests per seconds limit?
The text was updated successfully, but these errors were encountered: