Conversation
Summary of ChangesHello @eeshaKondlapudi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of OpenAI API interactions by introducing default "timeout" and "max_retries" configurations for the "AsyncOpenAI" client. This ensures that API calls have sensible default retry mechanisms and time limits, improving stability and error handling without requiring explicit configuration from the user unless custom behavior is desired. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for max_retries and timeout to the OpenAIChatModel. The implementation is a good addition. However, I've found a critical issue in the tests where the new test cases are nested inside another test method, which will prevent them from being discovered and executed by pytest. I've also pointed out a minor formatting issue in the model file.
| @patch("openjudge.models.openai_chat_model.AsyncOpenAI") | ||
| def test_timeout_and_max_retries_passed(self, mock_async_openai): | ||
| """Test that timeout and max_retries are passed to AsyncOpenAI.""" | ||
| OpenAIChatModel( | ||
| model="gpt-4", | ||
| api_key="test-key", | ||
| client_args={ | ||
| "timeout": 30.0, | ||
| "max_retries": 3, | ||
| }, | ||
| ) | ||
|
|
||
| _, kwargs = mock_async_openai.call_args | ||
|
|
||
| assert kwargs["timeout"] == 30.0 | ||
| assert kwargs["max_retries"] == 3 | ||
|
|
||
| @patch("openjudge.models.openai_chat_model.AsyncOpenAI") | ||
| def test_default_timeout_and_max_retries(self, mock_async_openai): | ||
| """Test that default timeout and max_retries are applied.""" | ||
| OpenAIChatModel( | ||
| model="gpt-4", | ||
| api_key="test-key", | ||
| ) | ||
|
|
||
| _, kwargs = mock_async_openai.call_args | ||
|
|
||
| assert kwargs["timeout"] == 60.0 | ||
| assert kwargs["max_retries"] == 2 | ||
|
|
There was a problem hiding this comment.
These new test methods are defined inside test_qwen_omni_audio_formatting. Because they are nested, pytest will not discover or run them.
To fix this, please move test_timeout_and_max_retries_passed and test_default_timeout_and_max_retries to be methods of the TestOpenAIChatModel class, at the same indentation level as test_qwen_omni_audio_formatting.
| # Add timeout and max_retries defaults if not explicitly provided | ||
| client_args.setdefault("timeout", 60.0) | ||
| client_args.setdefault("max_retries", 2) | ||
|
|
There was a problem hiding this comment.
There are a couple of minor formatting issues here:
- The comment on line 86 has an extra space at the beginning, causing it to be misaligned with the code block it describes.
- The blank line on line 89 is unnecessary and can be removed for better readability.
| # Add timeout and max_retries defaults if not explicitly provided | |
| client_args.setdefault("timeout", 60.0) | |
| client_args.setdefault("max_retries", 2) | |
| # Add timeout and max_retries defaults if not explicitly provided | |
| client_args.setdefault("timeout", 60.0) | |
| client_args.setdefault("max_retries", 2) |
OpenJudge Version
[The version of OpenJudge you are working on, e.g.
import openjudge; print(openjudge.__version__)]Description
[Please describe the background, purpose, changes made, and how to test this PR]
Checklist
Please check the following items before code is ready to be reviewed.
pre-commit run --all-filescommand