Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a function for centrally handling the engine list, with caching
This commit introduces a few key changes to the `Coder` class in `coder.py`: 1. Removed an unnecessary import and added `functools` to the import list. 2. Added a new method `get_openai_supported_engines` that fetches the list of models supported by the OpenAI API key. This method uses `functools.lru_cache` for caching the result, improving efficiency. 3. Refactored `get_llm_model_name` to use the new `get_openai_supported_engines` method, reducing code duplication and improving readability. These changes should make the `Coder` class more efficient and easier to understand. 🧠💡
- Loading branch information
ab49577
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖AICodeBot Review Comments:
Coder
class, the import statement forfunctools
has been added, which is necessary for the@functools.lru_cache
decorator to work properly.get_openai_supported_engines
has been added to theCoder
class, which fetches the list of models supported by the OpenAI API key. This method usesfunctools.lru_cache
for caching the result, which improves efficiency.get_llm_model_name
has been refactored to use the newget_openai_supported_engines
method, reducing code duplication and improving readability.Overall, these changes should make the
Coder
class more efficient and easier to understand. However, please ensure that the code has been thoroughly tested and that the caching behavior is working as expected.AICodeBot