-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: bailian tti and image model set default model #1983
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
35ae290
7f8eae3
547e860
c7b3651
381ae71
908c907
2647f55
0575047
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 |
|---|---|---|
|
|
@@ -40,8 +40,18 @@ | |
| ModelInfo('embedding', '', ModelTypeConst.EMBEDDING, embedding_model_credential, XFEmbedding) | ||
| ] | ||
|
|
||
| model_info_manage = ModelInfoManage.builder().append_model_info_list(model_info_list).append_default_model_info( | ||
| ModelInfo('generalv3.5', '', ModelTypeConst.LLM, qwen_model_credential, XFChatSparkLLM)).build() | ||
| model_info_manage = ( | ||
| ModelInfoManage.builder() | ||
| .append_model_info_list(model_info_list) | ||
| .append_default_model_info( | ||
| ModelInfo('generalv3.5', '', ModelTypeConst.LLM, qwen_model_credential, XFChatSparkLLM)) | ||
| .append_default_model_info( | ||
| ModelInfo('iat', '中英文识别', ModelTypeConst.STT, stt_model_credential, XFSparkSpeechToText), | ||
| ) | ||
| .append_default_model_info( | ||
| ModelInfo('tts', '', ModelTypeConst.TTS, tts_model_credential, XFSparkTextToSpeech)) | ||
| .build() | ||
| ) | ||
|
|
||
|
|
||
| class XunFeiModelProvider(IModelProvider): | ||
|
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 is well-structured and free of major issues. However, there are some minor improvements that can be made:
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:
These changes should not impact functionality but improve the code structure for ease of maintenance and review. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -521,25 +521,29 @@ | |
| rerank_list = [ModelInfo('bce-reranker-base_v1', | ||
| '发布新的重新排名器,建立在强大的 M3 和LLM (GEMMA 和 MiniCPM,实际上没那么大)骨干上,支持多语言处理和更大的输入,大幅提高 BEIR、C-MTEB/Retrieval 的排名性能、MIRACL、LlamaIndex 评估', | ||
| ModelTypeConst.RERANKER, XInferenceRerankerModelCredential(), XInferenceReranker)] | ||
| 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) | ||
| .append_model_info_list(tti_model_info) | ||
| .append_default_model_info(rerank_list[0]) | ||
| .build()) | ||
| 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) | ||
| .append_default_model_info(image_model_info[0]) | ||
| .append_model_info_list(tti_model_info) | ||
| .append_default_model_info(tti_model_info[0]) | ||
| .append_default_model_info(rerank_list[0]) | ||
| .build() | ||
| ) | ||
|
|
||
|
|
||
| def get_base_url(url: str): | ||
|
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 looks mostly clean, but there is one issue related to the default model information being added twice for each list except 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 |
||
|
|
||
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_infowith the same input. This is unnecessary as it will append additional copies of the default information. Here are some optimizations:This snippet uses
Counterfrom 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.