mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-05-01 04:50:01 +00:00
simplify the model selector
This commit is contained in:
parent
8bb5db158f
commit
859b7f6e7e
6 changed files with 151 additions and 75 deletions
|
|
@ -8,8 +8,6 @@ from typing import Optional
|
|||
|
||||
from openai import OpenAI
|
||||
|
||||
from open_notebook.domain.models import Model
|
||||
|
||||
|
||||
@dataclass
|
||||
class SpeechToTextModel(ABC):
|
||||
|
|
@ -42,21 +40,3 @@ class OpenAISpeechToTextModel(SpeechToTextModel):
|
|||
model=self.model_name, file=audio
|
||||
)
|
||||
return transcription.text
|
||||
|
||||
|
||||
SPEECH_TO_TEXT_CLASS_MAP = {
|
||||
"openai": OpenAISpeechToTextModel,
|
||||
}
|
||||
|
||||
|
||||
# todo: acho que dá pra juntar todos os get models em uma coisa só
|
||||
def get_speech_to_text_model(model_id):
|
||||
assert model_id, "Model ID cannot be empty"
|
||||
model = Model.get(model_id)
|
||||
if not model:
|
||||
raise ValueError(f"Model with ID {model_id} not found")
|
||||
if model.provider not in SPEECH_TO_TEXT_CLASS_MAP.keys():
|
||||
raise ValueError(
|
||||
f"Provider {model.provider} not compatible with Embedding Models"
|
||||
)
|
||||
return SPEECH_TO_TEXT_CLASS_MAP[model.provider](model_name=model.name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue