Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9646,3 +9646,90 @@ msgstr ""
#: apps/models_provider/impl/tencent_model_provider/credential/tokenhub_stt.py:76
msgid "Tokenhub sync_transcribe endpoint"
msgstr ""

msgid "Add logo"
msgstr "Add logo"

msgid "Custom watermark content, at most 16 characters, drawn in the bottom-right."
msgstr "Custom watermark content, at most 16 characters, drawn in the bottom-right."

msgid "Designed for Agent workloads, using a MoE architecture that supports interleaved thinking, structured output, Function Calling and Cache caching."
msgstr "Designed for Agent workloads, using a MoE architecture that supports interleaved thinking, structured output, Function Calling and Cache caching."

msgid "Frame rate"
msgstr "Frame rate"

msgid "Hunyuan HY-Video 1.5 image-to-video model."
msgstr "Hunyuan HY-Video 1.5 image-to-video model."

msgid "Hunyuan HY-Video 1.5 text-to-video model."
msgstr "Hunyuan HY-Video 1.5 text-to-video model."

msgid "Hunyuan Hy-Image 3.0 text-to-image model."
msgstr "Hunyuan Hy-Image 3.0 text-to-image model."

msgid "Hunyuan's latest role-playing model based on the Hunyuan model with role-playing scene fine-tuning."
msgstr "Hunyuan's latest role-playing model based on the Hunyuan model with role-playing scene fine-tuning."

msgid "Hunyuan's role-playing model with better basic effects in role-playing scenarios."
msgstr "Hunyuan's role-playing model with better basic effects in role-playing scenarios."

msgid "Output video frame rate: 16, 24, 30."
msgstr "Output video frame rate: 16, 24, 30."

msgid "Output video resolution: 480p, 720p, 1080p."
msgstr "Output video resolution: 480p, 720p, 1080p."

msgid "Prompt rewrite"
msgstr "Prompt rewrite"

msgid "Tencent Hybrid multilingual translation model."
msgstr "Tencent Hybrid multilingual translation model."

msgid "Tencent TokenHub multimodal embedding model, 2048 dimensions."
msgstr "Tencent TokenHub multimodal embedding model, 2048 dimensions."

msgid "Tencent TokenHub multimodal embedding model, 4096 dimensions."
msgstr "Tencent TokenHub multimodal embedding model, 4096 dimensions."

msgid "Tencent TokenHub text embedding model, 1024 dimensions."
msgstr "Tencent TokenHub text embedding model, 1024 dimensions."

msgid "Tencent TokenHub text embedding model, 2560 dimensions."
msgstr "Tencent TokenHub text embedding model, 2560 dimensions."

msgid "Tencent YT-Video 2.0 image-to-video model."
msgstr "Tencent YT-Video 2.0 image-to-video model."

msgid "The latest generation productivity model with upgraded Agent and complex task execution capabilities."
msgstr "The latest generation productivity model with upgraded Agent and complex task execution capabilities."

msgid "TokenHub Hy-Image v3-generation endpoint"
msgstr "TokenHub Hy-Image v3-generation endpoint"

msgid "TokenHub OpenAI compatible embeddings endpoint"
msgstr "TokenHub OpenAI compatible embeddings endpoint"

msgid "TokenHub OpenAI compatible endpoint"
msgstr "TokenHub OpenAI compatible endpoint"

msgid "TokenHub video endpoint. Use the base (e.g. https://tokenhub.tencentmaas.com/v1) or a full submit/query URL."
msgstr "TokenHub video endpoint. Use the base (e.g. https://tokenhub.tencentmaas.com/v1) or a full submit/query URL."

msgid "Tuned on real business scenarios, balancing effectiveness and cost-effectiveness, with reinforced Coding, long-text, reasoning and Agent capabilities."
msgstr "Tuned on real business scenarios, balancing effectiveness and cost-effectiveness, with reinforced Coding, long-text, reasoning and Agent capabilities."

msgid "Watermark footnote"
msgstr "Watermark footnote"

msgid "Whether the model should rewrite and optimize the prompt before generation."
msgstr "Whether the model should rewrite and optimize the prompt before generation."

msgid "Whether to add the AI-generated logo to the video. 1: add logo; 0: no logo (requires console approval for independent control)."
msgstr "Whether to add the AI-generated logo to the video. 1: add logo; 0: no logo (requires console approval for independent control)."

msgid "Width and height must be in [512, 2048] and the area must not exceed 1024x1024. If not passed, the model auto-selects the closest preset size."
msgstr "Width and height must be in [512, 2048] and the area must not exceed 1024x1024. If not passed, the model auto-selects the closest preset size."

msgid "api_key is required"
msgstr "api_key is required"
117 changes: 116 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9787,4 +9787,119 @@ msgstr "自动"

#: apps/models_provider/impl/tencent_model_provider/credential/tokenhub_stt.py:76
msgid "Tokenhub sync_transcribe endpoint"
msgstr "Tokenhub 同步转写接口地址"
msgstr "Tokenhub 同步转写接口地址"
#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Add logo"
msgstr "添加标识"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Custom watermark content, at most 16 characters, drawn in the bottom-right."
msgstr "自定义水印内容,最多16个字符,绘制在右下角。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Designed for Agent workloads, using a MoE architecture that supports interleaved thinking, structured output, Function Calling and Cache caching."
msgstr "专为 Agent 场景设计,采用 MoE 架构,支持交织思考、结构化输出、Function Calling 和 Cache 缓存。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Frame rate"
msgstr "帧率"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan HY-Video 1.5 image-to-video model."
msgstr "混元 HY-Video 1.5 图生视频模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan HY-Video 1.5 text-to-video model."
msgstr "混元 HY-Video 1.5 文生视频模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan Hy-Image 3.0 text-to-image model."
msgstr "混元 Hy-Image 3.0 文生图模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan's latest role-playing model based on the Hunyuan model with role-playing scene fine-tuning."
msgstr "基于混元模型并在角色扮演场景微调的最新角色扮演模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan's role-playing model with better basic effects in role-playing scenarios."
msgstr "在角色扮演场景中基础效果更优的混元角色扮演模型。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Output video frame rate: 16, 24, 30."
msgstr "输出视频帧率:16、24、30。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Output video resolution: 480p, 720p, 1080p."
msgstr "输出视频分辨率:480p、720p、1080p。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Prompt rewrite"
msgstr "提示词改写"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent Hybrid multilingual translation model."
msgstr "腾讯混元多语言翻译模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub multimodal embedding model, 2048 dimensions."
msgstr "腾讯 TokenHub 多模态向量模型,2048 维。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub multimodal embedding model, 4096 dimensions."
msgstr "腾讯 TokenHub 多模态向量模型,4096 维。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub text embedding model, 1024 dimensions."
msgstr "腾讯 TokenHub 文本向量模型,1024 维。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub text embedding model, 2560 dimensions."
msgstr "腾讯 TokenHub 文本向量模型,2560 维。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent YT-Video 2.0 image-to-video model."
msgstr "腾讯 YT-Video 2.0 图生视频模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "The latest generation productivity model with upgraded Agent and complex task execution capabilities."
msgstr "采用全新一代生产力模型,升级了 Agent 与复杂任务执行能力。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "TokenHub Hy-Image v3-generation endpoint"
msgstr "TokenHub Hy-Image v3-generation 接口"

#: apps/models_provider/impl/tencent_model_provider/credential/embedding.py
msgid "TokenHub OpenAI compatible embeddings endpoint"
msgstr "TokenHub OpenAI 兼容向量接口"

#: apps/models_provider/impl/tencent_model_provider/credential/llm.py
msgid "TokenHub OpenAI compatible endpoint"
msgstr "TokenHub OpenAI 兼容接口"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "TokenHub video endpoint. Use the base (e.g. https://tokenhub.tencentmaas.com/v1) or a full submit/query URL."
msgstr "TokenHub 视频接口。可使用根地址(如 https://tokenhub.tencentmaas.com/v1)或完整的 submit/query 地址。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tuned on real business scenarios, balancing effectiveness and cost-effectiveness, with reinforced Coding, long-text, reasoning and Agent capabilities."
msgstr "针对真实业务场景调优,兼顾效果与成本,强化了 Coding、长文本、推理和 Agent 能力。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Watermark footnote"
msgstr "水印角标"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Whether the model should rewrite and optimize the prompt before generation."
msgstr "模型是否在生成前改写并优化提示词。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Whether to add the AI-generated logo to the video. 1: add logo; 0: no logo (requires console approval for independent control)."
msgstr "是否为生成视频添加 AI 标识。1:添加标识;0:不添加标识(需在控制台申请开启独立控制)。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Width and height must be in [512, 2048] and the area must not exceed 1024x1024. If not passed, the model auto-selects the closest preset size."
msgstr "宽和高必须在 [512, 2048] 之间,且面积不得超过 1024x1024。不传时由模型自动选择最接近的预设尺寸。"

#: apps/models_provider/impl/tencent_model_provider/credential/embedding.py
msgid "api_key is required"
msgstr "api_key 必填"
116 changes: 116 additions & 0 deletions apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9785,3 +9785,119 @@ msgstr "自動"
#: apps/models_provider/impl/tencent_model_provider/credential/tokenhub_stt.py:76
msgid "Tokenhub sync_transcribe endpoint"
msgstr "Tokenhub 同步轉寫接口地址"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Add logo"
msgstr "加入標示"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Custom watermark content, at most 16 characters, drawn in the bottom-right."
msgstr "自訂浮水印內容,最多16個字元,繪製在右下角。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Designed for Agent workloads, using a MoE architecture that supports interleaved thinking, structured output, Function Calling and Cache caching."
msgstr "專為 Agent 場景設計,採用 MoE 架構,支援交織思考、結構化輸出、Function Calling 與 Cache 快取。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Frame rate"
msgstr "幀率"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan HY-Video 1.5 image-to-video model."
msgstr "混元 HY-Video 1.5 圖生影片模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan HY-Video 1.5 text-to-video model."
msgstr "混元 HY-Video 1.5 文生影片模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan Hy-Image 3.0 text-to-image model."
msgstr "混元 Hy-Image 3.0 文生圖模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan's latest role-playing model based on the Hunyuan model with role-playing scene fine-tuning."
msgstr "基於混元模型並在角色扮演場景微調的最新角色扮演模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Hunyuan's role-playing model with better basic effects in role-playing scenarios."
msgstr "在角色扮演場景中基礎效果更優的混元角色扮演模型。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Output video frame rate: 16, 24, 30."
msgstr "輸出影片幀率:16、24、30。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Output video resolution: 480p, 720p, 1080p."
msgstr "輸出影片解析度:480p、720p、1080p。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Prompt rewrite"
msgstr "提示詞改寫"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent Hybrid multilingual translation model."
msgstr "騰訊混元多語言翻譯模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub multimodal embedding model, 2048 dimensions."
msgstr "騰訊 TokenHub 多模態向量模型,2048 維。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub multimodal embedding model, 4096 dimensions."
msgstr "騰訊 TokenHub 多模態向量模型,4096 維。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub text embedding model, 1024 dimensions."
msgstr "騰訊 TokenHub 文字向量模型,1024 維。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent TokenHub text embedding model, 2560 dimensions."
msgstr "騰訊 TokenHub 文字向量模型,2560 維。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tencent YT-Video 2.0 image-to-video model."
msgstr "騰訊 YT-Video 2.0 圖生影片模型。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "The latest generation productivity model with upgraded Agent and complex task execution capabilities."
msgstr "採用全新一代生產力模型,升級了 Agent 與複雜任務執行能力。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "TokenHub Hy-Image v3-generation endpoint"
msgstr "TokenHub Hy-Image v3-generation 介面"

#: apps/models_provider/impl/tencent_model_provider/credential/embedding.py
msgid "TokenHub OpenAI compatible embeddings endpoint"
msgstr "TokenHub OpenAI 相容向量介面"

#: apps/models_provider/impl/tencent_model_provider/credential/llm.py
msgid "TokenHub OpenAI compatible endpoint"
msgstr "TokenHub OpenAI 相容介面"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "TokenHub video endpoint. Use the base (e.g. https://tokenhub.tencentmaas.com/v1) or a full submit/query URL."
msgstr "TokenHub 影片介面。可使用根位址(如 https://tokenhub.tencentmaas.com/v1)或完整的 submit/query 位址。"

#: apps/models_provider/impl/tencent_model_provider/tencent_model_provider.py
msgid "Tuned on real business scenarios, balancing effectiveness and cost-effectiveness, with reinforced Coding, long-text, reasoning and Agent capabilities."
msgstr "針對真實業務場景調優,兼顧效果與成本,強化了 Coding、長文本、推理和 Agent 能力。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Watermark footnote"
msgstr "浮水印角標"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Whether the model should rewrite and optimize the prompt before generation."
msgstr "模型是否在生成前改寫並最佳化提示詞。"

#: apps/models_provider/impl/tencent_model_provider/credential/ttv.py
msgid "Whether to add the AI-generated logo to the video. 1: add logo; 0: no logo (requires console approval for independent control)."
msgstr "是否為生成影片加入 AI 標示。1:加入標示;0:不加入標示(需在控制台申請開啟獨立控制)。"

#: apps/models_provider/impl/tencent_model_provider/credential/tti.py
msgid "Width and height must be in [512, 2048] and the area must not exceed 1024x1024. If not passed, the model auto-selects the closest preset size."
msgstr "寬和高必須在 [512, 2048] 之間,且面積不得超過 1024x1024。未傳時由模型自動選擇最接近的預設尺寸。"

#: apps/models_provider/impl/tencent_model_provider/credential/embedding.py
msgid "api_key is required"
msgstr "api_key 必填"
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# coding=utf-8

from typing import Dict

from django.utils.translation import gettext as _

from common import forms
from common.exception.app_exception import AppApiException
from common.forms import BaseForm
from common.forms import BaseForm, TooltipLabel
from models_provider.base_model_provider import BaseModelCredential, ValidCode
from common.utils.logger import maxkb_logger


class TencentEmbeddingCredential(BaseForm, BaseModelCredential):
def is_valid(
self,
model_type: str,
model_name,
model_credential: Dict[str, object],
model_params,
provider,
raise_exception=True,
) -> bool:
self, model_type, model_name, model_credential: Dict[str, object], model_params, provider, raise_exception=True
):
model_type_list = provider.get_model_type_list()
if not any(list(filter(lambda mt: mt.get("value") == model_type, model_type_list))):
if not any(mt.get("value") == model_type for mt in model_type_list):
raise AppApiException(
ValidCode.valid_error.value, _("{model_type} Model type is not supported").format(model_type=model_type)
)
self.valid_form(model_credential)

if "api_key" not in model_credential:
if raise_exception:
raise AppApiException(ValidCode.valid_error.value, _("api_key is required"))
return False

try:
model = provider.get_model(model_type, model_name, model_credential)
model.embed_query(_("Hello"))
Expand All @@ -43,9 +44,12 @@ def is_valid(
return False
return True

def encryption_dict(self, model: Dict[str, object]) -> Dict[str, object]:
encrypted_secret_key = super().encryption(model.get("SecretKey", ""))
return {**model, "SecretKey": encrypted_secret_key}
def encryption_dict(self, model: Dict[str, object]):
return {**model, "api_key": super().encryption(model.get("api_key", ""))}

SecretId = forms.PasswordInputField("SecretId", required=True)
SecretKey = forms.PasswordInputField("SecretKey", required=True)
base_url = forms.TextInputField(
label=TooltipLabel(_("API URL"), _("TokenHub OpenAI compatible embeddings endpoint")),
required=False,
default_value="https://tokenhub.tencentmaas.com/v1",
)
api_key = forms.PasswordInputField(_("API Key"), required=True)
Loading
Loading