Skip to content

Commit

Permalink
Corrected type annotation to "Any" from "any" all files in "model_pro…
Browse files Browse the repository at this point in the history
…viders" folder (#9135)
  • Loading branch information
ronaksingh27 authored Oct 10, 2024
1 parent 783a6b8 commit 62051d5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions api/core/model_runtime/model_providers/__base/tts_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import re
from abc import abstractmethod
from typing import Optional
from typing import Any, Optional

from pydantic import ConfigDict

Expand Down Expand Up @@ -88,7 +88,7 @@ def get_tts_model_voices(self, model: str, credentials: dict, language: Optional
else:
return [{"name": d["name"], "value": d["mode"]} for d in voices]

def _get_model_default_voice(self, model: str, credentials: dict) -> any:
def _get_model_default_voice(self, model: str, credentials: dict) -> Any:
"""
Get voice for given tts model
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import concurrent.futures
import copy
from typing import Optional
from typing import Any, Optional

from openai import AzureOpenAI

Expand All @@ -19,7 +19,7 @@ class AzureOpenAIText2SpeechModel(_CommonAzureOpenAI, TTSModel):

def _invoke(
self, model: str, tenant_id: str, credentials: dict, content_text: str, voice: str, user: Optional[str] = None
) -> any:
) -> Any:
"""
_invoke text2speech model
Expand Down Expand Up @@ -56,7 +56,7 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
except Exception as ex:
raise CredentialsValidateFailedError(str(ex))

def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:
def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> Any:
"""
_tts_invoke_streaming text2speech model
:param model: model name
Expand Down
8 changes: 4 additions & 4 deletions api/core/model_runtime/model_providers/fishaudio/tts/tts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Any, Optional

import httpx

Expand Down Expand Up @@ -46,7 +46,7 @@ def _invoke(
content_text: str,
voice: str,
user: Optional[str] = None,
) -> any:
) -> Any:
"""
Invoke text2speech model
Expand Down Expand Up @@ -87,7 +87,7 @@ def validate_credentials(self, credentials: dict, user: Optional[str] = None) ->
except Exception as ex:
raise CredentialsValidateFailedError(str(ex))

def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:
def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> Any:
"""
Invoke streaming text2speech model
:param model: model name
Expand All @@ -112,7 +112,7 @@ def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str
except Exception as ex:
raise InvokeBadRequestError(str(ex))

def _tts_invoke_streaming_sentence(self, credentials: dict, content_text: str, voice: Optional[str] = None) -> any:
def _tts_invoke_streaming_sentence(self, credentials: dict, content_text: str, voice: Optional[str] = None) -> Any:
"""
Invoke streaming text2speech model
Expand Down
6 changes: 3 additions & 3 deletions api/core/model_runtime/model_providers/openai/tts/tts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import concurrent.futures
from typing import Optional
from typing import Any, Optional

from openai import OpenAI

Expand All @@ -16,7 +16,7 @@ class OpenAIText2SpeechModel(_CommonOpenAI, TTSModel):

def _invoke(
self, model: str, tenant_id: str, credentials: dict, content_text: str, voice: str, user: Optional[str] = None
) -> any:
) -> Any:
"""
_invoke text2speech model
Expand Down Expand Up @@ -55,7 +55,7 @@ def validate_credentials(self, model: str, credentials: dict, user: Optional[str
except Exception as ex:
raise CredentialsValidateFailedError(str(ex))

def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:
def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> Any:
"""
_tts_invoke_streaming text2speech model
Expand Down
4 changes: 2 additions & 2 deletions api/core/model_runtime/model_providers/sagemaker/tts/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]
InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError],
}

def _get_model_default_voice(self, model: str, credentials: dict) -> any:
def _get_model_default_voice(self, model: str, credentials: dict) -> Any:
return ""

def _get_model_word_limit(self, model: str, credentials: dict) -> int:
Expand Down Expand Up @@ -225,7 +225,7 @@ def _invoke_sagemaker(self, payload: dict, endpoint: str):
json_obj = json.loads(json_str)
return json_obj

def _tts_invoke_streaming(self, model_type: str, payload: dict, sagemaker_endpoint: str) -> any:
def _tts_invoke_streaming(self, model_type: str, payload: dict, sagemaker_endpoint: str) -> Any:
"""
_tts_invoke_streaming text2speech model
Expand Down
6 changes: 3 additions & 3 deletions api/core/model_runtime/model_providers/tongyi/tts/tts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import threading
from queue import Queue
from typing import Optional
from typing import Any, Optional

import dashscope
from dashscope import SpeechSynthesizer
Expand All @@ -20,7 +20,7 @@ class TongyiText2SpeechModel(_CommonTongyi, TTSModel):

def _invoke(
self, model: str, tenant_id: str, credentials: dict, content_text: str, voice: str, user: Optional[str] = None
) -> any:
) -> Any:
"""
_invoke text2speech model
Expand Down Expand Up @@ -58,7 +58,7 @@ def validate_credentials(self, model: str, credentials: dict, user: Optional[str
except Exception as ex:
raise CredentialsValidateFailedError(str(ex))

def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:
def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> Any:
"""
_tts_invoke_streaming text2speech model
Expand Down
6 changes: 3 additions & 3 deletions api/core/model_runtime/model_providers/xinference/tts/tts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import concurrent.futures
from typing import Optional
from typing import Any, Optional

from xinference_client.client.restful.restful_client import RESTfulAudioModelHandle

Expand Down Expand Up @@ -166,7 +166,7 @@ def get_tts_model_voices(self, model: str, credentials: dict, language: Optional

return self.model_voices["__default"]["all"]

def _get_model_default_voice(self, model: str, credentials: dict) -> any:
def _get_model_default_voice(self, model: str, credentials: dict) -> Any:
return ""

def _get_model_word_limit(self, model: str, credentials: dict) -> int:
Expand All @@ -178,7 +178,7 @@ def _get_model_audio_type(self, model: str, credentials: dict) -> str:
def _get_model_workers_limit(self, model: str, credentials: dict) -> int:
return 5

def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:
def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> Any:
"""
_tts_invoke_streaming text2speech model
Expand Down

0 comments on commit 62051d5

Please sign in to comment.