-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Support tag in knowledge_workflow #4468
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 |
|---|---|---|
|
|
@@ -18,13 +18,13 @@ | |
|
|
||
|
|
||
| class AliyunBaiLianDefaultSTTModelCredential(BaseForm, BaseModelCredential): | ||
| type = forms.Radio(_("Type"), required=True, text_field='label', default_value='qwen', provider='', method='', | ||
| type = forms.SingleSelect(_("API"), required=True, text_field='label', default_value='qwen', provider='', method='', | ||
| value_field='value', option_list=[ | ||
| {'label': _('Audio file recognition - Tongyi Qwen'), | ||
| 'value': 'qwen'}, | ||
| {'label': _('Qwen-Omni'), | ||
| 'value': 'omni'}, | ||
| {'label': _('Audio file recognition - Fun-ASR/Paraformer/SenseVoice'), | ||
| {'label': _('Real-time speech recognition - Fun-ASR/Paraformer'), | ||
| 'value': 'other'} | ||
| ]) | ||
| api_url = forms.TextInputField(_('API URL'), required=True, relation_show_field_dict={'type': ['qwen', 'omni']}) | ||
|
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. The code looks mostly clean, but here are some suggestions:
Here's the corrected version with indentation added: class AliyunBaiLianDefaultSTTModelCredential(BaseForm, BaseModelCredential):
type = forms.SingleSelect(
_("API"),
required=True,
text_field='label',
default_value='qwen',
provider='', method='',
value_field='value',
option_list=[
{'label': _('Audio file recognition - Tongyi Qwen'),
'value': 'qwen'},
{'label': _('Qwen-Omni'),
'value': 'omni'},
{'label': _('Real-time speech recognition - Fun-ASR/Paraformer'),
'value': 'other'}
]
)
api_url = forms.TextInputField(
_('API URL'),
required=True,
relation_show_field_dict={'type': ['qwen', 'omni']}
)
These changes make the code more readable and maintainable while maintaining its functional correctness. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ def speech_to_text(self, audio_file): | |
| "format": "mp3", | ||
| }, | ||
| }, | ||
| {"type": "text", "text": self.params.get('CueWord')}, | ||
| {"type": "text", "text": self.params.get('CueWord') or '这段音频在说什么'}, | ||
| ], | ||
| }, | ||
| ], | ||
|
|
@@ -77,7 +77,7 @@ def speech_to_text(self, audio_file): | |
| # stream 必须设置为 True,否则会报错 | ||
| stream=True, | ||
| stream_options={"include_usage": True}, | ||
| extra_body=self.params | ||
| extra_body = {'enable_thinking': False, **self.params}, | ||
| ) | ||
| result = [] | ||
| for chunk in completion: | ||
|
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. The provided code checks for certain irregularities that need addressing: Irregularity/Issue
These changes should help ensure that the code functions correctly without syntax errors and improves robustness through some basic error handling practices. |
||
|
|
||
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 provided Python code is generally well-structured and follows Django best practices. However, there are a few areas where improvements could be made:
Imports: The
typing.Anyimport can often lead to type-checking errors. It might be better to specify more precise types where possible.Method Names: Method names like
convert_uuid_to_str,link_file, etc., are good for clarity but consider using underscores consistently (snake_case) instead of hyphens (-).Error Handling: Ensure that error handling is robust enough to manage any exceptions that may arise during file operations or database interactions.
Database Operations: For larger datasets, ensure that transactions are used to group multiple SQL queries into one transaction block, which can improve performance and consistency.
Serialization: Consider simplifying the serialization process by using Django's built-in serializers where appropriate, which can reduce boilerplate code.
Functionality: Verify that all functions, particularly those related to data insertion, handle edge cases and invalid inputs gracefully.
Code Comments: Add comments explaining complex logic or sections of the code, especially around multi-line comments or blocks of repeated code.
Here are some specific suggestions:
These changes make the code cleaner, more maintainable, and safer from potential runtime errors when interacting with databases or external services.