-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Reference segmentation limit #2487
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -567,7 +567,7 @@ class HitTest(ApiMixin, serializers.Serializer): | |
| id = serializers.CharField(required=True, error_messages=ErrMessage.char("id")) | ||
| user_id = serializers.UUIDField(required=False, error_messages=ErrMessage.char(_('user id'))) | ||
| query_text = serializers.CharField(required=True, error_messages=ErrMessage.char(_('query text'))) | ||
| top_number = serializers.IntegerField(required=True, max_value=100, min_value=1, | ||
| top_number = serializers.IntegerField(required=True, max_value=10000, min_value=1, | ||
| error_messages=ErrMessage.char("top number")) | ||
| similarity = serializers.FloatField(required=True, max_value=2, min_value=0, | ||
| error_messages=ErrMessage.char(_('similarity'))) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an issue in the Irregularity or Potential Issue:The current limit on Optimization Suggestion:Consider raising the upper limit on class HitTest(ApiMixin, serializers.Serializer):
id = serializers.CharField(required=True, error_messages=ErrMessage.char("id"))
user_id = serializers.UUIDField(
required=False,
error_messages=ErrMessage.char(_('user id'))
)
query_text = serializers.CharField(required=True, error_messages=ErrMessage.char(_('query text')))
top_number = serializers.IntegerField(
required=True,
max_value=10000, # Increased from 100 to 10000
min_value=1,
error_messages=ErrMessage.char('top number')
)
similarity = serializers.FloatField(
required=True,
max_value=2,
min_value=0,
error_messages=ErrMessage.char(_('similarity'))
)This change will make the API capable of handling requests with a significantly greater number of top-n results, which may be beneficial in scenarios requiring more detailed data retrieval based on similarity scores. |
||
|
|
||
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 code you provided is generally clean and follows best practices for Python serialization with Django REST Framework (DRF). However, there are some minor improvements and suggestions:
Improvements:
Consistent Use of
max_value: In theDatasetSettingSerializer, bothtop_nandsimilarityhavemax_value=10000. This is consistent, but if this value might change in future versions, it would be good to make it configurable or an environment variable.Error Message Translation: The translations for
"Number"and"relevance"should match across all fields where they appear consistently. Ensure that_is used correctly for translation throughout the codebase.Optimization Suggestions:
Avoid Hardcoding Values: Instead of having hardcoded values like
required=Truein each field configuration, consider using defaults or external settings files if these parameters are subject to change frequently.Use Consistent Field Names: While this isn't necessarily a technical issue, maintaining consistency in field names can improve readability and maintainability.
Summary:
Overall, the code looks mostly correct and functional. By making slight adjustments, such as configuring thresholds more dynamically and ensuring consistency in error message usage, you can enhance the robustness and flexibility of your serializer logic.