Skip to content

Commit

Permalink
Adjusts rate limiting strategy for dalle3.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanedwardes committed May 21, 2024
1 parent 5d31a00 commit 95ffcea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Runner.Discord/Responders/DalleResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public async Task ProcessMessage(IMessage message, CancellationToken token)
const string dalle3Trigger = "dalle3 ";
if (message.Content.StartsWith(dalle3Trigger, StringComparison.InvariantCultureIgnoreCase))
{
const int dalle3Limit = 5;
const int dalle3Limit = 2;
if (_featureFlags.DalleHqAttempts.Count >= dalle3Limit)
{
await message.Channel.SendMessageAsync("wait until the next day", options: token.ToRequestOptions());
await message.Channel.SendMessageAsync("wait until the next two hour period", options: token.ToRequestOptions());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Discord/Responders/FeatureFlagResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private DateTime CurrentDalleHqBucket
get
{
var now = DateTime.UtcNow;
return new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, DateTimeKind.Utc);
return new DateTime(now.Year, now.Month, now.Day, (int)Math.Round((double)now.Hour / 2, MidpointRounding.AwayFromZero) * 2, 0, 0, DateTimeKind.Utc);
}
}
public bool ShouldResetDalleHqAttempts() => DalleHqAttempts.Bucket != CurrentDalleHqBucket;
Expand Down

0 comments on commit 95ffcea

Please sign in to comment.