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

.Net: chore: avoid awaiting delay if its zero #9770

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,10 @@ private async Task<FunctionResult> ExecuteStepAsync(FlowStep step, string sessio
string? actionResult;
try
{
await Task.Delay(this._config.MinIterationTimeMs).ConfigureAwait(false);
if (this._config.MinIterationTimeMs > 0)
{
await Task.Delay(this._config.MinIterationTimeMs).ConfigureAwait(false);
}
actionResult = await this._reActEngine.InvokeActionAsync(actionStep, input, chatHistory, kernel, actionContextVariables).ConfigureAwait(false);

if (string.IsNullOrEmpty(actionResult))
Expand Down Expand Up @@ -776,8 +779,11 @@ private async Task<FunctionResult> ExecuteStepAsync(FlowStep step, string sessio
this._logger?.LogWarning("Action: No action to take");
}

// continue to next iteration
await Task.Delay(this._config.MinIterationTimeMs).ConfigureAwait(false);
if (this._config.MinIterationTimeMs > 0)
{
// continue to next iteration
await Task.Delay(this._config.MinIterationTimeMs).ConfigureAwait(false);
}
}

throw new KernelException($"Failed to complete step {stepId} for session {sessionId}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private async Task<FunctionCallingStepwisePlannerResult> ExecuteCoreAsync(
for (int i = 0; i < this._options.MaxIterations; i++)
{
// sleep for a bit to avoid rate limiting
if (i > 0)
if (i > 0 && this._options.MinIterationTimeMs > 0)
{
await Task.Delay(this._options.MinIterationTimeMs, cancellationToken).ConfigureAwait(false);
}
Expand Down
Loading