feat: add AioTextReRank to support async rerank#119
feat: add AioTextReRank to support async rerank#119Trenza1ore wants to merge 1 commit intodashscope:mainfrom
Conversation
Summary of ChangesHello, 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 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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. Footnotes
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an asynchronous text reranking API (AioTextReRank) by adding a new class in dashscope/rerank/text_rerank.py and updating dashscope/__init__.py to expose it. Corresponding asynchronous test cases have been added in samples/test_text_rerank.py. Feedback includes suggestions to improve code maintainability by reusing the Models inner class from TextReRank, extracting common input validation logic into a helper function to avoid duplication, and removing a redundant try...except block in the new asynchronous test.
There was a problem hiding this comment.
Code Review
This pull request introduces an asynchronous text reranking API, AioTextReRank, by adding a new class in dashscope/rerank/text_rerank.py and exposing it through dashscope/__init__.py. It also includes a new asynchronous test case in samples/test_text_rerank.py to demonstrate its usage. The review feedback points out several areas for improvement, including addressing a docstring line length violation, renaming a variable to avoid redefining a built-in name, resolving or explaining a type ignore comment, documenting the instruct parameter in the new API's docstring, and enhancing error handling in the new test case by logging exceptions before re-raising.
Description
dashscopecurrently has no async rerank API andrequests.postis thread-level blocking, meaning there is no way to have any concurrency within one thread. This PR just introduceAioTextReRankas an async copy ofTextReRank, and I'll leave the dashscope members to refactor later, gemini's comments are outside the scope of this PR.Related Issue: Fixes #118
Security Considerations: [Check if API keys or sensitive credentials are exposed in code/logs]
Type of Change
Component(s) Affected
Checklist
Testing
Added to
test_text_rerank.pysample test.Additional Notes
[Optional: any other context]