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

Implement rate-limiting for OpenAI API calls #11

Merged
merged 5 commits into from
Nov 5, 2024
Merged

Conversation

penguineer
Copy link
Owner

This pull request introduces a rate-limiting mechanism to handle API rate limits more gracefully. The most important changes include adding a RateLimitGate component, modifying the ChatRequestHandler to use this new component, and updating the RateLimitException handling to consider an additional header.

This works towards #8

Rate Limiting Mechanism:

Integration with Chat Request Handler:

Exception Handling:

Configuration Changes:

@penguineer penguineer added the enhancement New feature or request label Nov 5, 2024
@penguineer penguineer self-assigned this Nov 5, 2024

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (1)

src/main/java/com/penguineering/hareairis/rmq/ChatRequestHandler.java:35

  • [nitpick] Catching a generic Exception and throwing a RuntimeException in 'serializeChatError' is not ideal. Consider handling specific exceptions.
return chatEx.map(ChatError::new).map(err -> { try { return objectMapper.writeValueAsString(err); } catch (JsonProcessingException ex) { throw new RuntimeException(ex); } });
@penguineer penguineer merged commit 3b5fb43 into main Nov 5, 2024
1 check passed
@penguineer penguineer deleted the apply-rate-limit branch November 5, 2024 19:14
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.

1 participant