-
Notifications
You must be signed in to change notification settings - Fork 2k
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
docs: Create an application and add workflow parameters #2374
Conversation
) |
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 code looks mostly correct, but there are minor improvements and corrections that could be made:
Corrections/Improvements
-
Default Values:
- In the definition of
get_request_body_api
, both'stt_model_enable'
fields have identical titles ("Is text-to-speech enabled"). This can be corrected to ensure clarity.
'stt_model_enable': openapi.Schema(type=openapi.TYPE_STRING, title=_("Is stt enabled for training"), description=_("Is stt enabled during training")), 'stt_model_enable': openapi.Schema(type=openapi.TYPE_STRING, title=_("Whether to enable speech-to-text processing"), description=_("Enable speech-to-text functionality")),
- In the definition of
-
Missing Default Value for
dataset_setting
:- Ensure that
default={}
is consistent with other object definitions where an empty dictionary might make more sense for initialization purposes.
- Ensure that
-
No Newline at End:
- The final line should indeed not end with a newline character.
-
Consistent Property Order:
- While optional, it's generally recommended to keep property declarations in a logical order (e.g., always first default properties).
{ 'name': ..., 'description': ..., # Other common properties 'dataset_setting': ..., },
Suggested Optimal Code
Here’s an optimized version of your function with these changes:
import openapi_schema_v3 as openapi
from django.utils.translation import gettext_lazy as _
class ApplicationApi:
class WorkFlow:
@staticmethod
def get_request_body_api():
return openapi.Schema(
# Define your workflow schema here if needed
title=_('Workflow'),
description=_("Configuration settings relating to workflows."),
type=openapi.TYPE_OBJECT,
required=['steps'],
properties={
'steps': openapi.Schema(
type=openapi.TYPE_ARRAY,
items=openapi.Schema(type=openapi.TYPE_OBJECT),
title=_('Steps in Workflow'), description=_("Steps involved in the application workflow.")
),
}
)
def get_request_body_api():
return openapi.Schema(
type=openapi.TYPE_OBJECT,
required=['name', 'desc', 'model_id', 'dialogue_number', 'dataset_setting', 'model_setting',
'problem_optimization', 'stt_model_enable', 'speech_to_text_enabled', 'tts_type'],
properties={
'name': openapi.Schema(type=openapi.TYPE_STRING, title=_("Application Name"),
description=_("Application Name")),
'desc': openapi.Schema(type=openapi.TYPE_STRING, title=_("Description"),
description=_("Detailed Description")),
'model_id': openapi.Schema(type=openapi.TYPE_INTEGER, title=_("Model ID"),
description=_("Identifies corresponding model")),
'dialogue_number': openapi.Schema(type=openapi.TYPE_INTEGER, title=_("Dialogue Number"),
description=_("Total number of dialogues")),
'dataset_setting': openapi.Schema(type=openapi.TYPE_STRING, title=_("Data Set Setting"),
description=_("Settings for data set used")),
'model_setting': openapi.Schema(type=openapi.TYPE_STRING, title=_("Model Settings"), description="Model configuration details",
default='{}'),
'problem_optimization': openapi.Schema(type=openapi.TYPE_STRING, title=_("Problem Optimization"),
description=_("Optimization strategies applied"),
default='{}'),
'stt_model_enable': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("Enable STT During Training"),
description=_("Stutter recognition feature during model training")},
'stutter_recognition_enabled': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_("Enable Speech-To-Text Processing"),
description=_("Speech-to-text functionality"}},
'tts_type': openapi.Schema(type=openapi.TYPE_STRING, title=_("Type of Text-to-Speech"),
description=_("Selects the method for converting text to speech")),
'work_flow': ApplicationApi.WorkFlow.get_request_body_api(),
}
)
These adjustments improve consistency and readability while maintaining functional integrity. If you need further optimizations or additional features, please let me know!
docs: Create an application and add workflow parameters