|
|
|
|
@ -63,7 +63,7 @@ class ModelInstance:
|
|
|
|
|
:return: full response or stream response chunk generator result
|
|
|
|
|
"""
|
|
|
|
|
if not isinstance(self.model_type_instance, LargeLanguageModel):
|
|
|
|
|
raise Exception(f"Model type instance is not LargeLanguageModel")
|
|
|
|
|
raise Exception("Model type instance is not LargeLanguageModel")
|
|
|
|
|
|
|
|
|
|
self.model_type_instance = cast(LargeLanguageModel, self.model_type_instance)
|
|
|
|
|
return self.model_type_instance.invoke(
|
|
|
|
|
@ -88,7 +88,7 @@ class ModelInstance:
|
|
|
|
|
:return: embeddings result
|
|
|
|
|
"""
|
|
|
|
|
if not isinstance(self.model_type_instance, TextEmbeddingModel):
|
|
|
|
|
raise Exception(f"Model type instance is not TextEmbeddingModel")
|
|
|
|
|
raise Exception("Model type instance is not TextEmbeddingModel")
|
|
|
|
|
|
|
|
|
|
self.model_type_instance = cast(TextEmbeddingModel, self.model_type_instance)
|
|
|
|
|
return self.model_type_instance.invoke(
|
|
|
|
|
@ -112,7 +112,7 @@ class ModelInstance:
|
|
|
|
|
:return: rerank result
|
|
|
|
|
"""
|
|
|
|
|
if not isinstance(self.model_type_instance, RerankModel):
|
|
|
|
|
raise Exception(f"Model type instance is not RerankModel")
|
|
|
|
|
raise Exception("Model type instance is not RerankModel")
|
|
|
|
|
|
|
|
|
|
self.model_type_instance = cast(RerankModel, self.model_type_instance)
|
|
|
|
|
return self.model_type_instance.invoke(
|
|
|
|
|
@ -135,7 +135,7 @@ class ModelInstance:
|
|
|
|
|
:return: false if text is safe, true otherwise
|
|
|
|
|
"""
|
|
|
|
|
if not isinstance(self.model_type_instance, ModerationModel):
|
|
|
|
|
raise Exception(f"Model type instance is not ModerationModel")
|
|
|
|
|
raise Exception("Model type instance is not ModerationModel")
|
|
|
|
|
|
|
|
|
|
self.model_type_instance = cast(ModerationModel, self.model_type_instance)
|
|
|
|
|
return self.model_type_instance.invoke(
|
|
|
|
|
@ -155,7 +155,7 @@ class ModelInstance:
|
|
|
|
|
:return: text for given audio file
|
|
|
|
|
"""
|
|
|
|
|
if not isinstance(self.model_type_instance, Speech2TextModel):
|
|
|
|
|
raise Exception(f"Model type instance is not Speech2TextModel")
|
|
|
|
|
raise Exception("Model type instance is not Speech2TextModel")
|
|
|
|
|
|
|
|
|
|
self.model_type_instance = cast(Speech2TextModel, self.model_type_instance)
|
|
|
|
|
return self.model_type_instance.invoke(
|
|
|
|
|
@ -176,7 +176,7 @@ class ModelInstance:
|
|
|
|
|
:return: text for given audio file
|
|
|
|
|
"""
|
|
|
|
|
if not isinstance(self.model_type_instance, TTSModel):
|
|
|
|
|
raise Exception(f"Model type instance is not TTSModel")
|
|
|
|
|
raise Exception("Model type instance is not TTSModel")
|
|
|
|
|
|
|
|
|
|
self.model_type_instance = cast(TTSModel, self.model_type_instance)
|
|
|
|
|
return self.model_type_instance.invoke(
|
|
|
|
|
|