-
Notifications
You must be signed in to change notification settings - Fork 65
fix: rags of 5 metrics #276
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
Conversation
Summary of ChangesHello @pekopoke, 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 focuses on enhancing the configurability and code structure of the RAG (Retrieval Augmented Generation) metrics evaluation system. It introduces the ability to dynamically provide OpenAI API credentials for embedding models, making the system more adaptable. Additionally, it refactors several prompt-related methods into static methods for better code organization and clarifies JSON formatting within prompts. These changes collectively improve the maintainability and flexibility of the RAG evaluation components. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces several fixes and improvements across five RAG metric evaluation modules. Key changes include correctly handling API credentials for OpenAI embedding models by passing them as parameters instead of using hardcoded values, fixing f-string formatting issues in prompts by escaping curly braces, and marking helper methods as @staticmethod for better code structure. The changes are solid and enhance the code's robustness and maintainability. I have one suggestion in llm_rag_answer_relevancy.py to simplify a conditional block for improved readability.
| # 从配置中获取API密钥和base_url | ||
| if not cls.dynamic_config.key: | ||
| raise ValueError("key cannot be empty in llm config.") | ||
| elif not cls.dynamic_config.api_url: | ||
| raise ValueError("api_url cannot be empty in llm config.") | ||
| else: | ||
| api_key = cls.dynamic_config.key | ||
| base_url = cls.dynamic_config.api_url |
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.
The if/elif/else structure for validating key and api_url is a bit complex. You can simplify this by using two separate if statements to check for each required parameter. This makes the validation logic more direct and easier to read.
# 从配置中获取API密钥和base_url
if not cls.dynamic_config.key:
raise ValueError("key cannot be empty in llm config.")
if not cls.dynamic_config.api_url:
raise ValueError("api_url cannot be empty in llm config.")
api_key = cls.dynamic_config.key
base_url = cls.dynamic_config.api_url
No description provided.