/// chatGpt model gpt3.5-turbo、gpt-4-turbo、gpt-4o 默认是 gpt-4-turbo
public var gptModel:String = "gpt-4-turbo"
+ public var platform:MSPlatform{
+ return MixSdk.shared.aiPlatform
+ }
/// 使用大模型
public var useMode:((_ result:MSPlatform) -> Void)?
/// 使用大模型
}
else{
if platform == .chatGPT {
- checkChatptValid()
+ checkChatptValid(key ?? "") {[weak self] isValid, error in
+ guard let self = self else {return}
+ if let valid = isValid{
+ sendAiState(isValid: valid, gptKey: key)
+ }
+ else {
+ sendAiState(isValid: false, gptKey: key)
+ }
+ }
}
else{
sendAiState(isValid: true, gptKey: nil)
}
}
}
-
- func checkChatptValid(){
+
+ public func checkChatptValid(_ key:String ,completeHandler: @escaping MSChatGptCheckKeyCallBack){
guard let key = chatGptKey else{
Logger.log("请先设置chatGPT key")
- sendAiState(isValid: false, gptKey: "")
+ completeHandler(false,nil)
return
}
- MixSdk.shared.chatGpt.isValidKey(key) {[weak self] isValid, error in
- guard let self = self else {return}
- if let valid = isValid{
- sendAiState(isValid: valid, gptKey: key)
- }
- else {
- sendAiState(isValid: false, gptKey: key)
- }
- }
+ MixSdk.shared.chatGpt.isValidKey(key, completeHandler: completeHandler)
}
func sendAiState(isValid:Bool,gptKey:String?){
let model = IBAiValid()