Underground-Digital/Workflow-Engine
0
1from typing import IO, Optional2 3from core.model_runtime.model_providers.openai_api_compatible.speech2text.speech2text import OAICompatSpeech2TextModel4 5 6class SiliconflowSpeech2TextModel(OAICompatSpeech2TextModel):7 """8 Model class for Siliconflow Speech to text model.9 """10 11 def _invoke(self, model: str, credentials: dict, file: IO[bytes], user: Optional[str] = None) -> str:12 """13 Invoke speech2text model14 15 :param model: model name16 :param credentials: model credentials17 :param file: audio file18 :param user: unique user id19 :return: text for given audio file20 """21 self._add_custom_parameters(credentials)22 return super()._invoke(model, credentials, file)23 24 def validate_credentials(self, model: str, credentials: dict) -> None:25 self._add_custom_parameters(credentials)26 return super().validate_credentials(model, credentials)27 28 @classmethod29 def _add_custom_parameters(cls, credentials: dict) -> None:30 credentials["endpoint_url"] = "https://api.siliconflow.cn/v1"31 