Skip to content
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

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

shaohuzhang1
Copy link
Contributor

docs: Create an application and add workflow parameters

@shaohuzhang1 shaohuzhang1 merged commit 2d4deda into main Feb 24, 2025
4 checks passed
)
Copy link
Contributor Author

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

  1. 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")),
  2. 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.
  3. No Newline at End:

    • The final line should indeed not end with a newline character.
  4. 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!

@shaohuzhang1 shaohuzhang1 deleted the pr@main@doc_create_application_workflow branch February 24, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant