-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: bailian tti and image model set default model #1983
Conversation
--bug=1051237 --user=刘瑞斌 【模型管理】Xorbits Inference添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642278
--bug=1051236 --user=刘瑞斌 【模型管理】智谱AI添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642279
--bug=1051233 --user=刘瑞斌 【模型管理】讯飞星火添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642301
--bug=1051231 --user=刘瑞斌 【模型管理】火山引擎添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642307
--bug=1051229 --user=刘瑞斌 【模型管理】腾讯混元添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642310
--bug=1051228 --user=刘瑞斌 【模型管理】通义千问添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642313
--bug=1051227 --user=刘瑞斌 【模型管理】OpenAI添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642314
--bug=1051223 --user=刘瑞斌 【模型管理】阿里云百炼自定义添加图片生成模型报错 https://www.tapd.cn/57709429/s/1642319 --bug=1051218 --user=刘瑞斌 【模型管理】阿里云百炼自定义添加图片理解模型报错 https://www.tapd.cn/57709429/s/1642323
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. 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. |
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
.append_default_model_info(tti_model_info[0]) | ||
.append_default_model_info(rerank_list[0]) | ||
.build() | ||
) | ||
|
||
|
||
def get_base_url(url: str): |
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 clean, but there is one issue related to the default model information being added twice for each list except rerank_list
, which should only be appended once per list.
Here's the corrected version with the issue removed:
@@ -521,27 +521,31 @@
# ... other lines ...
+image_model_info.append(ImageModelInfo(
+ name='your_image_model_name_here'
))
+tti_model_info.append(TTIModelInfo(
+ name='your_tti_model_name_here'
))
model_info_manage = (
ModelInfoManage.builder()
.append_model_info_list(model_info_list)
.append_model_info_list(voice_model_info)
.append_default_model_info(voice_model_info[0])
.append_default_model_info(voice_model_info[1])
.append_default_model_info(ModelInfo('phi3',
'Phi-3 Mini是Microsoft的3.8B参数,轻量级,最先进的开放模型。',
ModelTypeConst.LLM, xinference_llm_model_credential,
XinferenceChatModel))
.append_model_info_list(embedding_model_info)
.append_default_model_info(ModelInfo('', '', ModelTypeConst.EMBEDDING,
xinference_embedding_model_credential, XinferenceEmbedding))
.append_model_info_list(rerank_list)
.append_model_info_list(image_model_info) # Added this line
.append_default_model_info(image_model_info[0]) # Removed this duplicate line
.append_model_info_list(tti_model_info)
.append_default_model_info(tti_model_info[0]) # Removed this duplicate line
.append_default_model_info(rerank_list[0])
.build()
)
@@ -544,6 +549,4 @@
def get_base_url(url: str):
Make sure to replace 'your_image_model_name_here'
and 'your_tti_model_name_here'
with actual names for your respective image and TTI models if they have unique names.
.append_default_model_info( | ||
ModelInfo('tts', '', ModelTypeConst.TTS, tts_model_credential, XFSparkTextToSpeech)) | ||
.build() | ||
) | ||
|
||
|
||
class XunFeiModelProvider(IModelProvider): |
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 is well-structured and free of major issues. However, there are some minor improvements that can be made:
-
Separate List Building: Instead of appending default model infos directly after specifying the list, consider separating the steps into different operations to make it more readable.
-
Consistent Method Syntax: Ensure consistent use of method chaining with parentheses when building objects like
ModelInfoManage
. -
Comments Improvements: Add comments explaining each step in the configuration process for clarity.
Here's an improved version:
@@ -40,8 +40,14 @@
ModelInfo('embedding', '', ModelTypeConst.EMBEDDING, embedding_model_credential, XFEmbedding)
])
# Separate out the list creation from the default info appends for better readability
model_info_list = [
ModelInfo('embedding', '', ModelTypeConst.EMBEDDING, embedding_model_credential, XFEmbedding)
]
# Append models to Manage first
model_info_manage = ModelInfoManage.builder()
# Build the model information management instance
model_info_manage.append_model_info_list(model_info_list)
# Then append default models to maintain proper order of construction
model_info_manage.append_default_model_info(
ModelInfo('generalv3.5', '', ModelTypeConst.LLM, qwen_model_credential, XFChatSparkLLM)
)
model_info_manage.append_default_model_info(
ModelInfo('iat', '中英文识别', ModelTypeConst.STT, stt_model_credential, XFSparkSpeechToText)
)
model_info_manage.append_default_model_info(
ModelInfo('tts', '', ModelTypeConst.TTS, tts_model_credential, XFSparkTextToSpeech)
)
# Finalize builder and obtain the model info manage instance
model_info_manage = model_info_manage.build()
class XunFeiModelProvider(IModelProvider):
Key Changes:
- Separation of list instantiation from subsequent adds to enhance organization.
- Consistent parentheses usage in method invocations where appropriate.
- Comments added at relevant points for understanding the sequence of operations.
These changes should not impact functionality but improve the code structure for ease of maintenance and review.
) | ||
.append_default_model_info(ModelInfo('tts-1', '', | ||
ModelTypeConst.TTS, openai_tts_model_credential, | ||
OpenAITextToSpeech)) | ||
.build() | ||
) | ||
|
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 contains repeated calls to append_default_model_info
with the same input. This is unnecessary as it will append additional copies of the default information. Here are some optimizations:
- Remove duplicates:
.model_info_embedding_list,
.model_info_image_list,
.model_info_tti_list).apply(lambda lst: [mi for mi, count in Counter(lst).items() if count == 1])
.append_default_model_info(mi)
for mi in unique_models]:
This snippet uses Counter
from Python's standard library to identify and discard duplicate models before applying .append_default_model_info
.
Note that since this approach removes all but distinct models (including potentially multiple instances or different configurations of certain models), you may need to adjust how these model credentials and types are managed depending on your application's needs.
Additionally, ensure all required modules and configurations (openai_stt_model_credential
, OpenAISpeechToText
, etc.) are correctly imported and initialized above the function call where they're used.
fix: xinference tti and image model set default model --bug=1051237 --user=刘瑞斌 【模型管理】Xorbits Inference添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642278
fix: zhipu tti and image model set default model --bug=1051236 --user=刘瑞斌 【模型管理】智谱AI添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642279
fix: xunfei tts and stt model set default model --bug=1051233 --user=刘瑞斌 【模型管理】讯飞星火添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642301
fix: volcanic tts and stt model set default model --bug=1051231 --user=刘瑞斌 【模型管理】火山引擎添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642307
fix: tencent tti and image model set default model --bug=1051229 --user=刘瑞斌 【模型管理】腾讯混元添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642310
fix: qwen tti and image model set default model --bug=1051228 --user=刘瑞斌 【模型管理】通义千问添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642313
fix: openai tti, tts, stt and image model set default model --bug=1051227 --user=刘瑞斌 【模型管理】OpenAI添加自定义模型报错问题汇总 https://www.tapd.cn/57709429/s/1642314
fix: bailian tti and image model set default model --bug=1051223 --user=刘瑞斌 【模型管理】阿里云百炼自定义添加图片生成模型报错 https://www.tapd.cn/57709429/s/1642319 --bug=1051218 --user=刘瑞斌 【模型管理】阿里云百炼自定义添加图片理解模型报错 https://www.tapd.cn/57709429/s/1642323