From: liangzhenying <867174124@qq.com> Date: Fri, 17 Jan 2025 07:43:18 +0000 (+0800) Subject: 注释掉ai功能 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=c607d86df307395161fd2964236b599a4b24e9c8;p=mirrors%2FIOTBluetooth-iOS.git 注释掉ai功能 --- diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate index 436d032..13d2352 100644 Binary files a/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate and b/IOTBluetooth/IOTBluetooth/IOTBluetooth.xcodeproj/project.xcworkspace/xcuserdata/yaozuopan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift index 6cf7c8e..b4f4035 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBAiManager.swift @@ -1,196 +1,196 @@ +//// +//// IBAiManager.swift +//// IOTBluetooth +//// +//// Created by incar on 2024/7/15. +//// // -// IBAiManager.swift -// IOTBluetooth +//import Foundation +//import MixSdk +//class IBAiManager{ +// static let shared = IBAiManager() +// var audioData = Data() +// +// var reply = "" +// +// init(){ +// MixSdk.shared.isDebug = true +// setupChatCallBack() +// } +// +// func aiValid(_ data:Data){ +// let result = IBGeneralParser.dataPacket(data) +// let code = result.int +// let desc = ["文心一言","ChatGPT","KIMI",":豆包"] +// Logger.log("询问模型是否可用:",desc[code]) +// let model = IBAiValid() +// model.isValid = true +// if code == 1 { +// model.key = "sk-proj-04ogvrZQqyaiv1OWw8OZT3BlbkFJG9Gyr8oFvRdmr3oXQNbX" +// } +// IBSender() +// .ability(IBAbility.aiValid) +// .parameters([.aiValid(model)]) +// .response { result in +// +// } // -// Created by incar on 2024/7/15. +// } +// func aiRequest(_ data:Data){ +// let result = IBGeneralParser.dataPacket(data) +// let code = result.int +// let desc = ["文心一言","ChatGPT","KIMI",":豆包"] +// Logger.log("使用模型:",desc[code]) +// IBSender() +// .ability(IBAbility.aiReady) +// .parameters([.value(1)]) +// .response {[weak self] result in +// self?.fectchAiAudio() +// } +// // - -import Foundation -import MixSdk -class IBAiManager{ - static let shared = IBAiManager() - var audioData = Data() - - var reply = "" - - init(){ - MixSdk.shared.isDebug = true - setupChatCallBack() - } - - func aiValid(_ data:Data){ - let result = IBGeneralParser.dataPacket(data) - let code = result.int - let desc = ["文心一言","ChatGPT","KIMI",":豆包"] - Logger.log("询问模型是否可用:",desc[code]) - let model = IBAiValid() - model.isValid = true - if code == 1 { - model.key = "sk-proj-04ogvrZQqyaiv1OWw8OZT3BlbkFJG9Gyr8oFvRdmr3oXQNbX" - } - IBSender() - .ability(IBAbility.aiValid) - .parameters([.aiValid(model)]) - .response { result in - - } - - } - func aiRequest(_ data:Data){ - let result = IBGeneralParser.dataPacket(data) - let code = result.int - let desc = ["文心一言","ChatGPT","KIMI",":豆包"] - Logger.log("使用模型:",desc[code]) - IBSender() - .ability(IBAbility.aiReady) - .parameters([.value(1)]) - .response {[weak self] result in - self?.fectchAiAudio() - } - - - var platform = MSPlatform.doubao - var key = "" - if code == 0 { - platform = .yiyan - } - else if code == 1 { - platform = .chatGPT - key = "sk-proj-04ogvrZQqyaiv1OWw8OZT3BlbkFJG9Gyr8oFvRdmr3oXQNbX" -// let gptModel = "gpt-4-turbo" -// MixSdk.shared.chatGpt.changeModel(model:gptModel ) - } - else if code == 2 { - platform = .kimi - } - else if code == 3 { - platform = .doubao - } - MixSdk.shared.setPlatform(platform,key: key) - } - func fectchAiAudio(){ - IBSender() - .ability(IBAbility.fetchAiAudio) - .parameters([]) - .response {[weak self] result in - guard let self = self else {return} - if result.isSuccess,let data = result.value as? Data{ - receiveAiData(sbcData: data) - } - else{ - Logger.log(result) - let model = IBAiResponse() - model.type = 0 - sendRelpy(model: model) - } - } - } - - -} -extension IBAiManager{ - func receiveAiData(sbcData:Data){ - let pcmData = MSAudioConvert.sbcTopcm(sbcData) - if pcmData.count == 0{ - Logger.log("sbc2pcm失败") - let model = IBAiResponse() - model.type = 0 - sendRelpy(model: model) - return - } - guard let pcmPath = IBTools.saveToFile(data: pcmData) else {return} - MixSdk.shared.stt.sentenceRecognize(filePath: pcmPath,format:"pcm",sample_rate:"16000",lang: "zh-cn") {[weak self] text, error in - guard let self = self else {return} - if let text = text,text.count > 0{ - Logger.log(text) - let model = IBAiResponse() - model.type = 1 - model.value = text - sendRelpy(model: model) - - MixSdk.shared.chat.send(content: text) - } - else{ - Logger.log(error ?? "") - let model = IBAiResponse() - model.type = 0 - sendRelpy(model: model) - } - } - } - - - func setupChatCallBack(){ - let chat = MixSdk.shared.chat - chat.callBack = {[weak self] model in - guard let self = self else {return} - print("\(model.type) : \(model.content ?? "")") - - if model.type == "start" { - reply = "" - } - else if model.type == "end" { +// var platform = MSPlatform.doubao +// var key = "" +// if code == 0 { +// platform = .yiyan +// } +// else if code == 1 { +// platform = .chatGPT +// key = "sk-proj-04ogvrZQqyaiv1OWw8OZT3BlbkFJG9Gyr8oFvRdmr3oXQNbX" +//// let gptModel = "gpt-4-turbo" +//// MixSdk.shared.chatGpt.changeModel(model:gptModel ) +// } +// else if code == 2 { +// platform = .kimi +// } +// else if code == 3 { +// platform = .doubao +// } +// MixSdk.shared.setPlatform(platform,key: key) +// } +// func fectchAiAudio(){ +// IBSender() +// .ability(IBAbility.fetchAiAudio) +// .parameters([]) +// .response {[weak self] result in +// guard let self = self else {return} +// if result.isSuccess,let data = result.value as? Data{ +// receiveAiData(sbcData: data) +// } +// else{ +// Logger.log(result) +// let model = IBAiResponse() +// model.type = 0 +// sendRelpy(model: model) +// } +// } +// } +// +// +//} +//extension IBAiManager{ +// func receiveAiData(sbcData:Data){ +// let pcmData = MSAudioConvert.sbcTopcm(sbcData) +// if pcmData.count == 0{ +// Logger.log("sbc2pcm失败") +// let model = IBAiResponse() +// model.type = 0 +// sendRelpy(model: model) +// return +// } +// guard let pcmPath = IBTools.saveToFile(data: pcmData) else {return} +// MixSdk.shared.stt.sentenceRecognize(filePath: pcmPath,format:"pcm",sample_rate:"16000",lang: "zh-cn") {[weak self] text, error in +// guard let self = self else {return} +// if let text = text,text.count > 0{ +// Logger.log(text) // let model = IBAiResponse() -// model.type = 2 -// model.value = reply +// model.type = 1 +// model.value = text // sendRelpy(model: model) - } - else if model.type == "middle"{ -// reply += model.content ?? "" - let data = IBAiResponse() - data.type = 2 - data.value = model.content ?? "" - sendRelpy(model: data) - } - } - } - - func sendRelpy(model:IBAiResponse){ - IBSender() - .ability(IBAbility.aiResponse) - .parameters([.aiResponse(model)]) - .response { result in - Logger.log(result) - } - } -} - -extension IBAiManager{ - func loginAction() { - MixSdk.shared.isDebug = true - let pwd = "aWGKrBWaijsKD5eEsVVU5rjWPI1sVy"//注册获得的密码 - self.startLogin(password:pwd) - } - func startLogin(password:String) { - MixSdk.shared.isDebug = true - let deviceId = "281106AFB0F7" - let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT" - - MixSdk.shared.auth.login(productKey:productKey,deviceId: deviceId, password: password){[weak self] token,error in - if let err = error{ - if case .reponseError(let code,let message) = err,code == 50021{ - //50021是账号或密码错误.可以在这里调用注册,重新注册后,之前的密码会被覆盖,APP更新保存的新密码 - self?.registerAction() - } - } - else{ - print(token ?? "") - } - } - } - @objc func registerAction() { - let deviceId = "281106AFB0F7" - let productId = "pafOCKLiUbeVHbdZlddH" - let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT" - MixSdk.shared.auth.register(productId: productId, productKey: productKey, deviceId: deviceId){[weak self] password,error in - if let pwd = password{ - print(pwd) - //deviceId和password APP要确保这个一一对应。 - self?.startLogin(password: pwd) - } - else{ - print(error!) - } - } - } -} +// +// MixSdk.shared.chat.send(content: text) +// } +// else{ +// Logger.log(error ?? "") +// let model = IBAiResponse() +// model.type = 0 +// sendRelpy(model: model) +// } +// } +// } +// +// +// func setupChatCallBack(){ +// let chat = MixSdk.shared.chat +// chat.callBack = {[weak self] model in +// guard let self = self else {return} +// print("\(model.type) : \(model.content ?? "")") +// +// if model.type == "start" { +// reply = "" +// } +// else if model.type == "end" { +//// let model = IBAiResponse() +//// model.type = 2 +//// model.value = reply +//// sendRelpy(model: model) +// } +// else if model.type == "middle"{ +//// reply += model.content ?? "" +// let data = IBAiResponse() +// data.type = 2 +// data.value = model.content ?? "" +// sendRelpy(model: data) +// } +// } +// } +// +// func sendRelpy(model:IBAiResponse){ +// IBSender() +// .ability(IBAbility.aiResponse) +// .parameters([.aiResponse(model)]) +// .response { result in +// Logger.log(result) +// } +// } +//} +// +//extension IBAiManager{ +// func loginAction() { +// MixSdk.shared.isDebug = true +// let pwd = "aWGKrBWaijsKD5eEsVVU5rjWPI1sVy"//注册获得的密码 +// self.startLogin(password:pwd) +// } +// func startLogin(password:String) { +// MixSdk.shared.isDebug = true +// let deviceId = "281106AFB0F7" +// let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT" +// +// MixSdk.shared.auth.login(productKey:productKey,deviceId: deviceId, password: password){[weak self] token,error in +// if let err = error{ +// if case .reponseError(let code,let message) = err,code == 50021{ +// //50021是账号或密码错误.可以在这里调用注册,重新注册后,之前的密码会被覆盖,APP更新保存的新密码 +// self?.registerAction() +// } +// } +// else{ +// print(token ?? "") +// } +// } +// } +// @objc func registerAction() { +// let deviceId = "281106AFB0F7" +// let productId = "pafOCKLiUbeVHbdZlddH" +// let productKey = "HHosiYUNdG42t1cTgKOzIUPOvAVMI2QT" +// MixSdk.shared.auth.register(productId: productId, productKey: productKey, deviceId: deviceId){[weak self] password,error in +// if let pwd = password{ +// print(pwd) +// //deviceId和password APP要确保这个一一对应。 +// self?.startLogin(password: pwd) +// } +// else{ +// print(error!) +// } +// } +// } +//} diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBNotify.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBNotify.swift index 9693031..25976a7 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBNotify.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBNotify.swift @@ -202,12 +202,12 @@ extension IBNotify { } //手表询问APP AI模型是否可用 if(data.bytes[1] == 0x05 && data.bytes[2] == 0x06){ - IBAiManager.shared.aiValid(data) +// IBAiManager.shared.aiValid(data) return true } //AI录音已准备好 if(data.bytes[1] == 0x05 && data.bytes[2] == 0x05){ - IBAiManager.shared.aiRequest(data) +// IBAiManager.shared.aiRequest(data) return true } //文件已接收完成 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift index dda7dc8..2088297 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/IBluetooth.swift @@ -58,7 +58,7 @@ class IBBluetooth: NSObject { centralManager = CBCentralManager(delegate: self, queue: nil) receiveManager.delegate = self - IBAiManager.shared.loginAction() +// IBAiManager.shared.loginAction() } /// 2AE5 diff --git a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPush.swift b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPush.swift index ec29b93..84ee676 100644 --- a/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPush.swift +++ b/IOTBluetooth/IOTBluetooth/IOTBluetooth/Models/IBPush.swift @@ -29,7 +29,7 @@ public class IBPush { for i in 0..<18{ let value = IBPush() value.type = IBPushType(rawValue: i)! - value.state = i < 10 ? 0:1 + value.state = 0 list.append(value) } return list