Commit 05eda689 authored by Steven杜宇's avatar Steven杜宇

// AI

parent a75ba694
...@@ -43,7 +43,13 @@ class YHAIChatConfiguration { ...@@ -43,7 +43,13 @@ class YHAIChatConfiguration {
if msg.isNeedSpiceMessage(), res.isNeedSpiceMessage() { if msg.isNeedSpiceMessage(), res.isNeedSpiceMessage() {
// 多个文字需要拼接 // 多个文字需要拼接
find = true find = true
msg.body.contentText += res.body.contentText if res.isTextCompleted() {
msg.isDone = true
} else {
msg.body.contentText += res.body.contentText
}
msg.updateBodyToData() msg.updateBodyToData()
} }
} }
......
...@@ -221,11 +221,11 @@ class YHAIRequestManager: NSObject { ...@@ -221,11 +221,11 @@ class YHAIRequestManager: NSObject {
if sessionDone { if sessionDone {
print("SESSION DONE") print("SESSION DONE")
} }
if receiveMessage.isCompleted() { if receiveMessage.isMessageCompleted() {
// 一段话结束需要重新生成uuid 来 // 一段话结束需要重新生成uuid 来
self.uuid = UUID().uuidString + NSDate().timeIntervalSince1970.description self.uuid = UUID().uuidString + NSDate().timeIntervalSince1970.description
} }
if !receiveMessage.isNotUserfulMessage() { if receiveMessage.isUserfulMessage() {
completion?(receiveMessage, sessionDone) completion?(receiveMessage, sessionDone)
} }
} }
......
...@@ -140,15 +140,53 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV ...@@ -140,15 +140,53 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < serviceArr.count { if 0 <= indexPath.item && indexPath.item < serviceArr.count {
let model = serviceArr[indexPath.item] let model = serviceArr[indexPath.item]
self.manager.getSubRobotChatConversationId(robotId: model.botId) {
sesseionId in if model.redirectMode == 1 { // web页面
let vc = YHAIRobotChatViewController() if !model.redirectPath.isEmpty {
vc.isNeedShowBannerHeader = model.isNeedShowBannerHeader() let vc = YHH5WebViewVC()
vc.myTitle = model.title vc.url = model.redirectPath
vc.robotId = model.botId let isEvaluation = true
vc.conversationId = sesseionId if isEvaluation {
vc.robotType = model.botType vc.isPushed = false
self.navigationController?.pushViewController(vc, animated: true) vc.isFullScreenFlag = true
vc.isHideNavigationBar = true
vc.evaluationResultCallback = {
dict in
block?(dict)
}
UIViewController.current?.present(vc, animated: true)
} else {
UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
}
}
} else if model.redirectMode == 2 {
// customerVoice -> APP客户心声 productList -> APP-首页银河甄选
if path == YHAIJumpPageType.customerHeart.rawValue {
//客户心声
let vc = YHOtherServiceViewController()
vc.classID = 5
UIViewController.current?.navigationController?.pushViewController(vc)
} else if path == YHAIJumpPageType.galaxySelect.rawValue {
// 银河甄选
let vc = YHSelectViewController()
vc.hideFlag = false
UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
}
} else if mode == 3 { // agent
self.manager.getSubRobotChatConversationId(robotId: model.botId) {
sesseionId in
let vc = YHAIRobotChatViewController()
vc.isNeedShowBannerHeader = model.isNeedShowBannerHeader()
vc.myTitle = model.title
vc.robotId = model.botId
vc.conversationId = sesseionId
vc.robotType = model.botType
self.navigationController?.pushViewController(vc, animated: true)
}
} }
} }
} }
......
...@@ -41,15 +41,23 @@ class YHAIChatMessage: CustomStringConvertible { ...@@ -41,15 +41,23 @@ class YHAIChatMessage: CustomStringConvertible {
var isDone: Bool = false var isDone: Bool = false
var body = YHAIMessageBody() var body = YHAIMessageBody()
func isCompleted() -> Bool { func isMessageCompleted() -> Bool {
if event.contains(completeText) { if self.body.status == "completed" {
return true
}
return false
}
func isTextCompleted() -> Bool {
if self.body.contentType == YHAIMessageType.text.rawValue && self.body.status == "done" && self.body.type == "answer" {
return true return true
} }
return false return false
} }
func setCompleted() { func setCompleted() {
event = self.completeText self.body.status = "completed"
} }
func isTextMessage() -> Bool { func isTextMessage() -> Bool {
...@@ -59,7 +67,7 @@ class YHAIChatMessage: CustomStringConvertible { ...@@ -59,7 +67,7 @@ class YHAIChatMessage: CustomStringConvertible {
func isNeedSpiceMessage() -> Bool { func isNeedSpiceMessage() -> Bool {
let type = self.getType() let type = self.getType()
return type == .text return type == .text && self.body.type == "answer"
} }
static func createQuestionMessage(_ text: String) -> YHAIChatMessage { static func createQuestionMessage(_ text: String) -> YHAIChatMessage {
...@@ -133,8 +141,8 @@ class YHAIChatMessage: CustomStringConvertible { ...@@ -133,8 +141,8 @@ class YHAIChatMessage: CustomStringConvertible {
} }
// //
func isNotUserfulMessage() -> Bool { func isUserfulMessage() -> Bool {
if !self.body.isStart() && !self.isCompleted() && !self.body.isDone() { if !self.body.isStart() && !self.body.isDone() {
return true return true
} }
return false return false
......
...@@ -120,11 +120,6 @@ class YHAIProductCell: UICollectionViewCell { ...@@ -120,11 +120,6 @@ class YHAIProductCell: UICollectionViewCell {
let degree = isRotateRight ? 2.0 : -2.0 let degree = isRotateRight ? 2.0 : -2.0
let transform = CGAffineTransform(rotationAngle: CGFloat(degree * CGFloat.pi / 180)) // 2 度转换为弧度 let transform = CGAffineTransform(rotationAngle: CGFloat(degree * CGFloat.pi / 180)) // 2 度转换为弧度
titleLabel.transform = transform bgImgView.transform = transform
subtitleLabel.transform = transform
blackButton.transform = transform
if model.cover.isEmpty {
bgImgView.image = UIImage(named: isRotateRight ? "ai_product_left" : "ai_product_right")
}
} }
} }
...@@ -68,7 +68,7 @@ class YHAITextMessageCell: UITableViewCell { ...@@ -68,7 +68,7 @@ class YHAITextMessageCell: UITableViewCell {
} else { } else {
isNeedShowCopyView = message.isDone isNeedShowCopyView = message.isDone
let complete = message.isCompleted() || message.isDone let complete = message.isDone
isNeedShowLoadingView = !complete isNeedShowLoadingView = !complete
} }
} }
......
...@@ -10,6 +10,7 @@ import UIKit ...@@ -10,6 +10,7 @@ import UIKit
class YHAIJumpPageTool { class YHAIJumpPageTool {
// mode = 0 // 1 web 2 原生页面 3 AI_Robot
// type = 0 // 0 普通 1 测评 // type = 0 // 0 普通 1 测评
static func jumpPageWithType(_ type:Int = 0, mode: Int, path: String, block:(([String:Any])->())?) { static func jumpPageWithType(_ type:Int = 0, mode: Int, path: String, block:(([String:Any])->())?) {
...@@ -26,8 +27,9 @@ class YHAIJumpPageTool { ...@@ -26,8 +27,9 @@ class YHAIJumpPageTool {
vc.evaluationResultCallback = { vc.evaluationResultCallback = {
dict in dict in
block?(dict) block?(dict)
UIViewController.current?.present(vc, animated: true)
} }
UIViewController.current?.present(vc, animated: true)
} else { } else {
UIViewController.current?.navigationController?.pushViewController(vc, animated: true) UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
} }
...@@ -47,6 +49,8 @@ class YHAIJumpPageTool { ...@@ -47,6 +49,8 @@ class YHAIJumpPageTool {
vc.hideFlag = false vc.hideFlag = false
UIViewController.current?.navigationController?.pushViewController(vc, animated: true) UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
} }
} else if mode == 3 {
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment