This commit is contained in:
an-lee
2024-05-21 16:28:45 +08:00
parent f95b63ed85
commit 2fea45fb32
2 changed files with 14 additions and 5 deletions

View File

@@ -68,18 +68,23 @@ export class Conversation extends Model<Conversation> {
@BeforeSave
static validateConfiguration(conversation: Conversation) {
if (!conversation.model) throw new Error(t("models.conversation.modelIsRequired"));
if (conversation.type === 'tts') {
if (conversation.type === "tts") {
if (!conversation.configuration.tts) {
throw new Error(t("models.conversation.ttsConfigurationIsRequired"))
throw new Error(t("models.conversation.ttsConfigurationIsRequired"));
}
if (!conversation.configuration.tts.engine) {
throw new Error(t("models.conversation.ttsEngineIsRequired"))
throw new Error(t("models.conversation.ttsEngineIsRequired"));
}
if (!conversation.configuration.tts.model) {
throw new Error("models.conversation.ttsModelIsRequired")
throw new Error("models.conversation.ttsModelIsRequired");
}
conversation.engine = conversation.configuration.tts.engine;
conversation.configuration.model = conversation.configuration.tts.engine;
}
if (!conversation.configuration.model)
throw new Error(t("models.conversation.modelIsRequired"));
}
@AfterCreate

View File

@@ -49,6 +49,8 @@ export default () => {
type: "tts",
tts: {
engine: currentEngine.name,
model: "tts-1",
voice: "alloy",
},
},
},
@@ -152,6 +154,8 @@ export default () => {
type: "tts",
tts: {
engine: currentEngine.name,
model: "tts-1",
voice: "alloy",
},
},
};