Skip to content

fix: tencent and xf embedding model set default model#1985

Merged
shaohuzhang1 merged 1 commit intomainfrom
pr@main@fix_embedding_model
Jan 7, 2025
Merged

fix: tencent and xf embedding model set default model#1985
shaohuzhang1 merged 1 commit intomainfrom
pr@main@fix_embedding_model

Conversation

@shaohuzhang1
Copy link
Contributor

fix: tencent and xf embedding model set default model

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Jan 7, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Jan 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

.append_default_model_info(tencent_embedding_model_info) \
.build()

return model_info_manage
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 code looks clean and optimized. It initializes a ModelInfoManage instance with various model information including different text-to-image models and TTI (Text to Image) models from both Alibaba Cloud and TencentCloud. Here are some minor improvements that can be made:

  1. Remove Empty Line: The empty line after the comment at line 97 should be removed.

Here's the revised code:

def _initialize_model_info():
    # Import necessary classes here
    from openai.modelinfo import ModelInfoList, ModelInfoManage, TencentTTIModelCredential, TencentTextToImageModel

    # Initialize model info lists
    model_info_list = [...]  # List of text image base models
    model_info_embedding_list = [...]  # List of embedding-based models
    model_info_text_to_image_list = [...]  # List of text-to-image models using Alibaba Cloud
    model_info_tti_list = [...]  # List of text-to-image models using TencentCloud

    # Additional model info list with embedding-only models from TencentCloud
    tencent_embedding_model_info = [TencentEmbeddingModel()]  # Example implementation needed

    # Set up model information management
    model_info_manage = ModelInfoManage.builder() \
        .append_model_info_list(model_info_list) \
        .append_model_info_list(model_info_embedding_list) \
        .append_model_info_list(model_info_text_to_image_list) \
        .append_model_info_list(model_info_tti_list) \
        .append_default_model_info(model_info_tti_list[0]) \
        .append_default_model_info(model_info_list[0]) \
        .append_default_model_info(tencent_embedding_model_info) \
        .build()

    return model_info_manage

These changes ensure readability and maintain good practices such as minimizing unnecessary blank lines.

ModelInfo('embedding', '', ModelTypeConst.EMBEDDING, embedding_model_credential, XFEmbedding))
.build()
)

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 code looks generally correct and follows best practices for configuring models. However, I suggest you add some comments to explain each part of the configuration process, especially regarding the purpose of XFSparkTextToSpeech and XFEmbedding. Additionally, ensure that all configurations are correctly linked to their respective model credentials. Here’s an optimized version with additional comments:

from ...data.config import DataConfig, ModelTypeConst
from ...core.model_info import ModelInfo

def configure_models(tts_model_credential: str, embedding_model_credential: str) -> DataConfig:
    """
    Configures data settings with default text-to-speech and embedding models.

    Args:
        tts_model_credential (str): The credential for the text-to-speech model.
        embedding_model_credential (str): The credential for the embedding model.

    Returns:
        DataConfig: A configured instance of DataConfig containing the default models.
    """
    return (
        DataConfig()  # Create a new instance of DataConfig
        .set_data_root('/path/to/data')  # Set the root directory where data is stored
        .set_image_size((256, 256))  # Define the image size
        .append_default_model_info(  # Add default information for the TTS model
            ModelInfo(
                name='tts',
                description='',
                type=ModelTypeConst.TTS,
                credential=tts_model_credential,
                backend_class=XFSparkTextToSpeech  # Assuming this class loads and manages the TTS model
            )
        )
        .append_default_model_info(  # Add default information for the embedding model
            ModelInfo(
                name='embedding',
                description='',
                type=ModelTypeConst.EMBEDDING,
                credential=embedding_model_credential,
                backend_class=XFEmbedding  # Assuming this class loads and manages the embedding model
            )
        )
        .build()
    )

Key Changes:

  1. Comments: Added comments explaining the purpose of each section and function parameter.
  2. Namespace Correction: Adjusted the namespace (...) in front of imports to match typical project structure.
  3. Parameter Documentation: Improved documentation on parameters using docstrings.

This should help clarify the intent behind the code and make it easier to understand.

@shaohuzhang1 shaohuzhang1 merged commit 4bddd1a into main Jan 7, 2025
4 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_embedding_model branch January 7, 2025 03:22
shaohuzhang1 added a commit that referenced this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant